🚧 Use handler for new-reply notifications
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / notification / NotificationHandlerModule.kt
index 96a7cdf..4a91fc7 100644 (file)
@@ -40,9 +40,11 @@ class NotificationHandlerModule : AbstractModule() {
        override fun configure() {
                bind(NotificationHandler::class.java).`in`(Singleton::class.java)
                bind<MarkPostKnownDuringFirstStartHandler>().asSingleton()
+               bind<MarkPostReplyKnownDuringFirstStartHandler>().asSingleton()
                bind<SoneLockedOnStartupHandler>().asSingleton()
                bind<NewSoneHandler>().asSingleton()
                bind<NewRemotePostHandler>().asSingleton()
+               bind<RemotePostReplyHandler>().asSingleton()
                bind<SoneLockedHandler>().asSingleton()
                bind<LocalPostHandler>().asSingleton()
                bind<NewVersionHandler>().asSingleton()
@@ -52,12 +54,16 @@ class NotificationHandlerModule : AbstractModule() {
                bind<StartupHandler>().asSingleton()
                bind<WebOfTrustHandler>().asSingleton()
                bind<SoneMentionDetector>().asSingleton()
+               bind<SoneMentionedHandler>().asSingleton()
        }
 
        @Provides
        fun getMarkPostKnownHandler(core: Core): Consumer<Post> = Consumer { core.markPostKnown(it) }
 
        @Provides
+       fun getMarkPostReplyKnownHandler(core: Core): Consumer<PostReply> = Consumer { core.markReplyKnown(it) }
+
+       @Provides
        @Singleton
        @Named("soneLockedOnStartup")
        fun getSoneLockedOnStartupNotification(loaders: Loaders) =
@@ -76,6 +82,12 @@ class NotificationHandlerModule : AbstractModule() {
 
        @Provides
        @Singleton
+       @Named("newRemotePostReply")
+       fun getNewRemotePostReplyNotification(loaders: Loaders) =
+                       ListNotification<PostReply>("new-reply-notification", "replies", loaders.loadTemplate("/templates/notify/newReplyNotification.html"), dismissable = false)
+
+       @Provides
+       @Singleton
        @Named("soneLocked")
        fun getSoneLockedNotification(loaders: Loaders) =
                        ListNotification<Sone>("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true)
@@ -146,6 +158,12 @@ class NotificationHandlerModule : AbstractModule() {
        fun getWebOfTrustReschedule(@Named("notification") ticker: ScheduledExecutorService) =
                        Consumer<Runnable> { ticker.schedule(it, 15, SECONDS) }
 
+       @Provides
+       @Singleton
+       @Named("soneMentioned")
+       fun getSoneMentionedNotification(loaders: Loaders) =
+                       ListNotification<Post>("mention-notification", "posts", loaders.loadTemplate("/templates/notify/mentionNotification.html"), dismissable = false)
+
        private inline fun <reified T> bind(): AnnotatedBindingBuilder<T> = bind(T::class.java)
        private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)