Accept Move() activities coming from "target" actor

This commit is contained in:
silverpill 2022-11-27 18:32:13 +00:00
parent 73ef78f021
commit df8c206cf0

View file

@ -30,20 +30,23 @@ pub async fn handle_move_person(
activity: Activity,
) -> HandlerResult {
let object_id = find_object_id(&activity.object)?;
if object_id != activity.actor {
return Err(ValidationError("actor ID mismatch").into());
};
let target_value = activity.target
.ok_or(ValidationError("target is missing"))?;
let target_id = find_object_id(&target_value)?;
// Actor is old profile (Mastodon)
// Actor is new profile (Mitra)
if object_id != activity.actor && target_id != activity.actor {
return Err(ValidationError("actor ID mismatch").into());
};
let instance = config.instance();
let media_dir = config.media_dir();
let old_profile = get_or_import_profile_by_actor_id(
db_client,
&instance,
&media_dir,
&activity.actor,
&object_id,
).await?;
let old_actor = old_profile.actor_json.unwrap();
let new_profile = get_or_import_profile_by_actor_id(