mirror of https://gitlab.com/bashrc2/epicyon
Make actor updates as close to what mastodon does as possible
parent
ab3e3eb772
commit
0c397dba93
18
daemon.py
18
daemon.py
|
@ -55,7 +55,7 @@ from donate import getWebsite
|
||||||
from donate import setWebsite
|
from donate import setWebsite
|
||||||
from person import setPersonNotes
|
from person import setPersonNotes
|
||||||
from person import getDefaultPersonContext
|
from person import getDefaultPersonContext
|
||||||
from person import getUpdateActorContext
|
from person import getActorUpdateJson
|
||||||
from person import savePersonQrcode
|
from person import savePersonQrcode
|
||||||
from person import randomizeActorImages
|
from person import randomizeActorImages
|
||||||
from person import personUpgradeActor
|
from person import personUpgradeActor
|
||||||
|
@ -5817,22 +5817,8 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
actorJson['id'].replace('/', '#') + '.json'
|
actorJson['id'].replace('/', '#') + '.json'
|
||||||
saveJson(actorJson, actorCacheFilename)
|
saveJson(actorJson, actorCacheFilename)
|
||||||
# send profile update to followers
|
# send profile update to followers
|
||||||
pubStr = 'https://www.w3.org/ns/' + \
|
|
||||||
'activitystreams#Public'
|
|
||||||
pubNumber, pubDate = getStatusNumber()
|
pubNumber, pubDate = getStatusNumber()
|
||||||
# remove the context from the actor json and put it
|
updateActorJson = getActorUpdateJson()
|
||||||
# at the start of the Upgrade activity
|
|
||||||
del actorJson['@context']
|
|
||||||
updateActorContext = getUpdateActorContext()
|
|
||||||
updateActorJson = {
|
|
||||||
'@context': updateActorContext,
|
|
||||||
'id': actorJson['id'] + '#updates/' + pubNumber,
|
|
||||||
'type': 'Update',
|
|
||||||
'actor': actorJson['id'],
|
|
||||||
'to': [pubStr],
|
|
||||||
'cc': [actorJson['id'] + '/followers'],
|
|
||||||
'object': actorJson
|
|
||||||
}
|
|
||||||
print('Sending actor update: ' + str(updateActorJson))
|
print('Sending actor update: ' + str(updateActorJson))
|
||||||
self._postToOutbox(updateActorJson,
|
self._postToOutbox(updateActorJson,
|
||||||
self.server.projectVersion,
|
self.server.projectVersion,
|
||||||
|
|
36
person.py
36
person.py
|
@ -187,10 +187,13 @@ def randomizeActorImages(personJson: {}) -> None:
|
||||||
'/image' + randStr + '.' + existingExtension
|
'/image' + randStr + '.' + existingExtension
|
||||||
|
|
||||||
|
|
||||||
def getUpdateActorContext() -> []:
|
def getActorUpdateJson(actorJson: {}) -> {}:
|
||||||
"""Returns the context used on actor updates
|
"""Returns the json for an Person Update
|
||||||
"""
|
"""
|
||||||
return [
|
pubNumber, _ = getStatusNumber()
|
||||||
|
manuallyApprovesFollowers = actorJson['manuallyApprovesFollowers']
|
||||||
|
return {
|
||||||
|
'@context': [
|
||||||
"https://www.w3.org/ns/activitystreams",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
"https://w3id.org/security/v1",
|
"https://w3id.org/security/v1",
|
||||||
{
|
{
|
||||||
|
@ -258,7 +261,32 @@ def getUpdateActorContext() -> []:
|
||||||
"@id": "toot:focalPoint"
|
"@id": "toot:focalPoint"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
'id': actorJson['id'] + '#updates/' + pubNumber,
|
||||||
|
'type': 'Update',
|
||||||
|
'actor': actorJson['id'],
|
||||||
|
'to': ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
|
'cc': [actorJson['id'] + '/followers'],
|
||||||
|
'object': {
|
||||||
|
'id': actorJson['id'],
|
||||||
|
'type': actorJson['type'],
|
||||||
|
'following': actorJson['id'] + '/following',
|
||||||
|
'followers': actorJson['id'] + '/followers',
|
||||||
|
'inbox': actorJson['id'] + '/inbox',
|
||||||
|
'outbox': actorJson['id'] + '/outbox',
|
||||||
|
'featured': actorJson['id'] + '/collections/featured',
|
||||||
|
'featuredTags': actorJson['id'] + '/collections/tags',
|
||||||
|
'preferredUsername': actorJson['preferredUsername'],
|
||||||
|
'name': actorJson['name'],
|
||||||
|
'summary': actorJson['summary'],
|
||||||
|
'url': actorJson['url'],
|
||||||
|
'manuallyApprovesFollowers': manuallyApprovesFollowers,
|
||||||
|
'discoverable': actorJson['discoverable'],
|
||||||
|
'published': actorJson['published'],
|
||||||
|
'devices': actorJson['devices'],
|
||||||
|
"publicKey": actorJson['publicKey'],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def getDefaultPersonContext() -> str:
|
def getDefaultPersonContext() -> str:
|
||||||
|
|
Loading…
Reference in New Issue