// Only add the like if the score isnt 0
let comment = orig_comment.comment;
- let object = PostOrComment::Comment(Box::new(comment));
+ let object = PostOrComment::Comment(comment);
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
if do_add {
let like_form2 = like_form.clone();
})
.await??;
- let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??;
+ let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
// Making sure the site creator, if an admin, is at the top
let creator_index = admins
})
.await??;
- let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??;
+ let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
let creator_index = admins
.iter()
.position(|r| r.person.id == site_creator_id)
blocking(context.pool(), move |conn| ModAdd::create(conn, &form)).await??;
- let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
+ let site_view = blocking(context.pool(), SiteView::read).await??;
- let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??;
+ let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
let creator_index = admins
.iter()
.position(|r| r.person.id == site_view.creator.id)
let creator_person = admins.remove(creator_index);
admins.insert(0, creator_person);
- let banned = blocking(context.pool(), move |conn| PersonViewSafe::banned(conn)).await??;
+ let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
let federated_instances = build_federated_instances(
context.pool(),
&context.settings().federation,
return Err(ApiError::err("couldnt_like_comment").into());
}
- let object = PostOrComment::Comment(Box::new(updated_comment));
+ let object = PostOrComment::Comment(updated_comment);
Vote::send(
&object,
&local_user_view.person,
return Err(ApiError::err("site_already_exists").into());
}
- let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
+ let site_view = blocking(context.pool(), SiteView::read).await??;
Ok(SiteResponse { site_view })
}
) -> Result<GetSiteResponse, LemmyError> {
let data: &GetSite = self;
- let site_view = match blocking(context.pool(), move |conn| SiteView::read(conn)).await? {
+ let site_view = match blocking(context.pool(), SiteView::read).await? {
Ok(site_view) => Some(site_view),
// If the site isn't created yet, check the setup
Err(_) => {
};
create_site.perform(context, websocket_id).await?;
info!("Site {} created", setup.site_name);
- Some(blocking(context.pool(), move |conn| SiteView::read(conn)).await??)
+ Some(blocking(context.pool(), SiteView::read).await??)
} else {
None
}
}
};
- let mut admins = blocking(context.pool(), move |conn| PersonViewSafe::admins(conn)).await??;
+ let mut admins = blocking(context.pool(), PersonViewSafe::admins).await??;
// Make sure the site creator is the top admin
if let Some(site_view) = site_view.to_owned() {
}
}
- let banned = blocking(context.pool(), move |conn| PersonViewSafe::banned(conn)).await??;
+ let banned = blocking(context.pool(), PersonViewSafe::banned).await??;
let online = context
.chat_server()
return Err(ApiError::err("couldnt_update_site").into());
}
- let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
+ let site_view = blocking(context.pool(), SiteView::read).await??;
let res = SiteResponse { site_view };
.await?;
match object {
PostOrComment::Post(p) => undo_vote_post(actor, p.deref(), context).await,
- PostOrComment::Comment(c) => undo_vote_comment(actor, c.deref(), context).await,
+ PostOrComment::Comment(c) => undo_vote_comment(actor, &c, context).await,
}
}
}
let object = self.object.dereference(context, request_counter).await?;
match object {
PostOrComment::Post(p) => vote_post(&self.kind, actor, p.deref(), context).await,
- PostOrComment::Comment(c) => vote_comment(&self.kind, actor, c.deref(), context).await,
+ PostOrComment::Comment(c) => vote_comment(&self.kind, actor, &c, context).await,
}
}
}
#[derive(Clone, Debug)]
pub enum PostOrComment {
- Comment(Box<Comment>),
Post(Box<Post>),
+ Comment(Comment),
}
pub enum PostOrCommentForm {
- PostForm(PostForm),
+ PostForm(Box<PostForm>),
CommentForm(CommentForm),
}
#[derive(Deserialize)]
pub enum PageOrNote {
- Page(Page),
- Note(Note),
+ Page(Box<Page>),
+ Note(Box<Note>),
}
#[async_trait::async_trait(?Send)]
let post = Post::read_from_apub_id(conn, object_id.clone())?;
Ok(match post {
Some(o) => Some(PostOrComment::Post(Box::new(o))),
- None => {
- Comment::read_from_apub_id(conn, object_id)?.map(|c| PostOrComment::Comment(Box::new(c)))
- }
+ None => Comment::read_from_apub_id(conn, object_id)?.map(PostOrComment::Comment),
})
}
}
PageOrNote::Page(p) => PostOrComment::Post(Box::new(
Post::from_apub(p, context, expected_domain, request_counter).await?,
)),
- PageOrNote::Note(n) => PostOrComment::Comment(Box::new(
+ PageOrNote::Note(n) => PostOrComment::Comment(
Comment::from_apub(n, context, expected_domain, request_counter).await?,
- )),
+ ),
})
}
}
listing_type: ListingType,
sort_type: SortType,
) -> Result<HttpResponse, LemmyError> {
- let site_view = blocking(context.pool(), move |conn| SiteView::read(conn)).await??;
+ let site_view = blocking(context.pool(), SiteView::read).await??;
let posts = blocking(context.pool(), move |conn| {
PostQueryBuilder::create(conn)