summaryrefslogtreecommitdiffstats
path: root/server/src/api/comment.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-04-27 12:57:00 -0400
committerDessalines <tyhou13@gmx.com>2020-04-27 12:57:00 -0400
commit22abbebd41d586298c62bb6a45efa7a96d998049 (patch)
tree60c31f49e9cee360cd06edc18eb53f93e953d6b7 /server/src/api/comment.rs
parent3ce061836242813730ec0b63240097347647dfc4 (diff)
Lots of additions to federation.
- Added a shared inbox. - Added federated comments, comment updates, and tests. - Abstracted ap object sends into a common trait.
Diffstat (limited to 'server/src/api/comment.rs')
-rw-r--r--server/src/api/comment.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/server/src/api/comment.rs b/server/src/api/comment.rs
index eb67d8f2..fddb42ab 100644
--- a/server/src/api/comment.rs
+++ b/server/src/api/comment.rs
@@ -87,7 +87,8 @@ impl Perform for Oper<CreateComment> {
}
// Check for a site ban
- if UserView::read(&conn, user_id)?.banned {
+ let user = User_::read(&conn, user_id)?;
+ if user.banned {
return Err(APIError::err("site_ban").into());
}
@@ -101,6 +102,7 @@ impl Perform for Oper<CreateComment> {
removed: None,
deleted: None,
read: None,
+ published: None,
updated: None,
ap_id: "changeme".into(),
local: true,
@@ -111,11 +113,13 @@ impl Perform for Oper<CreateComment> {
Err(_e) => return Err(APIError::err("couldnt_create_comment").into()),
};
- match Comment::update_ap_id(&conn, inserted_comment.id) {
+ let updated_comment = match Comment::update_ap_id(&conn, inserted_comment.id) {
Ok(comment) => comment,
Err(_e) => return Err(APIError::err("couldnt_create_comment").into()),
};
+ updated_comment.send_create(&user, &conn)?;
+
let mut recipient_ids = Vec::new();
// Scan the comment for user mentions, add those rows
@@ -273,6 +277,8 @@ impl Perform for Oper<EditComment> {
let conn = pool.get()?;
+ let user = User_::read(&conn, user_id)?;
+
let orig_comment = CommentView::read(&conn, data.edit_id, None)?;
// You are allowed to mark the comment as read even if you're banned.
@@ -297,7 +303,7 @@ impl Perform for Oper<EditComment> {
}
// Check for a site ban
- if UserView::read(&conn, user_id)?.banned {
+ if user.banned {
return Err(APIError::err("site_ban").into());
}
}
@@ -314,6 +320,7 @@ impl Perform for Oper<EditComment> {
removed: data.removed.to_owned(),
deleted: data.deleted.to_owned(),
read: data.read.to_owned(),
+ published: None,
updated: if data.read.is_some() {
orig_comment.updated
} else {
@@ -323,11 +330,13 @@ impl Perform for Oper<EditComment> {
local: read_comment.local,
};
- let _updated_comment = match Comment::update(&conn, data.edit_id, &comment_form) {
+ let updated_comment = match Comment::update(&conn, data.edit_id, &comment_form) {
Ok(comment) => comment,
Err(_e) => return Err(APIError::err("couldnt_update_comment").into()),
};
+ updated_comment.send_update(&user, &conn)?;
+
let mut recipient_ids = Vec::new();
// Scan the comment for user mentions, add those rows