Disable ID domain check in FromApub until we figure it out properly
This commit is contained in:
parent
a85873d294
commit
8ad4378960
15 changed files with 42 additions and 71 deletions
|
@ -131,7 +131,6 @@ impl FromApub for CommentForm {
|
||||||
note: &Note,
|
note: &Note,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<CommentForm, LemmyError> {
|
) -> Result<CommentForm, LemmyError> {
|
||||||
let creator_actor_id = ¬e
|
let creator_actor_id = ¬e
|
||||||
.attributed_to()
|
.attributed_to()
|
||||||
|
@ -182,7 +181,7 @@ impl FromApub for CommentForm {
|
||||||
published: note.published().map(|u| u.to_owned().naive_local()),
|
published: note.published().map(|u| u.to_owned().naive_local()),
|
||||||
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
ap_id: note.id(actor_id.domain().unwrap())?.unwrap().to_string(),
|
ap_id: note.id_unchecked().unwrap().to_string(),
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,12 +321,7 @@ impl FromApub for CommunityForm {
|
||||||
type ApubType = GroupExt;
|
type ApubType = GroupExt;
|
||||||
|
|
||||||
/// Parse an ActivityPub group received from another instance into a Lemmy community.
|
/// Parse an ActivityPub group received from another instance into a Lemmy community.
|
||||||
async fn from_apub(
|
async fn from_apub(group: &GroupExt, client: &Client, pool: &DbPool) -> Result<Self, LemmyError> {
|
||||||
group: &GroupExt,
|
|
||||||
client: &Client,
|
|
||||||
pool: &DbPool,
|
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<Self, LemmyError> {
|
|
||||||
let creator_and_moderator_uris = group.inner.attributed_to().unwrap();
|
let creator_and_moderator_uris = group.inner.attributed_to().unwrap();
|
||||||
let creator_uri = creator_and_moderator_uris
|
let creator_uri = creator_and_moderator_uris
|
||||||
.as_many()
|
.as_many()
|
||||||
|
@ -363,11 +358,7 @@ impl FromApub for CommunityForm {
|
||||||
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: group.ext_one.sensitive,
|
nsfw: group.ext_one.sensitive,
|
||||||
actor_id: group
|
actor_id: group.inner.id_unchecked().unwrap().to_string(),
|
||||||
.inner
|
|
||||||
.id(actor_id.domain().unwrap())?
|
|
||||||
.unwrap()
|
|
||||||
.to_string(),
|
|
||||||
local: false,
|
local: false,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
|
public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
|
||||||
|
|
|
@ -172,7 +172,7 @@ pub async fn search_by_apub_id(
|
||||||
response
|
response
|
||||||
}
|
}
|
||||||
SearchAcceptedObjects::Page(p) => {
|
SearchAcceptedObjects::Page(p) => {
|
||||||
let post_form = PostForm::from_apub(&p, client, pool, &query_url).await?;
|
let post_form = PostForm::from_apub(&p, client, pool).await?;
|
||||||
|
|
||||||
let p = blocking(pool, move |conn| upsert_post(&post_form, conn)).await??;
|
let p = blocking(pool, move |conn| upsert_post(&post_form, conn)).await??;
|
||||||
response.posts = vec![blocking(pool, move |conn| PostView::read(conn, p.id, None)).await??];
|
response.posts = vec![blocking(pool, move |conn| PostView::read(conn, p.id, None)).await??];
|
||||||
|
@ -185,8 +185,8 @@ pub async fn search_by_apub_id(
|
||||||
// TODO: also fetch parent comments if any
|
// TODO: also fetch parent comments if any
|
||||||
let x = post_url.first().unwrap().as_xsd_any_uri().unwrap();
|
let x = post_url.first().unwrap().as_xsd_any_uri().unwrap();
|
||||||
let post = fetch_remote_object(client, x).await?;
|
let post = fetch_remote_object(client, x).await?;
|
||||||
let post_form = PostForm::from_apub(&post, client, pool, &query_url).await?;
|
let post_form = PostForm::from_apub(&post, client, pool).await?;
|
||||||
let comment_form = CommentForm::from_apub(&c, client, pool, &query_url).await?;
|
let comment_form = CommentForm::from_apub(&c, client, pool).await?;
|
||||||
|
|
||||||
blocking(pool, move |conn| upsert_post(&post_form, conn)).await??;
|
blocking(pool, move |conn| upsert_post(&post_form, conn)).await??;
|
||||||
let c = blocking(pool, move |conn| upsert_comment(&comment_form, conn)).await??;
|
let c = blocking(pool, move |conn| upsert_comment(&comment_form, conn)).await??;
|
||||||
|
@ -231,7 +231,7 @@ pub async fn get_or_fetch_and_upsert_user(
|
||||||
debug!("Fetching and updating from remote user: {}", apub_id);
|
debug!("Fetching and updating from remote user: {}", apub_id);
|
||||||
let person = fetch_remote_object::<PersonExt>(client, apub_id).await?;
|
let person = fetch_remote_object::<PersonExt>(client, apub_id).await?;
|
||||||
|
|
||||||
let mut uf = UserForm::from_apub(&person, client, pool, apub_id).await?;
|
let mut uf = UserForm::from_apub(&person, client, pool).await?;
|
||||||
uf.last_refreshed_at = Some(naive_now());
|
uf.last_refreshed_at = Some(naive_now());
|
||||||
let user = blocking(pool, move |conn| User_::update(conn, u.id, &uf)).await??;
|
let user = blocking(pool, move |conn| User_::update(conn, u.id, &uf)).await??;
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ pub async fn get_or_fetch_and_upsert_user(
|
||||||
debug!("Fetching and creating remote user: {}", apub_id);
|
debug!("Fetching and creating remote user: {}", apub_id);
|
||||||
let person = fetch_remote_object::<PersonExt>(client, apub_id).await?;
|
let person = fetch_remote_object::<PersonExt>(client, apub_id).await?;
|
||||||
|
|
||||||
let uf = UserForm::from_apub(&person, client, pool, apub_id).await?;
|
let uf = UserForm::from_apub(&person, client, pool).await?;
|
||||||
let user = blocking(pool, move |conn| User_::create(conn, &uf)).await??;
|
let user = blocking(pool, move |conn| User_::create(conn, &uf)).await??;
|
||||||
|
|
||||||
Ok(user)
|
Ok(user)
|
||||||
|
@ -282,7 +282,7 @@ pub async fn get_or_fetch_and_upsert_community(
|
||||||
debug!("Fetching and updating from remote community: {}", apub_id);
|
debug!("Fetching and updating from remote community: {}", apub_id);
|
||||||
let group = fetch_remote_object::<GroupExt>(client, apub_id).await?;
|
let group = fetch_remote_object::<GroupExt>(client, apub_id).await?;
|
||||||
|
|
||||||
let mut cf = CommunityForm::from_apub(&group, client, pool, apub_id).await?;
|
let mut cf = CommunityForm::from_apub(&group, client, pool).await?;
|
||||||
cf.last_refreshed_at = Some(naive_now());
|
cf.last_refreshed_at = Some(naive_now());
|
||||||
let community = blocking(pool, move |conn| Community::update(conn, c.id, &cf)).await??;
|
let community = blocking(pool, move |conn| Community::update(conn, c.id, &cf)).await??;
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ pub async fn get_or_fetch_and_upsert_community(
|
||||||
debug!("Fetching and creating remote community: {}", apub_id);
|
debug!("Fetching and creating remote community: {}", apub_id);
|
||||||
let group = fetch_remote_object::<GroupExt>(client, apub_id).await?;
|
let group = fetch_remote_object::<GroupExt>(client, apub_id).await?;
|
||||||
|
|
||||||
let cf = CommunityForm::from_apub(&group, client, pool, apub_id).await?;
|
let cf = CommunityForm::from_apub(&group, client, pool).await?;
|
||||||
let community = blocking(pool, move |conn| Community::create(conn, &cf)).await??;
|
let community = blocking(pool, move |conn| Community::create(conn, &cf)).await??;
|
||||||
|
|
||||||
// Also add the community moderators too
|
// Also add the community moderators too
|
||||||
|
@ -358,7 +358,7 @@ pub async fn get_or_fetch_and_insert_post(
|
||||||
Err(NotFound {}) => {
|
Err(NotFound {}) => {
|
||||||
debug!("Fetching and creating remote post: {}", post_ap_id);
|
debug!("Fetching and creating remote post: {}", post_ap_id);
|
||||||
let post = fetch_remote_object::<PageExt>(client, post_ap_id).await?;
|
let post = fetch_remote_object::<PageExt>(client, post_ap_id).await?;
|
||||||
let post_form = PostForm::from_apub(&post, client, pool, post_ap_id).await?;
|
let post_form = PostForm::from_apub(&post, client, pool).await?;
|
||||||
|
|
||||||
let post = blocking(pool, move |conn| Post::create(conn, &post_form)).await??;
|
let post = blocking(pool, move |conn| Post::create(conn, &post_form)).await??;
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ pub async fn get_or_fetch_and_insert_comment(
|
||||||
comment_ap_id
|
comment_ap_id
|
||||||
);
|
);
|
||||||
let comment = fetch_remote_object::<Note>(client, comment_ap_id).await?;
|
let comment = fetch_remote_object::<Note>(client, comment_ap_id).await?;
|
||||||
let comment_form = CommentForm::from_apub(&comment, client, pool, comment_ap_id).await?;
|
let comment_form = CommentForm::from_apub(&comment, client, pool).await?;
|
||||||
|
|
||||||
let comment = blocking(pool, move |conn| Comment::create(conn, &comment_form)).await??;
|
let comment = blocking(pool, move |conn| Comment::create(conn, &comment_form)).await??;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
|
@ -57,7 +56,7 @@ async fn receive_create_post(
|
||||||
let user = get_user_from_activity(&create, client, pool).await?;
|
let user = get_user_from_activity(&create, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(create.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(create.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
|
let post = PostForm::from_apub(&page, client, pool).await?;
|
||||||
|
|
||||||
let inserted_post = blocking(pool, move |conn| Post::create(conn, &post)).await??;
|
let inserted_post = blocking(pool, move |conn| Post::create(conn, &post)).await??;
|
||||||
|
|
||||||
|
@ -89,7 +88,7 @@ async fn receive_create_comment(
|
||||||
let user = get_user_from_activity(&create, client, pool).await?;
|
let user = get_user_from_activity(&create, client, pool).await?;
|
||||||
let note = Note::from_any_base(create.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(create.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
|
let comment = CommentForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let inserted_comment = blocking(pool, move |conn| Comment::create(conn, &comment)).await??;
|
let inserted_comment = blocking(pool, move |conn| Comment::create(conn, &comment)).await??;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
|
@ -58,7 +57,7 @@ async fn receive_delete_post(
|
||||||
let user = get_user_from_activity(&delete, client, pool).await?;
|
let user = get_user_from_activity(&delete, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, client, pool, &user.actor_id()?)
|
let post_ap_id = PostForm::from_apub(&page, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ async fn receive_delete_comment(
|
||||||
let user = get_user_from_activity(&delete, client, pool).await?;
|
let user = get_user_from_activity(&delete, client, pool).await?;
|
||||||
let note = Note::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?)
|
let comment_ap_id = CommentForm::from_apub(¬e, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ async fn receive_delete_community(
|
||||||
let group = GroupExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let group = GroupExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
let user = get_user_from_activity(&delete, client, pool).await?;
|
let user = get_user_from_activity(&delete, client, pool).await?;
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, client, pool, &user.actor_id()?)
|
let community_actor_id = CommunityForm::from_apub(&group, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
|
@ -53,7 +52,7 @@ async fn receive_dislike_post(
|
||||||
let user = get_user_from_activity(&dislike, client, pool).await?;
|
let user = get_user_from_activity(&dislike, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(dislike.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(dislike.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
|
let post = PostForm::from_apub(&page, client, pool).await?;
|
||||||
|
|
||||||
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -94,7 +93,7 @@ async fn receive_dislike_comment(
|
||||||
let note = Note::from_any_base(dislike.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(dislike.object().to_owned().one().unwrap())?.unwrap();
|
||||||
let user = get_user_from_activity(&dislike, client, pool).await?;
|
let user = get_user_from_activity(&dislike, client, pool).await?;
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
|
let comment = CommentForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
|
@ -53,7 +52,7 @@ async fn receive_like_post(
|
||||||
let user = get_user_from_activity(&like, client, pool).await?;
|
let user = get_user_from_activity(&like, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
|
let post = PostForm::from_apub(&page, client, pool).await?;
|
||||||
|
|
||||||
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -94,7 +93,7 @@ async fn receive_like_comment(
|
||||||
let note = Note::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
||||||
let user = get_user_from_activity(&like, client, pool).await?;
|
let user = get_user_from_activity(&like, client, pool).await?;
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
|
let comment = CommentForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
|
@ -58,7 +57,7 @@ async fn receive_remove_post(
|
||||||
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, client, pool, &mod_.actor_id()?)
|
let post_ap_id = PostForm::from_apub(&page, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ async fn receive_remove_comment(
|
||||||
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
||||||
let note = Note::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, client, pool, &mod_.actor_id()?)
|
let comment_ap_id = CommentForm::from_apub(¬e, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -169,7 +168,7 @@ async fn receive_remove_community(
|
||||||
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
let mod_ = get_user_from_activity(&remove, client, pool).await?;
|
||||||
let group = GroupExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let group = GroupExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, client, pool, &mod_.actor_id()?)
|
let community_actor_id = CommunityForm::from_apub(&group, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
GroupExt,
|
GroupExt,
|
||||||
PageExt,
|
PageExt,
|
||||||
|
@ -123,7 +122,7 @@ async fn receive_undo_delete_comment(
|
||||||
let user = get_user_from_activity(delete, client, pool).await?;
|
let user = get_user_from_activity(delete, client, pool).await?;
|
||||||
let note = Note::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?)
|
let comment_ap_id = CommentForm::from_apub(¬e, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -181,7 +180,7 @@ async fn receive_undo_remove_comment(
|
||||||
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
||||||
let note = Note::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, client, pool, &mod_.actor_id()?)
|
let comment_ap_id = CommentForm::from_apub(¬e, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -239,7 +238,7 @@ async fn receive_undo_delete_post(
|
||||||
let user = get_user_from_activity(delete, client, pool).await?;
|
let user = get_user_from_activity(delete, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, client, pool, &user.actor_id()?)
|
let post_ap_id = PostForm::from_apub(&page, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -294,7 +293,7 @@ async fn receive_undo_remove_post(
|
||||||
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, client, pool, &mod_.actor_id()?)
|
let post_ap_id = PostForm::from_apub(&page, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.get_ap_id()?;
|
.get_ap_id()?;
|
||||||
|
|
||||||
|
@ -349,7 +348,7 @@ async fn receive_undo_delete_community(
|
||||||
let user = get_user_from_activity(delete, client, pool).await?;
|
let user = get_user_from_activity(delete, client, pool).await?;
|
||||||
let group = GroupExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
let group = GroupExt::from_any_base(delete.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, client, pool, &user.actor_id()?)
|
let community_actor_id = CommunityForm::from_apub(&group, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id;
|
||||||
|
|
||||||
|
@ -413,7 +412,7 @@ async fn receive_undo_remove_community(
|
||||||
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
let mod_ = get_user_from_activity(remove, client, pool).await?;
|
||||||
let group = GroupExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
let group = GroupExt::from_any_base(remove.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, client, pool, &mod_.actor_id()?)
|
let community_actor_id = CommunityForm::from_apub(&group, client, pool)
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id;
|
||||||
|
|
||||||
|
@ -477,7 +476,7 @@ async fn receive_undo_like_comment(
|
||||||
let user = get_user_from_activity(like, client, pool).await?;
|
let user = get_user_from_activity(like, client, pool).await?;
|
||||||
let note = Note::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
|
let comment = CommentForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -523,7 +522,7 @@ async fn receive_undo_like_post(
|
||||||
let user = get_user_from_activity(like, client, pool).await?;
|
let user = get_user_from_activity(like, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(like.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
|
let post = PostForm::from_apub(&page, client, pool).await?;
|
||||||
|
|
||||||
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -10,7 +10,6 @@ use crate::{
|
||||||
get_user_from_activity,
|
get_user_from_activity,
|
||||||
receive_unhandled_activity,
|
receive_unhandled_activity,
|
||||||
},
|
},
|
||||||
ActorType,
|
|
||||||
FromApub,
|
FromApub,
|
||||||
PageExt,
|
PageExt,
|
||||||
},
|
},
|
||||||
|
@ -57,7 +56,7 @@ async fn receive_update_post(
|
||||||
let user = get_user_from_activity(&update, client, pool).await?;
|
let user = get_user_from_activity(&update, client, pool).await?;
|
||||||
let page = PageExt::from_any_base(update.object().to_owned().one().unwrap())?.unwrap();
|
let page = PageExt::from_any_base(update.object().to_owned().one().unwrap())?.unwrap();
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
|
let post = PostForm::from_apub(&page, client, pool).await?;
|
||||||
|
|
||||||
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
@ -89,7 +88,7 @@ async fn receive_update_comment(
|
||||||
let note = Note::from_any_base(update.object().to_owned().one().unwrap())?.unwrap();
|
let note = Note::from_any_base(update.object().to_owned().one().unwrap())?.unwrap();
|
||||||
let user = get_user_from_activity(&update, client, pool).await?;
|
let user = get_user_from_activity(&update, client, pool).await?;
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
|
let comment = CommentForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -121,7 +121,7 @@ async fn receive_create_private_message(
|
||||||
|
|
||||||
insert_activity(user.id, create, false, pool).await?;
|
insert_activity(user.id, create, false, pool).await?;
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, client, pool, user_uri).await?;
|
let private_message = PrivateMessageForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let inserted_private_message = blocking(pool, move |conn| {
|
let inserted_private_message = blocking(pool, move |conn| {
|
||||||
PrivateMessage::create(conn, &private_message)
|
PrivateMessage::create(conn, &private_message)
|
||||||
|
@ -162,7 +162,7 @@ async fn receive_update_private_message(
|
||||||
|
|
||||||
insert_activity(user.id, update, false, pool).await?;
|
insert_activity(user.id, update, false, pool).await?;
|
||||||
|
|
||||||
let private_message_form = PrivateMessageForm::from_apub(¬e, client, pool, user_uri).await?;
|
let private_message_form = PrivateMessageForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message_form.ap_id.clone();
|
let private_message_ap_id = private_message_form.ap_id.clone();
|
||||||
let private_message = blocking(pool, move |conn| {
|
let private_message = blocking(pool, move |conn| {
|
||||||
|
@ -211,7 +211,7 @@ async fn receive_delete_private_message(
|
||||||
|
|
||||||
insert_activity(user.id, delete, false, pool).await?;
|
insert_activity(user.id, delete, false, pool).await?;
|
||||||
|
|
||||||
let private_message_form = PrivateMessageForm::from_apub(¬e, client, pool, user_uri).await?;
|
let private_message_form = PrivateMessageForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message_form.ap_id;
|
let private_message_ap_id = private_message_form.ap_id;
|
||||||
let private_message = blocking(pool, move |conn| {
|
let private_message = blocking(pool, move |conn| {
|
||||||
|
@ -273,7 +273,7 @@ async fn receive_undo_delete_private_message(
|
||||||
|
|
||||||
insert_activity(user.id, delete, false, pool).await?;
|
insert_activity(user.id, delete, false, pool).await?;
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, client, pool, user_uri).await?;
|
let private_message = PrivateMessageForm::from_apub(¬e, client, pool).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message.ap_id.clone();
|
let private_message_ap_id = private_message.ap_id.clone();
|
||||||
let private_message_id = blocking(pool, move |conn| {
|
let private_message_id = blocking(pool, move |conn| {
|
||||||
|
|
|
@ -132,7 +132,6 @@ pub trait FromApub {
|
||||||
apub: &Self::ApubType,
|
apub: &Self::ApubType,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<Self, LemmyError>
|
) -> Result<Self, LemmyError>
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
|
|
|
@ -154,7 +154,6 @@ impl FromApub for PostForm {
|
||||||
page: &PageExt,
|
page: &PageExt,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<PostForm, LemmyError> {
|
) -> Result<PostForm, LemmyError> {
|
||||||
let ext = &page.ext_one;
|
let ext = &page.ext_one;
|
||||||
let creator_actor_id = page
|
let creator_actor_id = page
|
||||||
|
@ -246,11 +245,7 @@ impl FromApub for PostForm {
|
||||||
embed_description,
|
embed_description,
|
||||||
embed_html,
|
embed_html,
|
||||||
thumbnail_url,
|
thumbnail_url,
|
||||||
ap_id: page
|
ap_id: page.inner.id_unchecked().unwrap().to_string(),
|
||||||
.inner
|
|
||||||
.id(actor_id.domain().unwrap())?
|
|
||||||
.unwrap()
|
|
||||||
.to_string(),
|
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ impl FromApub for PrivateMessageForm {
|
||||||
note: &Note,
|
note: &Note,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
pool: &DbPool,
|
pool: &DbPool,
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<PrivateMessageForm, LemmyError> {
|
) -> Result<PrivateMessageForm, LemmyError> {
|
||||||
let creator_actor_id = note
|
let creator_actor_id = note
|
||||||
.attributed_to()
|
.attributed_to()
|
||||||
|
@ -103,7 +102,7 @@ impl FromApub for PrivateMessageForm {
|
||||||
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
read: None,
|
read: None,
|
||||||
ap_id: note.id(actor_id.domain().unwrap())?.unwrap().to_string(),
|
ap_id: note.id_unchecked().unwrap().to_string(),
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,12 +201,7 @@ impl ActorType for User_ {
|
||||||
impl FromApub for UserForm {
|
impl FromApub for UserForm {
|
||||||
type ApubType = PersonExt;
|
type ApubType = PersonExt;
|
||||||
/// Parse an ActivityPub person received from another instance into a Lemmy user.
|
/// Parse an ActivityPub person received from another instance into a Lemmy user.
|
||||||
async fn from_apub(
|
async fn from_apub(person: &PersonExt, _: &Client, _: &DbPool) -> Result<Self, LemmyError> {
|
||||||
person: &PersonExt,
|
|
||||||
_: &Client,
|
|
||||||
_: &DbPool,
|
|
||||||
actor_id: &Url,
|
|
||||||
) -> Result<Self, LemmyError> {
|
|
||||||
let avatar = match person.icon() {
|
let avatar = match person.icon() {
|
||||||
Some(any_image) => Image::from_any_base(any_image.as_one().unwrap().clone())
|
Some(any_image) => Image::from_any_base(any_image.as_one().unwrap().clone())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -242,7 +237,7 @@ impl FromApub for UserForm {
|
||||||
show_avatars: false,
|
show_avatars: false,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
matrix_user_id: None,
|
matrix_user_id: None,
|
||||||
actor_id: person.id(actor_id.domain().unwrap())?.unwrap().to_string(),
|
actor_id: person.id_unchecked().unwrap().to_string(),
|
||||||
bio: person
|
bio: person
|
||||||
.inner
|
.inner
|
||||||
.summary()
|
.summary()
|
||||||
|
|
Loading…
Reference in a new issue