kopia lustrzana https://gitlab.com/marnanel/chapeau
create() can read the "tag" field of an Actor and create Mention objects as appropriate.
Tests updated and passing.issue-47
rodzic
297d3cbf56
commit
c61afd585e
|
@ -238,14 +238,53 @@ def on_note(fields, address):
|
||||||
newbie,
|
newbie,
|
||||||
)
|
)
|
||||||
|
|
||||||
return newbie
|
|
||||||
|
|
||||||
except Exception as ke:
|
except Exception as ke:
|
||||||
logger.debug('%s: failed to create status: %s',
|
logger.debug('%s: failed to create status: %s',
|
||||||
address,
|
address,
|
||||||
ke)
|
ke)
|
||||||
return None
|
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):
|
def on_announce(fields, address):
|
||||||
|
|
||||||
logger.debug('%s: on_announce %s', address, fields)
|
logger.debug('%s: on_announce %s', address, fields)
|
||||||
|
|
|
@ -315,7 +315,6 @@ class Tests(Create_TestCase):
|
||||||
msg = 'status is in the same conversation',
|
msg = 'status is in the same conversation',
|
||||||
)
|
)
|
||||||
|
|
||||||
@skip("Mentions are not yet implemented")
|
|
||||||
@httpretty.activate
|
@httpretty.activate
|
||||||
def test_with_mentions(self):
|
def test_with_mentions(self):
|
||||||
|
|
||||||
|
@ -327,7 +326,7 @@ class Tests(Create_TestCase):
|
||||||
'tag': [
|
'tag': [
|
||||||
{
|
{
|
||||||
'type': 'Mention',
|
'type': 'Mention',
|
||||||
'href': self._fred.id,
|
'href': self._fred.url,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -341,7 +340,7 @@ class Tests(Create_TestCase):
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
self._fred,
|
self._fred,
|
||||||
status.mentions,
|
status.tags,
|
||||||
msg = 'status mentions self._fred',
|
msg = 'status mentions self._fred',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue