mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 15:49:16 +02:00
Test bot can now unfollow
This commit is contained in:
parent
81e7f03f77
commit
3ad1fe17d5
6 changed files with 100 additions and 13 deletions
|
@ -130,7 +130,7 @@ class SystemActor(object):
|
|||
'No handler for activity %s', ac['type'])
|
||||
return
|
||||
|
||||
return handler(ac, actor)
|
||||
return handler(data, actor)
|
||||
|
||||
|
||||
class LibraryActor(SystemActor):
|
||||
|
@ -269,6 +269,40 @@ class TestActor(SystemActor):
|
|||
to=[ac['actor']],
|
||||
on_behalf_of=test_actor)
|
||||
|
||||
def handle_undo(self, ac, sender):
|
||||
if ac['object']['type'] != 'Follow':
|
||||
return
|
||||
|
||||
if ac['object']['actor'] != sender.url:
|
||||
# not the same actor, permission issue
|
||||
return
|
||||
|
||||
test_actor = self.get_actor_instance()
|
||||
models.Follow.objects.filter(
|
||||
actor=sender,
|
||||
target=test_actor,
|
||||
).delete()
|
||||
# we also unfollow the sender, if possible
|
||||
try:
|
||||
follow = models.Follow.objects.get(
|
||||
target=sender,
|
||||
actor=test_actor,
|
||||
)
|
||||
except models.Follow.DoesNotExist:
|
||||
return
|
||||
undo = {
|
||||
'@context': serializers.AP_CONTEXT,
|
||||
'type': 'Undo',
|
||||
'id': follow.get_federation_url() + '/undo',
|
||||
'actor': test_actor.url,
|
||||
'object': serializers.FollowSerializer(follow).data,
|
||||
}
|
||||
follow.delete()
|
||||
activity.deliver(
|
||||
undo,
|
||||
to=[sender.url],
|
||||
on_behalf_of=test_actor)
|
||||
|
||||
SYSTEM_ACTORS = {
|
||||
'library': LibraryActor(),
|
||||
'test': TestActor(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue