kopia lustrzana https://github.com/snarfed/bridgy-fed
				
				
				
			
							rodzic
							
								
									ae0a7920a0
								
							
						
					
					
						commit
						aa4f9e5bf8
					
				| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue