mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 08:41:00 +00:00
Don't show deleted follows, and sort publicly
This commit is contained in:
parent
23db8f3dd8
commit
13ebe14cf9
3 changed files with 20 additions and 10 deletions
|
@ -3,7 +3,7 @@ from django.utils.decorators import method_decorator
|
|||
from django.views.generic import ListView
|
||||
|
||||
from users.decorators import identity_required
|
||||
from users.models import Follow, FollowStates
|
||||
from users.models import Follow, FollowStates, IdentityStates
|
||||
|
||||
|
||||
@method_decorator(identity_required, name="dispatch")
|
||||
|
@ -39,6 +39,8 @@ class Follows(ListView):
|
|||
"source",
|
||||
"source__domain",
|
||||
)
|
||||
.exclude(source__state__in=IdentityStates.group_deleted())
|
||||
.exclude(target__state__in=IdentityStates.group_deleted())
|
||||
.order_by("-created")
|
||||
)
|
||||
|
||||
|
|
|
@ -53,6 +53,10 @@ class IdentityStates(StateGraph):
|
|||
outdated.transitions_to(updated)
|
||||
updated.transitions_to(outdated)
|
||||
|
||||
@classmethod
|
||||
def group_deleted(cls):
|
||||
return [cls.deleted, cls.deleted_fanned_out]
|
||||
|
||||
@classmethod
|
||||
async def targets_fan_out(cls, identity: "Identity", type_: str) -> None:
|
||||
from activities.models import FanOut
|
||||
|
@ -115,9 +119,7 @@ class IdentityStates(StateGraph):
|
|||
|
||||
class IdentityQuerySet(models.QuerySet):
|
||||
def not_deleted(self):
|
||||
query = self.exclude(
|
||||
state__in=[IdentityStates.deleted, IdentityStates.deleted_fanned_out]
|
||||
)
|
||||
query = self.exclude(state__in=IdentityStates.group_deleted())
|
||||
return query
|
||||
|
||||
|
||||
|
|
|
@ -16,14 +16,20 @@ class IdentityService:
|
|||
self.identity = identity
|
||||
|
||||
def following(self) -> models.QuerySet[Identity]:
|
||||
return Identity.objects.filter(
|
||||
inbound_follows__source=self.identity
|
||||
).not_deleted()
|
||||
return (
|
||||
Identity.objects.filter(inbound_follows__source=self.identity)
|
||||
.not_deleted()
|
||||
.order_by("username")
|
||||
.select_related("domain")
|
||||
)
|
||||
|
||||
def followers(self) -> models.QuerySet[Identity]:
|
||||
return Identity.objects.filter(
|
||||
outbound_follows__target=self.identity
|
||||
).not_deleted()
|
||||
return (
|
||||
Identity.objects.filter(outbound_follows__target=self.identity)
|
||||
.not_deleted()
|
||||
.order_by("username")
|
||||
.select_related("domain")
|
||||
)
|
||||
|
||||
def follow_from(self, from_identity: Identity) -> Follow:
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue