Skip to content

Commit

Permalink
Protocol.maybe_delete_copy: minor tweaks
Browse files Browse the repository at this point in the history
for #783
  • Loading branch information
snarfed committed May 23, 2024
1 parent 9de5eb4 commit aa5ec4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
23 changes: 12 additions & 11 deletions protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,20 +1099,21 @@ def maybe_delete_copy(copy_cls, user):
return

now = util.now().isoformat()
delete_id = f'{copy_user_id}#delete-copy-{copy_cls.LABEL}-{now}'
delete = Object(id=delete_id, our_as1={
'id': delete_id,
'objectType': 'activity',
'verb': 'delete',
'actor': 'fake:user',
'object': copy_user_id,
})
target = Target(protocol=copy_cls.LABEL, uri=copy_cls.target_for(delete))
delete.undelivered = [target]
delete_id = f'{user.key.id()}#delete-copy-{copy_cls.LABEL}-{now}'
delete = Object(id=delete_id, source_protocol=user.LABEL, our_as1={
'id': delete_id,
'objectType': 'activity',
'verb': 'delete',
'actor': user.key.id(),
'object': copy_user_id,
})

target_uri = copy_cls.target_for(Object(id=copy_user_id))
delete.undelivered = [Target(protocol=copy_cls.LABEL, uri=target_uri)]
delete.put()

common.create_task(queue='send', obj=delete.key.urlsafe(),
url=target.uri, protocol=target.protocol,
url=target_uri, protocol=copy_cls.LABEL,
user=user.key.urlsafe())

@classmethod
Expand Down
12 changes: 6 additions & 6 deletions tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -2037,9 +2037,9 @@ def test_follow_and_block_protocol_user_sets_enabled_protocols(self):

# ...and delete copy actor
self.assertEqual(
[('fake:u:eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00',
'fake:u:eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00:target')],
Fake.sent)
[('eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00',
'fake:u:eefake:user:target')],
Fake.sent)

def test_follow_bot_user_refreshes_profile(self):
# bot user
Expand Down Expand Up @@ -2182,9 +2182,9 @@ def test_dm_no_yes_sets_enabled_protocols(self):

# ...and delete copy actor
self.assertEqual(
[('fake:u:eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00',
'fake:u:eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00:target')],
Fake.sent)
[('eefake:user#delete-copy-fake-2022-01-02T03:04:05+00:00',
'fake:u:eefake:user:target')],
Fake.sent)

@patch('protocol.LIMITED_DOMAINS', ['lim.it'])
@patch('requests.get')
Expand Down

0 comments on commit aa5ec4c

Please sign in to comment.