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
+14 -9
View File
@@ -3,6 +3,7 @@ use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use comments::Comment;
use notifications::*;
use plume_common::activity_pub::inbox::AsActor;
use posts::Post;
use schema::mentions;
use users::User;
@@ -129,14 +130,18 @@ impl Mention {
fn notify(&self, conn: &Connection) -> Result<()> {
let m = self.get_mentioned(conn)?;
Notification::insert(
conn,
NewNotification {
kind: notification_kind::MENTION.to_string(),
object_id: self.id,
user_id: m.id,
},
)
.map(|_| ())
if m.is_local() {
Notification::insert(
conn,
NewNotification {
kind: notification_kind::MENTION.to_string(),
object_id: self.id,
user_id: m.id,
},
)
.map(|_| ())
} else {
Ok(())
}
}
}