Skip to content

Commit

Permalink
atproto_firehose load_dids: don't load disabled ATProto users
Browse files Browse the repository at this point in the history
for #1669
  • Loading branch information
snarfed committed Jan 7, 2025
1 parent 1aca15e commit 57fa6a1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion atproto_firehose.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def _load_dids():
if not DEBUG:
Timer(STORE_CURSOR_FREQ.total_seconds(), _load_dids).start()

atproto_query = ATProto.query(ATProto.enabled_protocols != None,
atproto_query = ATProto.query(ATProto.status == None,
ATProto.enabled_protocols != None,
ATProto.updated > atproto_loaded_at)
loaded_at = ATProto.query().order(-ATProto.updated).get().updated
new_atproto = [key.id() for key in atproto_query.iter(keys_only=True)]
Expand Down
6 changes: 6 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ indexes:
- name: updated
- name: enabled_protocols

- kind: ATProto
properties:
- name: status
- name: enabled_protocols
- name: updated

- kind: AtpRepo
properties:
- name: status
Expand Down
11 changes: 11 additions & 0 deletions tests/test_atproto_firehose.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,17 @@ def test_load_dids_updated_atproto_user(self):
self.assert_enqueues({'$type': 'app.bsky.feed.post'}, repo='did:plc:eve')
self.assertIn('did:plc:eve', atproto_firehose.atproto_dids)

def test_load_dids_disabled_atproto_user(self):
self.cursor.cursor = 1
self.cursor.put()

self.store_object(id='did:plc:eve', raw=DID_DOC)
eve = self.make_user('did:plc:eve', cls=ATProto, enabled_protocols=['efake'],
manual_opt_out=True)

self.subscribe()
self.assertNotIn('did:plc:eve', atproto_firehose.atproto_dids)

def test_load_dids_atprepo(self):
FakeWebsocketClient.to_receive = [({'op': 1, 't': '#info'}, {})]
self.subscribe()
Expand Down

0 comments on commit 57fa6a1

Please sign in to comment.