launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30787
Re: [Merge] ~pelpsi/launchpad:social-account-interface-and-implementation into launchpad:master
Diff comments:
> diff --git a/lib/lp/registry/interfaces/socialaccount.py b/lib/lp/registry/interfaces/socialaccount.py
> new file mode 100644
> index 0000000..73b4c5b
> --- /dev/null
> +++ b/lib/lp/registry/interfaces/socialaccount.py
> @@ -0,0 +1,90 @@
> +# Copyright 2023 Canonical Ltd. This software is licensed under the
> +# GNU Affero General Public License version 3 (see the file LICENSE).
> +
> +"""SocialAccount interfaces."""
> +
> +__all__ = ["ISocialAccount", "ISocialAccountSet", "PlatformType"]
> +
> +from lazr.enum import DBEnumeratedType, DBItem
> +from lazr.restful.declarations import exported, exported_as_webservice_entry
> +from lazr.restful.fields import Reference
> +from zope.interface import Interface
> +from zope.schema import Choice, Dict, Int, TextLine
> +
> +from lp import _
> +from lp.registry.interfaces.role import IHasOwner
> +
> +
> +class PlatformType(DBEnumeratedType):
This is a WIP: we need to define here the platformTypes and the related descriptions.
> + """Platform Type
> +
> + When a social account is added it is referring
> + to a given platform type.
> + """
> +
> + MATRIX = DBItem(
> + 1,
> + """
> + Matrix platform
> +
> + To define matrix
> + """,
> + )
> +
> + JABBER = DBItem(
> + 2,
> + """
> + Jabber platform
> +
> + To define jabber
> + """,
> + )
> +
> +
> +@exported_as_webservice_entry(as_of="beta")
> +class ISocialAccount(IHasOwner):
> + """Jabber specific user ID"""
> +
> + id = Int(title=_("Database ID"), required=True, readonly=True)
> + # schema=Interface will be overridden in person.py because of circular
> + # dependencies.
> + person = exported(
> + Reference(
> + title=_("Owner"), required=True, schema=Interface, readonly=True
> + )
> + )
> +
> + platform = exported(
> + Choice(
> + title=_("Platform type"),
> + required=True,
> + vocabulary=PlatformType,
> + default=PlatformType.MATRIX,
> + )
> + )
> +
> + identity = exported(
> + Dict(
> + title=_("SocialAccount identity"),
> + key_type=TextLine(),
> + required=True,
> + readonly=False,
> + description=_(
> + "A dictionary mapping attributes for the social media account "
> + "(JSON format specific per social media platform). "
> + ),
> + )
> + )
> +
> + def destroySelf():
> + """Delete this SocialAccount from the database."""
> +
> +
> +class ISocialAccountSet(Interface):
> + """The set of SocialAccounts."""
> +
> + def new(self, person, platform, identity):
> + """Create a new SocialAccount pointing to the given Person."""
> +
> + def getByPerson(person):
> + """Return all SocialAccounts for the given person."""
--
https://code.launchpad.net/~pelpsi/launchpad/+git/launchpad/+merge/457527
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad:social-account-interface-and-implementation into launchpad:master.
References