Improve notification management (#561)

* Don't notify for comment when mentioned

fix #505

* Don't save notification for remote users

fix #472
This commit is contained in:
fdb-hiroshima
2019-05-04 17:15:41 +02:00
committed by GitHub
parent 918bda14ec
commit c9070930d2
6 changed files with 65 additions and 46 deletions
+11 -9
View File
@@ -4,7 +4,7 @@ use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use notifications::*;
use plume_common::activity_pub::{
inbox::{AsObject, FromId},
inbox::{AsActor, AsObject, FromId},
Id, IntoId, PUBLIC_VISIBILITY,
};
use posts::Post;
@@ -54,14 +54,16 @@ impl Like {
pub fn notify(&self, conn: &Connection) -> Result<()> {
let post = Post::get(conn, self.post_id)?;
for author in post.get_authors(conn)? {
Notification::insert(
conn,
NewNotification {
kind: notification_kind::LIKE.to_string(),
object_id: self.id,
user_id: author.id,
},
)?;
if author.is_local() {
Notification::insert(
conn,
NewNotification {
kind: notification_kind::LIKE.to_string(),
object_id: self.id,
user_id: author.id,
},
)?;
}
}
Ok(())
}