diff options
author | Andrew Godwin | 2022-12-16 19:42:48 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-12-16 19:42:48 -0700 |
commit | 12567f6891ad591390cbd74c0e7b77a4a024a24e (patch) | |
tree | 39a6bab590d3f1bde3802854d4a1175780404276 /users/models | |
parent | c588567c8698700cd347d9b8f884a7967890aa58 (diff) | |
download | takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.gz takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.tar.bz2 takahe-12567f6891ad591390cbd74c0e7b77a4a024a24e.zip |
Identity admin/moderation
Diffstat (limited to 'users/models')
-rw-r--r-- | users/models/identity.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/users/models/identity.py b/users/models/identity.py index 574e54e..d6c35d2 100644 --- a/users/models/identity.py +++ b/users/models/identity.py @@ -55,6 +55,11 @@ class Identity(StatorModel): Represents both local and remote Fediverse identities (actors) """ + class Restriction(models.IntegerChoices): + none = 0 + limited = 1 + blocked = 2 + # The Actor URI is essentially also a PK - we keep the default numeric # one around as well for making nice URLs etc. actor_uri = models.CharField(max_length=500, unique=True) @@ -105,6 +110,13 @@ class Identity(StatorModel): # Should be a list of object URIs (we don't want a full M2M here) pinned = models.JSONField(blank=True, null=True) + # Admin-only moderation fields + sensitive = models.BooleanField(default=False) + restriction = models.IntegerField( + choices=Restriction.choices, default=Restriction.none + ) + admin_notes = models.TextField(null=True, blank=True) + private_key = models.TextField(null=True, blank=True) public_key = models.TextField(null=True, blank=True) public_key_id = models.TextField(null=True, blank=True) @@ -124,6 +136,8 @@ class Identity(StatorModel): view = "/@{self.username}@{self.domain_id}/" action = "{view}action/" activate = "{view}activate/" + admin = "/admin/identities/" + admin_edit = "{admin}{self.pk}/" def get_scheme(self, url): return "https" @@ -197,9 +211,16 @@ class Identity(StatorModel): domain = domain.lower() try: if local: - return cls.objects.get(username=username, domain_id=domain, local=True) + return cls.objects.get( + username=username, + domain_id=domain, + local=True, + ) else: - return cls.objects.get(username=username, domain_id=domain) + return cls.objects.get( + username=username, + domain_id=domain, + ) except cls.DoesNotExist: if fetch and not local: actor_uri, handle = async_to_sync(cls.fetch_webfinger)( @@ -277,6 +298,14 @@ class Identity(StatorModel): # TODO: Setting return self.data_age > 60 * 24 * 24 + @property + def blocked(self) -> bool: + return self.restriction == self.Restriction.blocked + + @property + def limited(self) -> bool: + return self.restriction == self.Restriction.limited + ### ActivityPub (outbound) ### def to_ap(self): |