summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDessalines <dessalines@users.noreply.github.com>2020-07-14 12:12:04 -0400
committerGitHub <noreply@github.com>2020-07-14 12:12:04 -0400
commitcc0ae6343c5a6537cee19c7b5a21201794f7d4c3 (patch)
tree7df90e6b7e483f280bf74d46d5d3111a2f8677b3
parent2f32d3e6dfedf985cc09d92c5be3c4b5d0f7b16c (diff)
downloadlemmy-cc0ae6343c5a6537cee19c7b5a21201794f7d4c3.tar.gz
lemmy-cc0ae6343c5a6537cee19c7b5a21201794f7d4c3.tar.xz
Fixing user mention reading. (#968)
-rw-r--r--server/src/api/user.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/src/api/user.rs b/server/src/api/user.rs
index ddcf2ef2..d547f64b 100644
--- a/server/src/api/user.rs
+++ b/server/src/api/user.rs
@@ -880,28 +880,29 @@ impl Perform for Oper<EditUserMention> {
};
let user_id = claims.id;
- if user_id != data.user_mention_id {
- return Err(APIError::err("couldnt_update_comment").into());
- }
let user_mention_id = data.user_mention_id;
- let user_mention =
+ let read_user_mention =
blocking(pool, move |conn| UserMention::read(conn, user_mention_id)).await??;
+ if user_id != read_user_mention.recipient_id {
+ return Err(APIError::err("couldnt_update_comment").into());
+ }
+
let user_mention_form = UserMentionForm {
- recipient_id: user_id,
- comment_id: user_mention.comment_id,
+ recipient_id: read_user_mention.recipient_id,
+ comment_id: read_user_mention.comment_id,
read: data.read.to_owned(),
};
- let user_mention_id = user_mention.id;
+ let user_mention_id = read_user_mention.id;
let update_mention =
move |conn: &'_ _| UserMention::update(conn, user_mention_id, &user_mention_form);
if blocking(pool, update_mention).await?.is_err() {
return Err(APIError::err("couldnt_update_comment").into());
};
- let user_mention_id = user_mention.id;
+ let user_mention_id = read_user_mention.id;
let user_mention_view = blocking(pool, move |conn| {
UserMentionView::read(conn, user_mention_id, user_id)
})