use crate::{
apub::{
- community::do_announce, extensions::signatures::sign, insert_activity, is_apub_id_valid,
+ community::do_announce,
+ extensions::signatures::sign,
+ insert_activity,
+ is_apub_id_valid,
ActorType,
},
request::retry_custom,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::base::AnyBase;
use actix_web::client::Client;
use crate::{
apub::{
activities::{generate_activity_id, send_activity_to_community},
- create_apub_response, create_apub_tombstone_response, create_tombstone, fetch_webfinger_url,
+ create_apub_response,
+ create_apub_tombstone_response,
+ create_tombstone,
+ fetch_webfinger_url,
fetcher::{
- get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post,
- get_or_fetch_and_upsert_remote_user,
+ get_or_fetch_and_insert_comment,
+ get_or_fetch_and_insert_post,
+ get_or_fetch_and_upsert_user,
},
- ActorType, ApubLikeableType, ApubObjectType, FromApub, ToApub,
+ ActorType,
+ ApubLikeableType,
+ ApubObjectType,
+ FromApub,
+ ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{
activity::{
kind::{CreateType, DeleteType, DislikeType, LikeType, RemoveType, UndoType, UpdateType},
- Create, Delete, Dislike, Like, Remove, Undo, Update,
+ Create,
+ Delete,
+ Dislike,
+ Like,
+ Remove,
+ Undo,
+ Update,
},
base::AnyBase,
context,
.as_single_xsd_any_uri()
.unwrap();
- let creator = get_or_fetch_and_upsert_remote_user(creator_actor_id, client, pool).await?;
+ let creator = get_or_fetch_and_upsert_user(creator_actor_id, client, pool).await?;
let mut in_reply_tos = note
.in_reply_to()
let post_ap_id = in_reply_tos.next().unwrap();
// This post, or the parent comment might not yet exist on this server yet, fetch them.
- let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
+ let post = get_or_fetch_and_insert_post(&post_ap_id, client, pool).await?;
// The 2nd item, if it exists, is the parent comment apub_id
// For deeply nested comments, FromApub automatically gets called recursively
Some(parent_comment_uri) => {
let parent_comment_ap_id = &parent_comment_uri;
let parent_comment =
- get_or_fetch_and_insert_remote_comment(&parent_comment_ap_id, client, pool).await?;
+ get_or_fetch_and_insert_comment(&parent_comment_ap_id, client, pool).await?;
Some(parent_comment.id)
}
debug!("mention actor_id: {}", actor_id);
addressed_ccs.push(actor_id.to_owned().to_string());
- let mention_user = get_or_fetch_and_upsert_remote_user(&actor_id, client, pool).await?;
+ let mention_user = get_or_fetch_and_upsert_user(&actor_id, client, pool).await?;
let shared_inbox = mention_user.get_shared_inbox_url();
mention_inboxes.push(shared_inbox);
use crate::{
apub::{
activities::{generate_activity_id, send_activity},
- create_apub_response, create_apub_tombstone_response, create_tombstone,
+ create_apub_response,
+ create_apub_tombstone_response,
+ create_tombstone,
extensions::group_extensions::GroupExtension,
- fetcher::get_or_fetch_and_upsert_remote_user,
- get_shared_inbox, insert_activity, ActorType, FromApub, GroupExt, ToApub,
+ fetcher::get_or_fetch_and_upsert_user,
+ get_shared_inbox,
+ insert_activity,
+ ActorType,
+ FromApub,
+ GroupExt,
+ ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_ext::Ext2;
use activitystreams_new::{
activity::{
kind::{AcceptType, AnnounceType, DeleteType, LikeType, RemoveType, UndoType},
- Accept, Announce, Delete, Follow, Remove, Undo,
+ Accept,
+ Announce,
+ Delete,
+ Follow,
+ Remove,
+ Undo,
},
actor::{kind::GroupType, ApActor, Endpoints, Group},
base::{AnyBase, BaseExt},
.as_xsd_any_uri()
.unwrap();
- let creator = get_or_fetch_and_upsert_remote_user(creator_uri, client, pool).await?;
+ let creator = get_or_fetch_and_upsert_user(creator_uri, client, pool).await?;
Ok(CommunityForm {
name: group
use crate::{
api::site::SearchResponse,
apub::{
- is_apub_id_valid, ActorType, FromApub, GroupExt, PageExt, PersonExt, APUB_JSON_CONTENT_TYPE,
+ is_apub_id_valid,
+ ActorType,
+ FromApub,
+ GroupExt,
+ PageExt,
+ PersonExt,
+ APUB_JSON_CONTENT_TYPE,
},
blocking,
request::{retry, RecvError},
routes::nodeinfo::{NodeInfo, NodeInfoWellKnown},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{base::BaseExt, object::Note, prelude::*};
use actix_web::client::Client;
post_view::PostView,
user::{UserForm, User_},
user_view::UserView,
- Crud, Joinable, SearchType,
+ Crud,
+ Joinable,
+ SearchType,
};
use lemmy_utils::get_apub_protocol_string;
use log::debug;
SearchAcceptedObjects::Person(p) => {
let user_uri = p.inner.id(domain)?.unwrap();
- let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
+ let user = get_or_fetch_and_upsert_user(&user_uri, client, pool).await?;
response.users = vec![blocking(pool, move |conn| UserView::read(conn, user.id)).await??];
SearchAcceptedObjects::Group(g) => {
let community_uri = g.inner.id(domain)?.unwrap();
- let community = get_or_fetch_and_upsert_remote_community(community_uri, client, pool).await?;
+ let community = get_or_fetch_and_upsert_community(community_uri, client, pool).await?;
// TODO Maybe at some point in the future, fetch all the history of a community
// fetch_community_outbox(&c, conn)?;
Ok(response)
}
-pub async fn get_or_fetch_and_upsert_remote_actor(
+pub async fn get_or_fetch_and_upsert_actor(
apub_id: &Url,
client: &Client,
pool: &DbPool,
) -> Result<Box<dyn ActorType>, LemmyError> {
- let user = get_or_fetch_and_upsert_remote_user(apub_id, client, pool).await;
+ let user = get_or_fetch_and_upsert_user(apub_id, client, pool).await;
let actor: Box<dyn ActorType> = match user {
Ok(u) => Box::new(u),
- Err(_) => Box::new(get_or_fetch_and_upsert_remote_community(apub_id, client, pool).await?),
+ Err(_) => Box::new(get_or_fetch_and_upsert_community(apub_id, client, pool).await?),
};
Ok(actor)
}
/// Check if a remote user exists, create if not found, if its too old update it.Fetch a user, insert/update it in the database and return the user.
-pub async fn get_or_fetch_and_upsert_remote_user(
+pub async fn get_or_fetch_and_upsert_user(
apub_id: &Url,
client: &Client,
pool: &DbPool,
}
/// Check if a remote community exists, create if not found, if its too old update it.Fetch a community, insert/update it in the database and return the community.
-pub async fn get_or_fetch_and_upsert_remote_community(
+pub async fn get_or_fetch_and_upsert_community(
apub_id: &Url,
client: &Client,
pool: &DbPool,
let mut creator_and_moderators = Vec::new();
for uri in creator_and_moderator_uris {
- let c_or_m = get_or_fetch_and_upsert_remote_user(uri, client, pool).await?;
+ let c_or_m = get_or_fetch_and_upsert_user(uri, client, pool).await?;
creator_and_moderators.push(c_or_m);
}
}
}
-pub async fn get_or_fetch_and_insert_remote_post(
+pub async fn get_or_fetch_and_insert_post(
post_ap_id: &Url,
client: &Client,
pool: &DbPool,
}
}
-pub async fn get_or_fetch_and_insert_remote_comment(
+pub async fn get_or_fetch_and_insert_comment(
comment_ap_id: &Url,
client: &Client,
pool: &DbPool,
use crate::{
apub::inbox::{
activities::{
- create::receive_create, delete::receive_delete, dislike::receive_dislike, like::receive_like,
- remove::receive_remove, undo::receive_undo, update::receive_update,
+ create::receive_create,
+ delete::receive_delete,
+ dislike::receive_dislike,
+ like::receive_like,
+ remove::receive_remove,
+ undo::receive_undo,
+ update::receive_update,
},
shared_inbox::receive_unhandled_activity,
},
routes::ChatServerParam,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::*, base::AnyBase, prelude::ExtendsExt};
use actix_web::{client::Client, HttpResponse};
},
apub::{
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, PageExt,
+ ActorType,
+ FromApub,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Create, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
use crate::{
api::{comment::CommentResponse, community::CommunityResponse, post::PostResponse},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, GroupExt, PageExt,
+ ActorType,
+ FromApub,
+ GroupExt,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Delete, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
.await?
.get_ap_id()?;
- let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
+ let post = get_or_fetch_and_insert_post(&post_ap_id, client, pool).await?;
let post_form = PostForm {
name: post.name.to_owned(),
.await?
.get_ap_id()?;
- let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
+ let comment = get_or_fetch_and_insert_comment(&comment_ap_id, client, pool).await?;
let comment_form = CommentForm {
content: comment.content.to_owned(),
use crate::{
api::{comment::CommentResponse, post::PostResponse},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, PageExt,
+ ActorType,
+ FromApub,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Dislike, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
- let post_id = get_or_fetch_and_insert_remote_post(&post.get_ap_id()?, client, pool)
+ let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
.await?
.id;
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
- let comment_id = get_or_fetch_and_insert_remote_comment(&comment.get_ap_id()?, client, pool)
+ let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
.await?
.id;
use crate::{
api::{comment::CommentResponse, post::PostResponse},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, PageExt,
+ ActorType,
+ FromApub,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Like, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
- let post_id = get_or_fetch_and_insert_remote_post(&post.get_ap_id()?, client, pool)
+ let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
.await?
.id;
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
- let comment_id = get_or_fetch_and_insert_remote_comment(&comment.get_ap_id()?, client, pool)
+ let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
.await?
.id;
use crate::{
api::{comment::CommentResponse, community::CommunityResponse, post::PostResponse},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, GroupExt, PageExt,
+ ActorType,
+ FromApub,
+ GroupExt,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Remove, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
.await?
.get_ap_id()?;
- let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
+ let post = get_or_fetch_and_insert_post(&post_ap_id, client, pool).await?;
let post_form = PostForm {
name: post.name.to_owned(),
.await?
.get_ap_id()?;
- let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
+ let comment = get_or_fetch_and_insert_comment(&comment_ap_id, client, pool).await?;
let comment_form = CommentForm {
content: comment.content.to_owned(),
use crate::{
api::{comment::CommentResponse, community::CommunityResponse, post::PostResponse},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, GroupExt, PageExt,
+ ActorType,
+ FromApub,
+ GroupExt,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::*, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
naive_now,
post::{Post, PostForm, PostLike, PostLikeForm},
post_view::PostView,
- Crud, Likeable,
+ Crud,
+ Likeable,
};
pub async fn receive_undo(
.await?
.get_ap_id()?;
- let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
+ let comment = get_or_fetch_and_insert_comment(&comment_ap_id, client, pool).await?;
let comment_form = CommentForm {
content: comment.content.to_owned(),
.await?
.get_ap_id()?;
- let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
+ let comment = get_or_fetch_and_insert_comment(&comment_ap_id, client, pool).await?;
let comment_form = CommentForm {
content: comment.content.to_owned(),
.await?
.get_ap_id()?;
- let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
+ let post = get_or_fetch_and_insert_post(&post_ap_id, client, pool).await?;
let post_form = PostForm {
name: post.name.to_owned(),
.await?
.get_ap_id()?;
- let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
+ let post = get_or_fetch_and_insert_post(&post_ap_id, client, pool).await?;
let post_form = PostForm {
name: post.name.to_owned(),
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
- let comment_id = get_or_fetch_and_insert_remote_comment(&comment.get_ap_id()?, client, pool)
+ let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
.await?
.id;
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
- let post_id = get_or_fetch_and_insert_remote_post(&post.get_ap_id()?, client, pool)
+ let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
.await?
.id;
post::PostResponse,
},
apub::{
- fetcher::{get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post},
+ fetcher::{get_or_fetch_and_insert_comment, get_or_fetch_and_insert_post},
inbox::shared_inbox::{
- announce_if_community_is_local, get_user_from_activity, receive_unhandled_activity,
+ announce_if_community_is_local,
+ get_user_from_activity,
+ receive_unhandled_activity,
},
- ActorType, FromApub, PageExt,
+ ActorType,
+ FromApub,
+ PageExt,
},
blocking,
routes::ChatServerParam,
server::{SendComment, SendPost},
UserOperation,
},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{activity::Update, base::AnyBase, object::Note, prelude::*};
use actix_web::{client::Client, HttpResponse};
let post = PostForm::from_apub(&page, client, pool, &user.actor_id()?).await?;
- let post_id = get_or_fetch_and_insert_remote_post(&post.get_ap_id()?, client, pool)
+ let post_id = get_or_fetch_and_insert_post(&post.get_ap_id()?, client, pool)
.await?
.id;
let comment = CommentForm::from_apub(¬e, client, pool, &user.actor_id()?).await?;
- let comment_id = get_or_fetch_and_insert_remote_comment(&comment.get_ap_id()?, client, pool)
+ let comment_id = get_or_fetch_and_insert_comment(&comment.get_ap_id()?, client, pool)
.await?
.id;
use crate::{
apub::{
extensions::signatures::verify,
- fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
- insert_activity, ActorType,
+ fetcher::{get_or_fetch_and_upsert_community, get_or_fetch_and_upsert_user},
+ insert_activity,
+ ActorType,
},
blocking,
routes::{ChatServerParam, DbPoolParam},
let user_uri = follow.actor()?.as_single_xsd_any_uri().unwrap();
let community_uri = follow.object().as_single_xsd_any_uri().unwrap();
- let user = get_or_fetch_and_upsert_remote_user(&user_uri, &client, &db).await?;
- let community = get_or_fetch_and_upsert_remote_community(community_uri, &client, &db).await?;
+ let user = get_or_fetch_and_upsert_user(&user_uri, &client, &db).await?;
+ let community = get_or_fetch_and_upsert_community(community_uri, &client, &db).await?;
verify(&request, &user)?;
community::do_announce,
extensions::signatures::verify,
fetcher::{
- get_or_fetch_and_upsert_remote_actor, get_or_fetch_and_upsert_remote_community,
- get_or_fetch_and_upsert_remote_user,
+ get_or_fetch_and_upsert_actor,
+ get_or_fetch_and_upsert_community,
+ get_or_fetch_and_upsert_user,
},
inbox::activities::{
- announce::receive_announce, create::receive_create, delete::receive_delete,
- dislike::receive_dislike, like::receive_like, remove::receive_remove, undo::receive_undo,
+ announce::receive_announce,
+ create::receive_create,
+ delete::receive_delete,
+ dislike::receive_dislike,
+ like::receive_like,
+ remove::receive_remove,
+ undo::receive_undo,
update::receive_update,
},
insert_activity,
},
routes::{ChatServerParam, DbPoolParam},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{
activity::{ActorAndObject, ActorAndObjectRef},
use log::debug;
use serde::Serialize;
use std::fmt::Debug;
+use url::Url;
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "PascalCase")]
let sender = &activity.actor()?.to_owned().single_xsd_any_uri().unwrap();
// TODO: pass this actor in instead of using get_user_from_activity()
- let actor = get_or_fetch_and_upsert_remote_actor(sender, &client, &pool).await?;
+ let actor = get_or_fetch_and_upsert_actor(sender, &client, &pool).await?;
verify(&request, actor.as_ref())?;
insert_activity(actor.user_id(), activity.clone(), false, &pool).await?;
{
let actor = activity.actor()?;
let user_uri = actor.as_single_xsd_any_uri().unwrap();
- get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await
+ get_or_fetch_and_upsert_user(&user_uri, client, pool).await
}
pub(in crate::apub::inbox) async fn announce_if_community_is_local<T, Kind>(
{
let cc = activity.cc().unwrap();
let cc = cc.as_many().unwrap();
- let community_uri = cc.first().unwrap().as_xsd_any_uri().unwrap();
- let community = get_or_fetch_and_upsert_remote_community(&community_uri, client, pool).await?;
+ let community_followers_uri = cc.first().unwrap().as_xsd_any_uri().unwrap();
+ // TODO: this is hacky but seems to be the only way to get the community ID
+ let community_uri = community_followers_uri
+ .to_string()
+ .replace("/followers", "");
+ let community =
+ get_or_fetch_and_upsert_community(&Url::parse(&community_uri)?, client, pool).await?;
if community.local {
do_announce(activity.into_any_base()?, &community, &user, client, pool).await?;
api::user::PrivateMessageResponse,
apub::{
extensions::signatures::verify,
- fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
- insert_activity, FromApub,
+ fetcher::{get_or_fetch_and_upsert_community, get_or_fetch_and_upsert_user},
+ insert_activity,
+ FromApub,
},
blocking,
routes::{ChatServerParam, DbPoolParam},
websocket::{server::SendUserRoomMessage, UserOperation},
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{
activity::{Accept, Create, Delete, Undo, Update},
private_message::{PrivateMessage, PrivateMessageForm},
private_message_view::PrivateMessageView,
user::User_,
- Crud, Followable,
+ Crud,
+ Followable,
};
use log::debug;
use serde::Deserialize;
) -> Result<HttpResponse, LemmyError> {
let community_uri = accept.actor()?.to_owned().single_xsd_any_uri().unwrap();
- let community = get_or_fetch_and_upsert_remote_community(&community_uri, client, pool).await?;
+ let community = get_or_fetch_and_upsert_community(&community_uri, client, pool).await?;
verify(request, &community)?;
let username = username.to_owned();
let user_uri = &create.actor()?.to_owned().single_xsd_any_uri().unwrap();
let note = Note::from_any_base(create.object().as_one().unwrap().to_owned())?.unwrap();
- let user = get_or_fetch_and_upsert_remote_user(user_uri, client, pool).await?;
+ let user = get_or_fetch_and_upsert_user(user_uri, client, pool).await?;
verify(request, &user)?;
insert_activity(user.id, create, false, pool).await?;
let user_uri = &update.actor()?.to_owned().single_xsd_any_uri().unwrap();
let note = Note::from_any_base(update.object().as_one().unwrap().to_owned())?.unwrap();
- let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
+ let user = get_or_fetch_and_upsert_user(&user_uri, client, pool).await?;
verify(request, &user)?;
insert_activity(user.id, update, false, pool).await?;
let user_uri = &delete.actor()?.to_owned().single_xsd_any_uri().unwrap();
let note = Note::from_any_base(delete.object().as_one().unwrap().to_owned())?.unwrap();
- let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
+ let user = get_or_fetch_and_upsert_user(&user_uri, client, pool).await?;
verify(request, &user)?;
insert_activity(user.id, delete, false, pool).await?;
let note = Note::from_any_base(delete.object().as_one().unwrap().to_owned())?.unwrap();
let user_uri = &delete.actor()?.to_owned().single_xsd_any_uri().unwrap();
- let user = get_or_fetch_and_upsert_remote_user(&user_uri, client, pool).await?;
+ let user = get_or_fetch_and_upsert_user(&user_uri, client, pool).await?;
verify(request, &user)?;
insert_activity(user.id, delete, false, pool).await?;
blocking,
request::{retry, RecvError},
routes::webfinger::WebFingerResponse,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_ext::{Ext1, Ext2};
use activitystreams_new::{
use crate::{
apub::{
activities::{generate_activity_id, send_activity_to_community},
- create_apub_response, create_apub_tombstone_response, create_tombstone,
+ create_apub_response,
+ create_apub_tombstone_response,
+ create_tombstone,
extensions::page_extension::PageExtension,
- fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
- ActorType, ApubLikeableType, ApubObjectType, FromApub, PageExt, ToApub,
+ fetcher::{get_or_fetch_and_upsert_community, get_or_fetch_and_upsert_user},
+ ActorType,
+ ApubLikeableType,
+ ApubObjectType,
+ FromApub,
+ PageExt,
+ ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_ext::Ext1;
use activitystreams_new::{
activity::{
kind::{CreateType, DeleteType, DislikeType, LikeType, RemoveType, UndoType, UpdateType},
- Create, Delete, Dislike, Like, Remove, Undo, Update,
+ Create,
+ Delete,
+ Dislike,
+ Like,
+ Remove,
+ Undo,
+ Update,
},
context,
object::{kind::PageType, Image, Page, Tombstone},
.as_single_xsd_any_uri()
.unwrap();
- let creator = get_or_fetch_and_upsert_remote_user(creator_actor_id, client, pool).await?;
+ let creator = get_or_fetch_and_upsert_user(creator_actor_id, client, pool).await?;
let community_actor_id = page
.inner
.as_single_xsd_any_uri()
.unwrap();
- let community =
- get_or_fetch_and_upsert_remote_community(community_actor_id, client, pool).await?;
+ let community = get_or_fetch_and_upsert_community(community_actor_id, client, pool).await?;
let thumbnail_url = match &page.inner.image() {
Some(any_image) => Image::from_any_base(any_image.to_owned().as_one().unwrap().to_owned())?
apub::{
activities::{generate_activity_id, send_activity},
create_tombstone,
- fetcher::get_or_fetch_and_upsert_remote_user,
- insert_activity, ApubObjectType, FromApub, ToApub,
+ fetcher::get_or_fetch_and_upsert_user,
+ insert_activity,
+ ApubObjectType,
+ FromApub,
+ ToApub,
},
- blocking, DbPool, LemmyError,
+ blocking,
+ DbPool,
+ LemmyError,
};
use activitystreams_new::{
activity::{
kind::{CreateType, DeleteType, UndoType, UpdateType},
- Create, Delete, Undo, Update,
+ Create,
+ Delete,
+ Undo,
+ Update,
},
context,
object::{kind::NoteType, Note, Tombstone},
.single_xsd_any_uri()
.unwrap();
- let creator = get_or_fetch_and_upsert_remote_user(&creator_actor_id, client, pool).await?;
+ let creator = get_or_fetch_and_upsert_user(&creator_actor_id, client, pool).await?;
let recipient_actor_id = note.to().unwrap().clone().single_xsd_any_uri().unwrap();
- let recipient = get_or_fetch_and_upsert_remote_user(&recipient_actor_id, client, pool).await?;
+ let recipient = get_or_fetch_and_upsert_user(&recipient_actor_id, client, pool).await?;
Ok(PrivateMessageForm {
creator_id: creator.id,
use crate::{
apub::{
activities::{generate_activity_id, send_activity},
- create_apub_response, insert_activity, ActorType, FromApub, PersonExt, ToApub,
+ create_apub_response,
+ insert_activity,
+ ActorType,
+ FromApub,
+ PersonExt,
+ ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool, LemmyError,
+ DbPool,
+ LemmyError,
};
use activitystreams_ext::Ext1;
use activitystreams_new::{
activity::{
kind::{FollowType, UndoType},
- Follow, Undo,
+ Follow,
+ Undo,
},
actor::{ApActor, Endpoints, Person},
context,