pub fn establish_unpooled_connection() -> PgConnection {
let db_url = match get_database_url_from_env() {
Ok(url) => url,
- Err(_) => panic!("Failed to read database URL from env var LEMMY_DATABASE_URL"),
+ Err(e) => panic!("Failed to read database URL from env var LEMMY_DATABASE_URL: {}", e),
};
PgConnection::establish(&db_url).unwrap_or_else(|_| panic!("Error connecting to {}", db_url))
}
use crate::{
apub::{
activities::{populate_object_props, 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_insert_remote_comment, get_or_fetch_and_insert_remote_post,
get_or_fetch_and_upsert_remote_user,
},
- ActorType,
- ApubLikeableType,
- ApubObjectType,
- FromApub,
- ToApub,
+ ActorType, ApubLikeableType, ApubObjectType, FromApub, ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
/// Parse an ActivityPub note received from another instance into a Lemmy comment
async fn from_apub(
- note: &mut Note,
+ note: &Note,
client: &Client,
pool: &DbPool,
) -> Result<CommentForm, LemmyError> {
use crate::{
apub::{
activities::{populate_object_props, 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,
+ get_shared_inbox, insert_activity, ActorType, FromApub, GroupExt, ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
activity::{Accept, Announce, Delete, Remove, Undo},
- Activity,
- Base,
- BaseBox,
+ Activity, Base, BaseBox,
};
use activitystreams_ext::Ext2;
use activitystreams_new::{
type ApubType = GroupExt;
/// Parse an ActivityPub group received from another instance into a Lemmy community.
- async fn from_apub(
- group: &mut GroupExt,
- client: &Client,
- pool: &DbPool,
- ) -> Result<Self, LemmyError> {
- // TODO: this is probably gonna cause problems cause fetcher:292 also calls take_attributed_to()
- let creator_and_moderator_uris = group.clone().take_attributed_to().unwrap();
+ async fn from_apub(group: &GroupExt, client: &Client, pool: &DbPool) -> Result<Self, LemmyError> {
+ let creator_and_moderator_uris = group.attributed_to().unwrap();
let creator_uri = creator_and_moderator_uris
.as_many()
.unwrap()
let creator = get_or_fetch_and_upsert_remote_user(creator_uri.as_str(), client, pool).await?;
Ok(CommunityForm {
- name: group
- .take_name()
- .unwrap()
- .as_single_xsd_string()
- .unwrap()
- .into(),
- title: group.inner.take_preferred_username().unwrap(),
+ name: group.name().unwrap().as_single_xsd_string().unwrap().into(),
+ title: group.inner.preferred_username().unwrap().to_string(),
// TODO: should be parsed as html and tags like <script> removed (or use markdown source)
// -> same for post.content etc
description: group
- .take_content()
+ .content()
.map(|s| s.as_single_xsd_string().unwrap().into()),
category_id: group.ext_one.category.identifier.parse::<i32>()?,
creator_id: creator.id,
removed: None,
published: group
- .take_published()
- .map(|u| u.as_ref().to_owned().naive_local()),
- updated: group
- .take_updated()
+ .published()
.map(|u| u.as_ref().to_owned().naive_local()),
+ updated: group.updated().map(|u| u.as_ref().to_owned().naive_local()),
deleted: None,
nsfw: group.ext_one.sensitive,
actor_id: group.id().unwrap().to_string(),
blocking,
request::{retry, RecvError},
routes::nodeinfo::{NodeInfo, NodeInfoWellKnown},
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::object::Note;
use activitystreams_new::{base::BaseExt, prelude::*, primitives::XsdAnyUri};
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;
response
}
- SearchAcceptedObjects::Page(mut p) => {
- let post_form = PostForm::from_apub(&mut p, client, pool).await?;
+ SearchAcceptedObjects::Page(p) => {
+ let post_form = PostForm::from_apub(&p, client, pool).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
}
- SearchAcceptedObjects::Comment(mut c) => {
+ SearchAcceptedObjects::Comment(c) => {
let post_url = c
.object_props
.get_many_in_reply_to_xsd_any_uris()
.to_string();
// TODO: also fetch parent comments if any
- let mut post = fetch_remote_object(client, &Url::parse(&post_url)?).await?;
- let post_form = PostForm::from_apub(&mut post, client, pool).await?;
- let comment_form = CommentForm::from_apub(&mut c, client, pool).await?;
+ let post = fetch_remote_object(client, &Url::parse(&post_url)?).await?;
+ let post_form = PostForm::from_apub(&post, client, pool).await?;
+ let comment_form = CommentForm::from_apub(&c, client, pool).await?;
blocking(pool, move |conn| upsert_post(&post_form, conn)).await??;
let c = blocking(pool, move |conn| upsert_comment(&comment_form, conn)).await??;
// If its older than a day, re-fetch it
Ok(u) if !u.local && should_refetch_actor(u.last_refreshed_at) => {
debug!("Fetching and updating from remote user: {}", apub_id);
- let mut person = fetch_remote_object::<PersonExt>(client, &Url::parse(apub_id)?).await?;
+ let person = fetch_remote_object::<PersonExt>(client, &Url::parse(apub_id)?).await?;
- let mut uf = UserForm::from_apub(&mut person, client, pool).await?;
+ let mut uf = UserForm::from_apub(&person, client, pool).await?;
uf.last_refreshed_at = Some(naive_now());
let user = blocking(pool, move |conn| User_::update(conn, u.id, &uf)).await??;
Ok(u) => Ok(u),
Err(NotFound {}) => {
debug!("Fetching and creating remote user: {}", apub_id);
- let mut person = fetch_remote_object::<PersonExt>(client, &Url::parse(apub_id)?).await?;
+ let person = fetch_remote_object::<PersonExt>(client, &Url::parse(apub_id)?).await?;
- let uf = UserForm::from_apub(&mut person, client, pool).await?;
+ let uf = UserForm::from_apub(&person, client, pool).await?;
let user = blocking(pool, move |conn| User_::create(conn, &uf)).await??;
Ok(user)
match community {
Ok(c) if !c.local && should_refetch_actor(c.last_refreshed_at) => {
debug!("Fetching and updating from remote community: {}", apub_id);
- let mut group = fetch_remote_object::<GroupExt>(client, &Url::parse(apub_id)?).await?;
+ let group = fetch_remote_object::<GroupExt>(client, &Url::parse(apub_id)?).await?;
- let mut cf = CommunityForm::from_apub(&mut group, client, pool).await?;
+ let mut cf = CommunityForm::from_apub(&group, client, pool).await?;
cf.last_refreshed_at = Some(naive_now());
let community = blocking(pool, move |conn| Community::update(conn, c.id, &cf)).await??;
Ok(c) => Ok(c),
Err(NotFound {}) => {
debug!("Fetching and creating remote community: {}", apub_id);
- let mut group = fetch_remote_object::<GroupExt>(client, &Url::parse(apub_id)?).await?;
+ let group = fetch_remote_object::<GroupExt>(client, &Url::parse(apub_id)?).await?;
- let cf = CommunityForm::from_apub(&mut group, client, pool).await?;
+ let cf = CommunityForm::from_apub(&group, client, pool).await?;
let community = blocking(pool, move |conn| Community::create(conn, &cf)).await??;
// Also add the community moderators too
- let attributed_to = group.inner.take_attributed_to().unwrap();
+ let attributed_to = group.inner.attributed_to().unwrap();
let creator_and_moderator_uris: Vec<&XsdAnyUri> = attributed_to
.as_many()
.unwrap()
Ok(p) => Ok(p),
Err(NotFound {}) => {
debug!("Fetching and creating remote post: {}", post_ap_id);
- let mut post = fetch_remote_object::<PageExt>(client, &Url::parse(post_ap_id)?).await?;
- let post_form = PostForm::from_apub(&mut post, client, pool).await?;
+ let post = fetch_remote_object::<PageExt>(client, &Url::parse(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??;
"Fetching and creating remote comment and its parents: {}",
comment_ap_id
);
- let mut comment = fetch_remote_object::<Note>(client, &Url::parse(comment_ap_id)?).await?;
- let comment_form = CommentForm::from_apub(&mut comment, client, pool).await?;
+ let comment = fetch_remote_object::<Note>(client, &Url::parse(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??;
blocking,
request::{retry, RecvError},
routes::webfinger::WebFingerResponse,
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::object::Page;
use activitystreams_ext::{Ext1, Ext2};
pub trait FromApub {
type ApubType;
async fn from_apub(
- apub: &mut Self::ApubType,
+ apub: &Self::ApubType,
client: &Client,
pool: &DbPool,
) -> Result<Self, LemmyError>
use crate::{
apub::{
activities::{populate_object_props, 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,
+ ActorType, ApubLikeableType, ApubObjectType, FromApub, PageExt, ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
activity::{Create, Delete, Dislike, Like, Remove, Undo, Update},
/// Parse an ActivityPub page received from another instance into a Lemmy post.
async fn from_apub(
- page: &mut PageExt,
+ page: &PageExt,
client: &Client,
pool: &DbPool,
) -> Result<PostForm, LemmyError> {
use crate::{
apub::{
- activities::send_activity,
- create_tombstone,
- fetcher::get_or_fetch_and_upsert_remote_user,
- insert_activity,
- ApubObjectType,
- FromApub,
- ToApub,
+ activities::send_activity, create_tombstone, fetcher::get_or_fetch_and_upsert_remote_user,
+ insert_activity, ApubObjectType, FromApub, ToApub,
},
- blocking,
- DbPool,
- LemmyError,
+ blocking, DbPool, LemmyError,
};
use activitystreams::{
activity::{Create, Delete, Undo, Update},
/// Parse an ActivityPub note received from another instance into a Lemmy Private message
async fn from_apub(
- note: &mut Note,
+ note: &Note,
client: &Client,
pool: &DbPool,
) -> Result<PrivateMessageForm, LemmyError> {
community::do_announce,
extensions::signatures::verify,
fetcher::{
- get_or_fetch_and_insert_remote_comment,
- get_or_fetch_and_insert_remote_post,
- get_or_fetch_and_upsert_remote_community,
- get_or_fetch_and_upsert_remote_user,
+ get_or_fetch_and_insert_remote_comment, get_or_fetch_and_insert_remote_post,
+ get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user,
},
- insert_activity,
- FromApub,
- GroupExt,
- PageExt,
+ insert_activity, FromApub, GroupExt, PageExt,
},
blocking,
routes::{ChatServerParam, DbPoolParam},
server::{SendComment, SendCommunityRoomMessage, SendPost},
UserOperation,
},
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
activity::{Announce, Create, Delete, Dislike, Like, Remove, Undo, Update},
object::Note,
- Activity,
- Base,
- BaseBox,
+ Activity, Base, BaseBox,
};
use actix_web::{client::Client, web, HttpRequest, HttpResponse};
use lemmy_db::{
naive_now,
post::{Post, PostForm, PostLike, PostLikeForm},
post_view::PostView,
- Crud,
- Likeable,
+ Crud, Likeable,
};
use lemmy_utils::scrape_text_for_mentions;
use log::debug;
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = create
+ let page = create
.create_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, create, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let inserted_post = blocking(pool, move |conn| Post::create(conn, &post)).await??;
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = create
+ let note = create
.create_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, create, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(¬e, client, pool).await?;
let inserted_comment = blocking(pool, move |conn| Comment::create(conn, &comment)).await??;
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = update
+ let page = update
.update_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, update, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = like
+ let page = like
.like_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, like, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = dislike
+ let page = dislike
.dislike_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, dislike, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = update
+ let note = update
.update_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, update, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(¬e, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = like
+ let note = like
.like_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, like, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(¬e, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = dislike
+ let note = dislike
.dislike_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, dislike, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(¬e, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
.unwrap()
.to_string();
- let mut group = delete
+ let group = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
.unwrap()
.to_string();
- let mut group = remove
+ let group = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
.unwrap()
.to_string();
- let mut page = delete
+ let page = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut page = remove
+ let page = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(¬e, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut note = remove
+ let note = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(¬e, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(¬e, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut note = remove
+ let note = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let comment_ap_id = CommentForm::from_apub(&mut note, client, pool).await?.ap_id;
+ let comment_ap_id = CommentForm::from_apub(¬e, client, pool).await?.ap_id;
let comment = get_or_fetch_and_insert_remote_comment(&comment_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut page = delete
+ let page = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut page = remove
+ let page = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let post_ap_id = PostForm::from_apub(&mut page, client, pool).await?.ap_id;
+ let post_ap_id = PostForm::from_apub(&page, client, pool).await?.ap_id;
let post = get_or_fetch_and_insert_remote_post(&post_ap_id, client, pool).await?;
.unwrap()
.to_string();
- let mut group = delete
+ let group = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
.unwrap()
.to_string();
- let mut group = remove
+ let group = remove
.remove_props
.get_object_base_box()
.to_owned()
insert_activity(mod_.id, remove, false, pool).await?;
- let community_actor_id = CommunityForm::from_apub(&mut group, client, pool)
+ let community_actor_id = CommunityForm::from_apub(&group, client, pool)
.await?
.actor_id;
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = like
+ let note = like
.like_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, like, false, pool).await?;
- let comment = CommentForm::from_apub(&mut note, client, pool).await?;
+ let comment = CommentForm::from_apub(¬e, client, pool).await?;
let comment_id = get_or_fetch_and_insert_remote_comment(&comment.ap_id, client, pool)
.await?
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut page = like
+ let page = like
.like_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, like, false, pool).await?;
- let post = PostForm::from_apub(&mut page, client, pool).await?;
+ let post = PostForm::from_apub(&page, client, pool).await?;
let post_id = get_or_fetch_and_insert_remote_post(&post.ap_id, client, pool)
.await?
use crate::{
api::claims::Claims,
apub::{
- activities::send_activity,
- create_apub_response,
- insert_activity,
- ActorType,
- FromApub,
- PersonExt,
- ToApub,
+ activities::send_activity, create_apub_response, insert_activity, ActorType, FromApub,
+ PersonExt, ToApub,
},
blocking,
routes::DbPoolParam,
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams_ext::Ext1;
use activitystreams_new::{
impl FromApub for UserForm {
type ApubType = PersonExt;
/// Parse an ActivityPub person received from another instance into a Lemmy user.
- async fn from_apub(person: &mut PersonExt, _: &Client, _: &DbPool) -> Result<Self, LemmyError> {
- let avatar = match person.take_icon() {
+ async fn from_apub(person: &PersonExt, _: &Client, _: &DbPool) -> Result<Self, LemmyError> {
+ let avatar = match person.icon() {
Some(any_image) => Image::from_any_base(any_image.as_one().unwrap().clone())
.unwrap()
.unwrap()
Ok(UserForm {
name: person
- .take_name()
+ .name()
.unwrap()
.as_single_xsd_string()
.unwrap()
.into(),
- preferred_username: person.inner.take_preferred_username(),
+ preferred_username: person.inner.preferred_username().map(|u| u.to_string()),
password_encrypted: "".to_string(),
admin: false,
banned: false,
email: None,
avatar,
updated: person
- .take_updated()
+ .updated()
.map(|u| u.as_ref().to_owned().naive_local()),
show_nsfw: false,
theme: "".to_string(),
matrix_user_id: None,
actor_id: person.id().unwrap().to_string(),
bio: person
- .take_summary()
+ .summary()
.map(|s| s.as_single_xsd_string().unwrap().into()),
local: false,
private_key: None,
apub::{
extensions::signatures::verify,
fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user},
- insert_activity,
- FromApub,
+ insert_activity, FromApub,
},
blocking,
routes::{ChatServerParam, DbPoolParam},
websocket::{server::SendUserRoomMessage, UserOperation},
- DbPool,
- LemmyError,
+ DbPool, LemmyError,
};
use activitystreams::{
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;
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = create
+ let note = create
.create_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, create, false, pool).await?;
- let private_message = PrivateMessageForm::from_apub(&mut note, client, pool).await?;
+ let private_message = PrivateMessageForm::from_apub(¬e, client, pool).await?;
let inserted_private_message = blocking(pool, move |conn| {
PrivateMessage::create(conn, &private_message)
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = update
+ let note = update
.update_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, update, false, pool).await?;
- let private_message_form = PrivateMessageForm::from_apub(&mut note, client, pool).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 = blocking(pool, move |conn| {
pool: &DbPool,
chat_server: ChatServerParam,
) -> Result<HttpResponse, LemmyError> {
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let private_message_form = PrivateMessageForm::from_apub(&mut note, client, pool).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 = blocking(pool, move |conn| {
.to_owned()
.into_concrete::<Delete>()?;
- let mut note = delete
+ let note = delete
.delete_props
.get_object_base_box()
.to_owned()
insert_activity(user.id, delete, false, pool).await?;
- let private_message = PrivateMessageForm::from_apub(&mut note, client, pool).await?;
+ let private_message = PrivateMessageForm::from_apub(¬e, client, pool).await?;
let private_message_ap_id = private_message.ap_id.clone();
let private_message_id = blocking(pool, move |conn| {