Skip to content

Commit

Permalink
bug fix, don't deliver activities to users if their Follower is inactive
Browse files Browse the repository at this point in the history
  • Loading branch information
snarfed committed Mar 4, 2023
1 parent fa2a9a1 commit bc15902
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def inbox(domain=None):
if obj.type in ('share', 'create', 'post') and actor and actor_id:
logger.info(f'Delivering to followers of {actor_id}')
for f in Follower.query(Follower.dest == actor_id,
Follower.status == 'active',
projection=[Follower.src]):
if f.src not in obj.domains:
obj.domains.append(f.src)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_activitypub.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def _test_inbox_create_obj(self, path, mock_head, mock_get, mock_post):
Follower.get_or_create(NOTE['actor'], 'foo.com')
Follower.get_or_create('http://other/actor', 'bar.com')
Follower.get_or_create(NOTE['actor'], 'baz.com')
Follower.get_or_create(NOTE['actor'], 'baj.com', status='inactive')

mock_head.return_value = requests_response(url='http://target')
mock_get.return_value = self.as2_resp(ACTOR) # source actor
Expand Down Expand Up @@ -440,6 +441,7 @@ def test_repost_of_federated_post(self, mock_head, mock_get, mock_post):
def test_shared_inbox_repost(self, mock_head, mock_get, mock_post):
Follower.get_or_create(ACTOR['id'], 'foo.com')
Follower.get_or_create(ACTOR['id'], 'baz.com')
Follower.get_or_create(ACTOR['id'], 'baj.com', status='inactive')

mock_head.return_value = requests_response(url='http://target')
mock_get.side_effect = [
Expand Down

0 comments on commit bc15902

Please sign in to comment.