🐛 Fix new-remote-post handler
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / notification / NewRemotePostHandler.kt
index acf9980..0c2368a 100644 (file)
@@ -22,18 +22,21 @@ import net.pterodactylus.sone.core.event.*
 import net.pterodactylus.sone.data.*
 import net.pterodactylus.sone.notify.*
 import net.pterodactylus.util.notify.*
+import javax.inject.*
 
 /**
  * Handler for [NewPostFoundEvent]s that adds the new post to the â€œnew posts” notification and
  * displays the notification if the â€œfirst start” notification is not being shown.
  */
-class NewRemotePostHandler(private val notificationManager: NotificationManager, private val notification: ListNotification<Post>) {
+class NewRemotePostHandler @Inject constructor(private val notificationManager: NotificationManager, @Named("newRemotePost") private val notification: ListNotification<Post>) {
 
        @Subscribe
        fun newPostFound(newPostFoundEvent: NewPostFoundEvent) {
-               notification.add(newPostFoundEvent.post)
-               if (!notificationManager.hasFirstStartNotification()) {
-                       notificationManager.addNotification(notification)
+               if (!newPostFoundEvent.post.sone.isLocal) {
+                       notification.add(newPostFoundEvent.post)
+                       if (!notificationManager.hasFirstStartNotification()) {
+                               notificationManager.addNotification(notification)
+                       }
                }
        }