mirror of https://gitlab.com/bashrc2/epicyon
Send Move activity after movedTo is changed
parent
ff93681130
commit
fc0f8d1764
12
daemon.py
12
daemon.py
|
@ -72,6 +72,7 @@ from person import add_actor_update_timestamp
|
|||
from person import set_person_notes
|
||||
from person import get_default_person_context
|
||||
from person import get_actor_update_json
|
||||
from person import get_actor_move_json
|
||||
from person import save_person_qrcode
|
||||
from person import randomize_actor_images
|
||||
from person import person_upgrade_actor
|
||||
|
@ -6312,6 +6313,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
if boundary:
|
||||
# get the various avatar, banner and background images
|
||||
actor_changed = True
|
||||
send_move_activity = False
|
||||
profile_media_types = (
|
||||
'avatar', 'image',
|
||||
'banner', 'search_banner',
|
||||
|
@ -7229,6 +7231,7 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
'://' in fields['movedTo'] and \
|
||||
'.' in fields['movedTo']:
|
||||
actor_json['movedTo'] = fields['movedTo']
|
||||
send_move_activity = True
|
||||
actor_changed = True
|
||||
else:
|
||||
if moved_to:
|
||||
|
@ -8414,6 +8417,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.project_version,
|
||||
nickname,
|
||||
curr_session, proxy_type)
|
||||
# send move activity if necessary
|
||||
if send_move_activity:
|
||||
move_actor_json = get_actor_move_json(actor_json)
|
||||
print('Sending Move activity: ' +
|
||||
str(move_actor_json))
|
||||
self._post_to_outbox(move_actor_json,
|
||||
self.server.project_version,
|
||||
nickname,
|
||||
curr_session, proxy_type)
|
||||
|
||||
# deactivate the account
|
||||
if fields.get('deactivateThisAccount'):
|
||||
|
|
25
person.py
25
person.py
|
@ -339,6 +339,31 @@ def get_actor_update_json(actor_json: {}) -> {}:
|
|||
}
|
||||
|
||||
|
||||
def get_actor_move_json(actor_json: {}) -> {}:
|
||||
"""Returns the json for a Move activity after movedTo has been set
|
||||
within the actor
|
||||
https://codeberg.org/fediverse/fep/src/branch/main/fep/7628/fep-7628.md
|
||||
"""
|
||||
if not actor_json.get('movedTo'):
|
||||
return None
|
||||
if '://' not in actor_json['movedTo'] or \
|
||||
'.' not in actor_json['movedTo']:
|
||||
return None
|
||||
if actor_json['movedTo'] == actor_json['id']:
|
||||
return None
|
||||
pub_number, _ = get_status_number()
|
||||
return {
|
||||
"@context": "https://www.w3.org/ns/activitystreams",
|
||||
"id": actor_json['id'] + '#moved/' + pub_number,
|
||||
"type": "Move",
|
||||
"actor": actor_json['id'],
|
||||
"object": actor_json['id'],
|
||||
"target": actor_json['movedTo'],
|
||||
"to": ['https://www.w3.org/ns/activitystreams#Public'],
|
||||
"cc": [actor_json['id'] + '/followers']
|
||||
}
|
||||
|
||||
|
||||
def get_default_person_context() -> str:
|
||||
"""Gets the default actor context
|
||||
"""
|
||||
|
|
2
utils.py
2
utils.py
|
@ -925,6 +925,8 @@ def remove_id_ending(id_str: str) -> str:
|
|||
id_str = id_str.split('#delete')[0]
|
||||
elif '#update' in id_str:
|
||||
id_str = id_str.split('#update')[0]
|
||||
elif '#moved' in id_str:
|
||||
id_str = id_str.split('#moved')[0]
|
||||
elif '#primary' in id_str:
|
||||
id_str = id_str.split('#primary')[0]
|
||||
elif '#reciprocal' in id_str:
|
||||
|
|
Loading…
Reference in New Issue