atproto_firehose: handle #account and #identity events

for #1201
pull/1667/head
Ryan Barrett 2025-01-05 13:22:55 -08:00
rodzic ae0a7920a0
commit aa4f9e5bf8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -299,6 +299,10 @@ def handler():
def handle(limit=None):
def _handle_account(op):
# reload DID doc to fetch new changes
ATProto.load(op.repo, did_doc=True, remote=True)
def _handle(op):
at_uri = f'at://{op.repo}/{op.path}'
@ -345,7 +349,12 @@ def handle(limit=None):
seen = 0
while op := commits.get():
_handle(op)
match op.action:
case 'account':
_handle_account(op)
case _:
_handle(op)
seen += 1
if limit is not None and seen >= limit:
return

Wyświetl plik

@ -21,7 +21,7 @@ from granary.tests.test_bluesky import (
from multiformats import CID
from oauth_dropins.webutil import util
from oauth_dropins.webutil.appengine_config import tasks_client
from oauth_dropins.webutil.testutil import NOW
from oauth_dropins.webutil.testutil import NOW, requests_response
import simple_websocket
from atproto import ATProto, Cursor
@ -539,6 +539,12 @@ class ATProtoFirehoseHandleTest(ATProtoTestCase):
authed_as='did:plc:user', received_at='1900-02-04',
eta_seconds=delayed_eta)
@patch('requests.get', return_value=requests_response({**DID_DOC, 'new': 'stuff'}))
def test_account(self, _, __):
commits.put(Op(repo='did:plc:user', action='account', seq=789))
handle(limit=1)
self.assertEqual('stuff', Object.get_by_id('did:plc:user').raw['new'])
def test_unsupported_type(self, mock_create_task):
orig_objs = Object.query().count()