Refactor Create(Note) activity processor
This commit is contained in:
parent
9f114f4255
commit
8d66bcb034
1 changed files with 36 additions and 32 deletions
|
@ -95,6 +95,9 @@ pub async fn receive_activity(
|
|||
(CREATE, NOTE) => {
|
||||
let object: Object = serde_json::from_value(activity.object)
|
||||
.map_err(|_| ValidationError("invalid object"))?;
|
||||
// TOOD: fetch the whole thread
|
||||
let objects = vec![object];
|
||||
for object in objects {
|
||||
let attributed_to = object.attributed_to
|
||||
.ok_or(ValidationError("unattributed note"))?;
|
||||
let author = get_profile_by_actor_id(db_client, &attributed_to).await?;
|
||||
|
@ -129,6 +132,7 @@ pub async fn receive_activity(
|
|||
created_at: object.published,
|
||||
};
|
||||
create_post(db_client, &author.id, post_data).await?;
|
||||
}
|
||||
},
|
||||
(FOLLOW, _) => {
|
||||
let source_profile = get_profile_by_actor_id(db_client, &activity.actor).await?;
|
||||
|
|
Loading…
Reference in a new issue