create() can read the "tag" field of an Actor and create Mention objects as appropriate.

Tests updated and passing.
issue-47
Marnanel Thurman 2020-10-29 04:20:31 +00:00
rodzic 297d3cbf56
commit c61afd585e
2 zmienionych plików z 43 dodań i 5 usunięć

Wyświetl plik

@ -238,14 +238,53 @@ def on_note(fields, address):
newbie,
)
return newbie
except Exception as ke:
logger.debug('%s: failed to create status: %s',
address,
ke)
return None
if 'tag' in fields:
logger.debug('%s: adding tags', address)
for tag in fields['tag']:
if 'type' not in tag or 'href' not in tag:
logger.debug('%s: -- missing fields: %s',
address, tag)
continue
if tag['type'].lower() != 'mention':
logger.debug('%s: -- unknown tag type: %s',
address, tag)
continue
logger.debug('%s: -- %s',
address, tag['href'])
whom = sombrero_fetch.fetch(tag['href'],
expected_type = trilby_models.Person)
if whom is None:
logger.debug('%s: -- not found',
address)
continue
mention = trilby_models.Mention(
status = newbie,
whom = whom,
)
mention.save()
logger.debug('%s: -- %s',
address, mention)
logger.debug('%s: -- tags done',
address)
return newbie
def on_announce(fields, address):
logger.debug('%s: on_announce %s', address, fields)

Wyświetl plik

@ -315,7 +315,6 @@ class Tests(Create_TestCase):
msg = 'status is in the same conversation',
)
@skip("Mentions are not yet implemented")
@httpretty.activate
def test_with_mentions(self):
@ -327,7 +326,7 @@ class Tests(Create_TestCase):
'tag': [
{
'type': 'Mention',
'href': self._fred.id,
'href': self._fred.url,
},
],
}
@ -341,7 +340,7 @@ class Tests(Create_TestCase):
self.assertIn(
self._fred,
status.mentions,
status.tags,
msg = 'status mentions self._fred',
)