ATProto firehose: test replies, mentions

#978
in-reply-to-bridged
Ryan Barrett 2024-05-08 11:31:31 -07:00
rodzic 8ff5426c49
commit 72ae63f4a0
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 6BE31FDF4776E9D4
2 zmienionych plików z 62 dodań i 1 usunięć

Wyświetl plik

@ -89,6 +89,8 @@ def subscribe():
match = AT_URI_PATTERN.match(did_or_ref['uri'])
if match:
did = match.group('repo')
else:
return
else:
did = did_or_ref
@ -110,7 +112,7 @@ def subscribe():
# mentions
for facet in record.get('facets', []):
for feature in facet['features']:
if feature['$type'] == '#mention':
if feature['$type'] == 'app.bsky.richtext.facet#mention':
maybe_add(feature['did'])
# TODO: quote posts

Wyświetl plik

@ -135,6 +135,65 @@ class ATProtoFirehoseSubscribeTest(TestCase):
self.make_user('did:plc:bob', cls=ATProto, enabled_protocols=['eefake'])
self.assert_doesnt_enqueue(POST_BSKY)
def test_reply_direct_to_our_user(self):
self.assert_enqueues({
'$type': 'app.bsky.feed.post',
'text': 'I hereby reply',
'reply': {
'$type': 'app.bsky.feed.post#replyRef',
'parent': {'uri': 'at://did:alice/app.bsky.feed.post/parent-tid'},
'root': {'uri': '-'},
},
})
def test_reply_indirect_to_our_user(self):
self.assert_enqueues({
'$type': 'app.bsky.feed.post',
'text': 'I hereby reply',
'reply': {
'$type': 'app.bsky.feed.post#replyRef',
'root': {'uri': 'at://did:alice/app.bsky.feed.post/parent-tid'},
'parent': {'uri': '-'},
},
})
def test_reply_indirect_to_other(self):
self.assert_doesnt_enqueue({
'$type': 'app.bsky.feed.post',
'text': 'I hereby reply',
'reply': {
'$type': 'app.bsky.feed.post#replyRef',
'parent': {'uri': 'at://did:bob/app.bsky.feed.post/parent-tid'},
'root': {'uri': '-'},
},
})
def test_mention_our_user(self):
self.assert_enqueues({
'$type': 'app.bsky.feed.post',
'text': 'foo @alice bar',
'facets': [{
'$type': 'app.bsky.richtext.facet',
'features': [{
'$type': 'app.bsky.richtext.facet#mention',
'did': 'did:alice',
}],
}],
})
def test_mention_other(self):
self.assert_doesnt_enqueue({
'$type': 'app.bsky.feed.post',
'text': 'foo @bob bar',
'facets': [{
'$type': 'app.bsky.richtext.facet',
'features': [{
'$type': 'app.bsky.richtext.facet#mention',
'did': 'did:bob',
}],
}],
})
def test_like_of_our_user(self):
self.assert_enqueues({
'$type': 'app.bsky.feed.like',