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,
|
||||||
|
|
164
person.py
164
person.py
|
@ -187,78 +187,106 @@ 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()
|
||||||
"https://www.w3.org/ns/activitystreams",
|
manuallyApprovesFollowers = actorJson['manuallyApprovesFollowers']
|
||||||
"https://w3id.org/security/v1",
|
return {
|
||||||
{
|
'@context': [
|
||||||
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
"https://www.w3.org/ns/activitystreams",
|
||||||
"toot": "http://joinmastodon.org/ns#",
|
"https://w3id.org/security/v1",
|
||||||
"featured":
|
|
||||||
{
|
{
|
||||||
"@id": "toot:featured",
|
"manuallyApprovesFollowers": "as:manuallyApprovesFollowers",
|
||||||
"@type": "@id"
|
"toot": "http://joinmastodon.org/ns#",
|
||||||
},
|
"featured":
|
||||||
"featuredTags":
|
{
|
||||||
{
|
"@id": "toot:featured",
|
||||||
"@id": "toot:featuredTags",
|
"@type": "@id"
|
||||||
"@type": "@id"
|
},
|
||||||
},
|
"featuredTags":
|
||||||
"alsoKnownAs":
|
{
|
||||||
{
|
"@id": "toot:featuredTags",
|
||||||
"@id": "as:alsoKnownAs",
|
"@type": "@id"
|
||||||
"@type": "@id"
|
},
|
||||||
},
|
"alsoKnownAs":
|
||||||
"movedTo":
|
{
|
||||||
{
|
"@id": "as:alsoKnownAs",
|
||||||
"@id": "as:movedTo",
|
"@type": "@id"
|
||||||
"@type": "@id"
|
},
|
||||||
},
|
"movedTo":
|
||||||
"schema": "http://schema.org#",
|
{
|
||||||
"PropertyValue": "schema:PropertyValue",
|
"@id": "as:movedTo",
|
||||||
"value": "schema:value",
|
"@type": "@id"
|
||||||
"IdentityProof": "toot:IdentityProof",
|
},
|
||||||
"discoverable": "toot:discoverable",
|
"schema": "http://schema.org#",
|
||||||
"Device": "toot:Device",
|
"PropertyValue": "schema:PropertyValue",
|
||||||
"Ed25519Signature": "toot:Ed25519Signature",
|
"value": "schema:value",
|
||||||
"Ed25519Key": "toot:Ed25519Key",
|
"IdentityProof": "toot:IdentityProof",
|
||||||
"Curve25519Key": "toot:Curve25519Key",
|
"discoverable": "toot:discoverable",
|
||||||
"EncryptedMessage": "toot:EncryptedMessage",
|
"Device": "toot:Device",
|
||||||
"publicKeyBase64": "toot:publicKeyBase64",
|
"Ed25519Signature": "toot:Ed25519Signature",
|
||||||
"deviceId": "toot:deviceId",
|
"Ed25519Key": "toot:Ed25519Key",
|
||||||
"claim":
|
"Curve25519Key": "toot:Curve25519Key",
|
||||||
{
|
"EncryptedMessage": "toot:EncryptedMessage",
|
||||||
"@type": "@id",
|
"publicKeyBase64": "toot:publicKeyBase64",
|
||||||
"@id": "toot:claim"
|
"deviceId": "toot:deviceId",
|
||||||
},
|
"claim":
|
||||||
"fingerprintKey":
|
{
|
||||||
{
|
"@type": "@id",
|
||||||
"@type": "@id",
|
"@id": "toot:claim"
|
||||||
"@id": "toot:fingerprintKey"
|
},
|
||||||
},
|
"fingerprintKey":
|
||||||
"identityKey":
|
{
|
||||||
{
|
"@type": "@id",
|
||||||
"@type": "@id",
|
"@id": "toot:fingerprintKey"
|
||||||
"@id": "toot:identityKey"
|
},
|
||||||
},
|
"identityKey":
|
||||||
"devices":
|
{
|
||||||
{
|
"@type": "@id",
|
||||||
"@type": "@id",
|
"@id": "toot:identityKey"
|
||||||
"@id": "toot:devices"
|
},
|
||||||
},
|
"devices":
|
||||||
"messageFranking": "toot:messageFranking",
|
{
|
||||||
"messageType": "toot:messageType",
|
"@type": "@id",
|
||||||
"cipherText": "toot:cipherText",
|
"@id": "toot:devices"
|
||||||
"suspended": "toot:suspended",
|
},
|
||||||
"focalPoint":
|
"messageFranking": "toot:messageFranking",
|
||||||
{
|
"messageType": "toot:messageType",
|
||||||
"@container": "@list",
|
"cipherText": "toot:cipherText",
|
||||||
"@id": "toot:focalPoint"
|
"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:
|
def getDefaultPersonContext() -> str:
|
||||||
|
|
Loading…
Reference in New Issue