launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #33129
Re: [Merge] ~ines-almeida/launchpad:add-github-social into launchpad:master
Diff comments:
> diff --git a/lib/lp/registry/interfaces/socialaccount.py b/lib/lp/registry/interfaces/socialaccount.py
> index 4c8134d..f7f6d9e 100644
> --- a/lib/lp/registry/interfaces/socialaccount.py
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -160,7 +170,39 @@ class MatrixPlatform(SocialPlatform):
> )
>
>
> +class GithubPlatform(SocialPlatform):
> + title = "GitHub"
> + identity_fields = ["username"]
> + identity_fields_example = {
> + "username": "mark",
> + "homeserver": "ubuntu.com",
Need to remove this
> + }
> + platform_type = SocialPlatformType.GITHUB
> + icon = "social-github"
> + display_format = "<strong>/{username}</strong>"
> + url = "https://github.com/{username}"
> +
> + @classmethod
> + def validate_identity(cls, identity):
> + if not all(
> + identity.get(required_field)
> + for required_field in cls.identity_fields
> + ):
> + raise SocialAccountIdentityError(
> + f"You must provide the following fields: "
> + f"{', '.join(cls.identity_fields)}."
> + )
> + if not isinstance(identity["username"], str):
> + raise SocialAccountIdentityError("Username must be a string.")
> + # GitHub username can contain a-z, 0-9, and -
> + # ref: https://docs.github.com/en/enterprise-cloud@latest/admin/managing-iam/iam-configuration-reference/username-considerations-for-external-authentication#about-username-normalization # noqa: E501
> + username_regex = r"^[A-z0-9-]+"
> + if not re.match(username_regex, identity["username"]):
> + raise SocialAccountIdentityError("Username must be valid.")
> +
> +
> SOCIAL_PLATFORM_TYPES_MAP = {
> + SocialPlatformType.GITHUB: GithubPlatform,
> SocialPlatformType.MATRIX: MatrixPlatform,
> }
>
--
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/494263
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:add-github-social into launchpad:master.
Follow ups