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:
@@ -15,7 +15,7 @@ use medias::Media;
|
||||
use mentions::Mention;
|
||||
use notifications::*;
|
||||
use plume_common::activity_pub::{
|
||||
inbox::{AsObject, FromId},
|
||||
inbox::{AsActor, AsObject, FromId},
|
||||
Id, IntoId, PUBLIC_VISIBILITY,
|
||||
};
|
||||
use plume_common::utils;
|
||||
@@ -157,14 +157,20 @@ impl Comment {
|
||||
|
||||
pub fn notify(&self, conn: &Connection) -> Result<()> {
|
||||
for author in self.get_post(conn)?.get_authors(conn)? {
|
||||
Notification::insert(
|
||||
conn,
|
||||
NewNotification {
|
||||
kind: notification_kind::COMMENT.to_string(),
|
||||
object_id: self.id,
|
||||
user_id: author.id,
|
||||
},
|
||||
)?;
|
||||
if Mention::list_for_comment(conn, self.id)?
|
||||
.iter()
|
||||
.all(|m| m.get_mentioned(conn).map(|u| u != author).unwrap_or(true))
|
||||
&& author.is_local()
|
||||
{
|
||||
Notification::insert(
|
||||
conn,
|
||||
NewNotification {
|
||||
kind: notification_kind::COMMENT.to_string(),
|
||||
object_id: self.id,
|
||||
user_id: author.id,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user