1 use crate::activities::receive::get_actor_as_person;
2 use activitystreams::activity::{Dislike, Like};
3 use lemmy_api_structs::{blocking, comment::CommentResponse};
4 use lemmy_db_queries::{source::comment::Comment_, Likeable};
5 use lemmy_db_schema::source::comment::{Comment, CommentLike};
6 use lemmy_db_views::comment_view::CommentView;
7 use lemmy_utils::LemmyError;
8 use lemmy_websocket::{messages::SendComment, LemmyContext, UserOperation};
10 pub(crate) async fn receive_undo_like_comment(
13 context: &LemmyContext,
14 request_counter: &mut i32,
15 ) -> Result<(), LemmyError> {
16 let person = get_actor_as_person(like, context, request_counter).await?;
18 let comment_id = comment.id;
19 let person_id = person.id;
20 blocking(context.pool(), move |conn| {
21 CommentLike::remove(conn, person_id, comment_id)
26 let comment_view = blocking(context.pool(), move |conn| {
27 CommentView::read(conn, comment_id, None)
31 // TODO get those recipient actor ids from somewhere
32 let recipient_ids = vec![];
33 let res = CommentResponse {
39 context.chat_server().do_send(SendComment {
40 op: UserOperation::CreateCommentLike,
48 pub(crate) async fn receive_undo_dislike_comment(
51 context: &LemmyContext,
52 request_counter: &mut i32,
53 ) -> Result<(), LemmyError> {
54 let person = get_actor_as_person(dislike, context, request_counter).await?;
56 let comment_id = comment.id;
57 let person_id = person.id;
58 blocking(context.pool(), move |conn| {
59 CommentLike::remove(conn, person_id, comment_id)
64 let comment_view = blocking(context.pool(), move |conn| {
65 CommentView::read(conn, comment_id, None)
69 // TODO get those recipient actor ids from somewhere
70 let recipient_ids = vec![];
71 let res = CommentResponse {
77 context.chat_server().do_send(SendComment {
78 op: UserOperation::CreateCommentLike,
86 pub(crate) async fn receive_undo_delete_comment(
87 context: &LemmyContext,
89 ) -> Result<(), LemmyError> {
90 let deleted_comment = blocking(context.pool(), move |conn| {
91 Comment::update_deleted(conn, comment.id, false)
96 let comment_id = deleted_comment.id;
97 let comment_view = blocking(context.pool(), move |conn| {
98 CommentView::read(conn, comment_id, None)
102 // TODO get those recipient actor ids from somewhere
103 let recipient_ids = vec![];
104 let res = CommentResponse {
110 context.chat_server().do_send(SendComment {
111 op: UserOperation::EditComment,
119 pub(crate) async fn receive_undo_remove_comment(
120 context: &LemmyContext,
122 ) -> Result<(), LemmyError> {
123 let removed_comment = blocking(context.pool(), move |conn| {
124 Comment::update_removed(conn, comment.id, false)
129 let comment_id = removed_comment.id;
130 let comment_view = blocking(context.pool(), move |conn| {
131 CommentView::read(conn, comment_id, None)
135 // TODO get those recipient actor ids from somewhere
136 let recipient_ids = vec![];
137 let res = CommentResponse {
143 context.chat_server().do_send(SendComment {
144 op: UserOperation::EditComment,