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 person import setPersonNotes
|
||||
from person import getDefaultPersonContext
|
||||
from person import getUpdateActorContext
|
||||
from person import getActorUpdateJson
|
||||
from person import savePersonQrcode
|
||||
from person import randomizeActorImages
|
||||
from person import personUpgradeActor
|
||||
|
@ -5817,22 +5817,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
actorJson['id'].replace('/', '#') + '.json'
|
||||
saveJson(actorJson, actorCacheFilename)
|
||||
# send profile update to followers
|
||||
pubStr = 'https://www.w3.org/ns/' + \
|
||||
'activitystreams#Public'
|
||||
pubNumber, pubDate = getStatusNumber()
|
||||
# remove the context from the actor json and put it
|
||||
# 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
|
||||
}
|
||||
updateActorJson = getActorUpdateJson()
|
||||
print('Sending actor update: ' + str(updateActorJson))
|
||||
self._postToOutbox(updateActorJson,
|
||||
self.server.projectVersion,
|
||||
|
|
164
person.py
164
person.py
|
@ -187,78 +187,106 @@ def randomizeActorImages(personJson: {}) -> None:
|
|||
'/image' + randStr + '.' + existingExtension
|
||||
|
||||
|
||||
def getUpdateActorContext() -> []:
|
||||
"""Returns the context used on actor updates
|
||||
def getActorUpdateJson(actorJson: {}) -> {}:
|
||||
"""Returns the json for an Person Update
|
||||
"""
|
||||
return [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"featured":
|
||||
pubNumber, _ = getStatusNumber()
|
||||
manuallyApprovesFollowers = actorJson['manuallyApprovesFollowers']
|
||||
return {
|
||||
'@context': [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"@id": "toot:featured",
|
||||
"@type": "@id"
|
||||
},
|
||||
"featuredTags":
|
||||
{
|
||||
"@id": "toot:featuredTags",
|
||||
"@type": "@id"
|
||||
},
|
||||
"alsoKnownAs":
|
||||
{
|
||||
"@id": "as:alsoKnownAs",
|
||||
"@type": "@id"
|
||||
},
|
||||
"movedTo":
|
||||
{
|
||||
"@id": "as:movedTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"schema": "http://schema.org#",
|
||||
"PropertyValue": "schema:PropertyValue",
|
||||
"value": "schema:value",
|
||||
"IdentityProof": "toot:IdentityProof",
|
||||
"discoverable": "toot:discoverable",
|
||||
"Device": "toot:Device",
|
||||
"Ed25519Signature": "toot:Ed25519Signature",
|
||||
"Ed25519Key": "toot:Ed25519Key",
|
||||
"Curve25519Key": "toot:Curve25519Key",
|
||||
"EncryptedMessage": "toot:EncryptedMessage",
|
||||
"publicKeyBase64": "toot:publicKeyBase64",
|
||||
"deviceId": "toot:deviceId",
|
||||
"claim":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:claim"
|
||||
},
|
||||
"fingerprintKey":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:fingerprintKey"
|
||||
},
|
||||
"identityKey":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:identityKey"
|
||||
},
|
||||
"devices":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:devices"
|
||||
},
|
||||
"messageFranking": "toot:messageFranking",
|
||||
"messageType": "toot:messageType",
|
||||
"cipherText": "toot:cipherText",
|
||||
"suspended": "toot:suspended",
|
||||
"focalPoint":
|
||||
{
|
||||
"@container": "@list",
|
||||
"@id": "toot:focalPoint"
|
||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||
"toot": "http://joinmastodon.org/ns#",
|
||||
"featured":
|
||||
{
|
||||
"@id": "toot:featured",
|
||||
"@type": "@id"
|
||||
},
|
||||
"featuredTags":
|
||||
{
|
||||
"@id": "toot:featuredTags",
|
||||
"@type": "@id"
|
||||
},
|
||||
"alsoKnownAs":
|
||||
{
|
||||
"@id": "as:alsoKnownAs",
|
||||
"@type": "@id"
|
||||
},
|
||||
"movedTo":
|
||||
{
|
||||
"@id": "as:movedTo",
|
||||
"@type": "@id"
|
||||
},
|
||||
"schema": "http://schema.org#",
|
||||
"PropertyValue": "schema:PropertyValue",
|
||||
"value": "schema:value",
|
||||
"IdentityProof": "toot:IdentityProof",
|
||||
"discoverable": "toot:discoverable",
|
||||
"Device": "toot:Device",
|
||||
"Ed25519Signature": "toot:Ed25519Signature",
|
||||
"Ed25519Key": "toot:Ed25519Key",
|
||||
"Curve25519Key": "toot:Curve25519Key",
|
||||
"EncryptedMessage": "toot:EncryptedMessage",
|
||||
"publicKeyBase64": "toot:publicKeyBase64",
|
||||
"deviceId": "toot:deviceId",
|
||||
"claim":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:claim"
|
||||
},
|
||||
"fingerprintKey":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:fingerprintKey"
|
||||
},
|
||||
"identityKey":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:identityKey"
|
||||
},
|
||||
"devices":
|
||||
{
|
||||
"@type": "@id",
|
||||
"@id": "toot:devices"
|
||||
},
|
||||
"messageFranking": "toot:messageFranking",
|
||||
"messageType": "toot:messageType",
|
||||
"cipherText": "toot:cipherText",
|
||||
"suspended": "toot:suspended",
|
||||
"focalPoint":
|
||||
{
|
||||
"@container": "@list",
|
||||
"@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:
|
||||
|
|
Loading…
Reference in New Issue