kopia lustrzana https://github.com/snarfed/bridgy-fed
rodzic
38b646ef7d
commit
14a63b8106
11
protocol.py
11
protocol.py
|
@ -1146,7 +1146,7 @@ class Protocol:
|
|||
|
||||
Args:
|
||||
to_user (models.User)
|
||||
text (str)
|
||||
text (str): message content. May be HTML.
|
||||
type (str): one of DM.TYPES
|
||||
"""
|
||||
dm = DM(protocol=bot_cls.LABEL, type=type)
|
||||
|
@ -1165,11 +1165,18 @@ class Protocol:
|
|||
target_uri = to_user.target_for(to_user.obj, shared=False)
|
||||
target = Target(protocol=to_user.LABEL, uri=target_uri)
|
||||
obj_key = Object(id=id, source_protocol='web', undelivered=[target], our_as1={
|
||||
'objectType': 'activity',
|
||||
'verb': 'post',
|
||||
'id': f'{id}-create',
|
||||
'actor': bot.key.id(),
|
||||
'object': {
|
||||
'objectType': 'note',
|
||||
'id': id,
|
||||
'actor': bot.key.id(),
|
||||
'author': bot.key.id(),
|
||||
'content': text,
|
||||
'to': [to_user.key.id()],
|
||||
},
|
||||
'to': [to_user.key.id()],
|
||||
}).put()
|
||||
|
||||
common.create_task(queue='send', obj=obj_key.urlsafe(), protocol=to_user.LABEL,
|
||||
|
|
|
@ -399,13 +399,19 @@ class IntegrationTests(TestCase):
|
|||
self.assert_equals(('http://inst/inbox',), args)
|
||||
message = '<p>Welcome to Bridgy Fed! Your account will soon be bridged to Bluesky at <a href="https://bsky.app/profile/alice.inst.ap.brid.gy">alice.inst.ap.brid.gy</a>. <a href="https://fed.brid.gy/docs">See the docs</a> and <a href="https://fed.brid.gy/ap/@alice@inst">your user page</a> for more information. To disable this and delete your bridged profile, block this account.</p>'
|
||||
self.assert_equals({
|
||||
'type': 'Create',
|
||||
'id': 'https://bsky.brid.gy/r/https://bsky.brid.gy/#welcome-dm-https://inst/alice-2022-01-02T03:04:05+00:00-create',
|
||||
'actor': 'https://bsky.brid.gy/bsky.brid.gy',
|
||||
'object': {
|
||||
'type': 'Note',
|
||||
'id': 'https://bsky.brid.gy/r/https://bsky.brid.gy/#welcome-dm-https://inst/alice-2022-01-02T03:04:05+00:00',
|
||||
'actor': 'https://bsky.brid.gy/bsky.brid.gy',
|
||||
'attributedTo': 'https://bsky.brid.gy/bsky.brid.gy',
|
||||
'content': message,
|
||||
'contentMap': {'en': message},
|
||||
'content_is_html': True,
|
||||
'to': ['https://inst/alice'],
|
||||
},
|
||||
'to': ['https://inst/alice'],
|
||||
}, json_loads(kwargs['data']), ignore=['to', '@context'])
|
||||
|
||||
# bot user follows back
|
||||
|
|
Ładowanie…
Reference in New Issue