Don't return error after receiving Add() or Remove() with "featured" collection as target
This commit is contained in:
parent
980d65fa5e
commit
272ee9997b
2 changed files with 8 additions and 6 deletions
|
@ -24,12 +24,13 @@ pub async fn handle_add(
|
||||||
&activity.actor,
|
&activity.actor,
|
||||||
).await?;
|
).await?;
|
||||||
let actor = actor_profile.actor_json.ok_or(ImportError::LocalObject)?;
|
let actor = actor_profile.actor_json.ok_or(ImportError::LocalObject)?;
|
||||||
let object_id = find_object_id(&activity.object)?;
|
|
||||||
let username = parse_local_actor_id(&config.instance_url(), &object_id)?;
|
|
||||||
let user = get_user_by_name(db_client, &username).await?;
|
|
||||||
let target_value = activity.target.ok_or(ValidationError("target is missing"))?;
|
let target_value = activity.target.ok_or(ValidationError("target is missing"))?;
|
||||||
let target_id = find_object_id(&target_value)?;
|
let target_id = find_object_id(&target_value)?;
|
||||||
if Some(target_id) == actor.subscribers {
|
if Some(target_id) == actor.subscribers {
|
||||||
|
// Adding to subscribers
|
||||||
|
let object_id = find_object_id(&activity.object)?;
|
||||||
|
let username = parse_local_actor_id(&config.instance_url(), &object_id)?;
|
||||||
|
let user = get_user_by_name(db_client, &username).await?;
|
||||||
subscribe_opt(db_client, &user.id, &actor_profile.id).await?;
|
subscribe_opt(db_client, &user.id, &actor_profile.id).await?;
|
||||||
return Ok(Some(PERSON));
|
return Ok(Some(PERSON));
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,12 +27,13 @@ pub async fn handle_remove(
|
||||||
&activity.actor,
|
&activity.actor,
|
||||||
).await?;
|
).await?;
|
||||||
let actor = actor_profile.actor_json.ok_or(ImportError::LocalObject)?;
|
let actor = actor_profile.actor_json.ok_or(ImportError::LocalObject)?;
|
||||||
let object_id = find_object_id(&activity.object)?;
|
|
||||||
let username = parse_local_actor_id(&config.instance_url(), &object_id)?;
|
|
||||||
let user = get_user_by_name(db_client, &username).await?;
|
|
||||||
let target_value = activity.target.ok_or(ValidationError("target is missing"))?;
|
let target_value = activity.target.ok_or(ValidationError("target is missing"))?;
|
||||||
let target_id = find_object_id(&target_value)?;
|
let target_id = find_object_id(&target_value)?;
|
||||||
if Some(target_id) == actor.subscribers {
|
if Some(target_id) == actor.subscribers {
|
||||||
|
// Removing from subscribers
|
||||||
|
let object_id = find_object_id(&activity.object)?;
|
||||||
|
let username = parse_local_actor_id(&config.instance_url(), &object_id)?;
|
||||||
|
let user = get_user_by_name(db_client, &username).await?;
|
||||||
// actor is recipient, user is sender
|
// actor is recipient, user is sender
|
||||||
match unsubscribe(db_client, &user.id, &actor_profile.id).await {
|
match unsubscribe(db_client, &user.id, &actor_profile.id).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
|
Loading…
Reference in a new issue