1
0
Fork 0

Allow removing followers and fix follow rejections

* adds the ability to remove a user from your followers list
* fixes verbs.Reject to process reject activities for previously accepted follows in both directions

fixes #2635
This commit is contained in:
Hugh Rundle 2023-11-19 20:03:48 +11:00
parent 06568aab88
commit 2ba0e3d7ff
No known key found for this signature in database
GPG key ID: A7E35779918253F9
9 changed files with 120 additions and 21 deletions

View file

@ -171,8 +171,36 @@ class Reject(Verb):
type: str = "Reject"
def action(self, allow_external_connections=True):
"""reject a follow request"""
obj = self.object.to_model(save=False, allow_create=False)
"""reject a follow or follow request"""
if self.object.type == "Follow":
model = apps.get_model("bookwyrm.UserFollowRequest")
obj = self.object.to_model(
model=model,
save=False,
allow_create=False,
allow_external_connections=allow_external_connections,
)
if not obj:
# This is a deletion (soft-block) of an accepted follow
model = apps.get_model("bookwyrm.UserFollows")
obj = self.object.to_model(
model=model,
save=False,
allow_create=False,
allow_external_connections=allow_external_connections,
)
else:
# it's something else
obj = self.object.to_model(
model=model,
save=False,
allow_create=False,
allow_external_connections=allow_external_connections,
)
if not obj:
# if we don't have the object, we can't reject it.
return
obj.reject()