♻️ Extract new-version notification handler
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / notification / NotificationHandlerModule.kt
index 7918758..09cf0cb 100644 (file)
@@ -23,6 +23,7 @@ import net.pterodactylus.sone.core.*
 import net.pterodactylus.sone.data.*
 import net.pterodactylus.sone.main.*
 import net.pterodactylus.sone.notify.*
+import net.pterodactylus.util.notify.*
 import java.util.concurrent.Executors.*
 import java.util.function.*
 import javax.inject.*
@@ -40,6 +41,8 @@ class NotificationHandlerModule : AbstractModule() {
                bind<NewSoneHandler>().asSingleton()
                bind<NewRemotePostHandler>().asSingleton()
                bind<SoneLockedHandler>().asSingleton()
+               bind<LocalPostHandler>().asSingleton()
+               bind<NewVersionHandler>().asSingleton()
        }
 
        @Provides
@@ -72,6 +75,18 @@ class NotificationHandlerModule : AbstractModule() {
        fun getScheduledExecutorService() =
                        newScheduledThreadPool(1)
 
+       @Provides
+       @Singleton
+       @Named("localPost")
+       fun getLocalPostNotification(loaders: Loaders) =
+                       ListNotification<Post>("local-post-notification", "posts", loaders.loadTemplate("/templates/notify/newPostNotification.html"), dismissable = false)
+
+       @Provides
+       @Singleton
+       @Named("newVersion")
+       fun getNewVersionNotification(loaders: Loaders) =
+                       TemplateNotification("new-version-notification", loaders.loadTemplate("/templates/notify/newVersionNotification.html"))
+
        private inline fun <reified T> bind(): AnnotatedBindingBuilder<T> = bind(T::class.java)
        private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)