add "activity_url" property to Status, and corresponding STATUS_ACTIVITY_URL template to settings

status-serialisers
Marnanel Thurman 2020-10-29 00:27:46 +00:00
rodzic e9af25bc6f
commit 88bef76a14
2 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -43,6 +43,7 @@ KEPI = {
'USER_LINK': '/users/%(username)s',
'COLLECTION_LINK': '/users/%(username)s/%(listname)s',
'STATUS_LINK': '/users/%(username)s/%(id)s',
'STATUS_ACTIVITY_LINK': '/users/%(username)s/%(id)s/activity',
'STATUS_FEED_LINK': '/users/%(username)s/feed/%(id)s',
'USER_FEED_LINK': '/users/%(username)s/feed',
'USER_WEBFINGER_LINK': '/.well-known/webfinger?resource=acct:%(username)s@%(hostname)s',

Wyświetl plik

@ -193,6 +193,18 @@ class Status(PolymorphicModel):
'id': self.id,
})
@property
def activity_url(self):
if self.remote_url is not None:
raise ValueError(
"Activity URL is not stored for remote statuses",
)
return uri_to_url(settings.KEPI['STATUS_ACTIVITY_LINK'] % {
'username': self.account.username,
'id': self.id,
})
@property
def ancestors(self):