🚧 Use ticker from Sone module for notifications
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / web / notification / NotificationHandlerModule.kt
index c75cbc1..0d7bb25 100644 (file)
@@ -24,6 +24,7 @@ import net.pterodactylus.sone.data.*
 import net.pterodactylus.sone.main.*
 import net.pterodactylus.sone.notify.*
 import net.pterodactylus.util.notify.*
+import java.util.concurrent.*
 import java.util.concurrent.Executors.*
 import java.util.function.*
 import javax.inject.*
@@ -40,6 +41,13 @@ class NotificationHandlerModule : AbstractModule() {
                bind<SoneLockedOnStartupHandler>().asSingleton()
                bind<NewSoneHandler>().asSingleton()
                bind<NewRemotePostHandler>().asSingleton()
+               bind<SoneLockedHandler>().asSingleton()
+               bind<LocalPostHandler>().asSingleton()
+               bind<NewVersionHandler>().asSingleton()
+               bind<ImageInsertHandler>().asSingleton()
+               bind<FirstStartHandler>().asSingleton()
+               bind<ConfigNotReadHandler>().asSingleton()
+               bind<StartupHandler>().asSingleton()
        }
 
        @Provides
@@ -70,8 +78,51 @@ class NotificationHandlerModule : AbstractModule() {
 
        @Provides
        @Singleton
-       fun getSoneLockedHandler(notificationManager: NotificationManager, @Named("soneLocked") soneLockedNotification: ListNotification<Sone>) =
-                       SoneLockedHandler(notificationManager, soneLockedNotification, newScheduledThreadPool(1))
+       @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"))
+
+       @Provides
+       @Singleton
+       @Named("imageInserting")
+       fun getImageInsertingNotification(loaders: Loaders) =
+                       ListNotification<Image>("inserting-images-notification", "images", loaders.loadTemplate("/templates/notify/inserting-images-notification.html"), dismissable = true)
+
+       @Provides
+       @Singleton
+       @Named("imageFailed")
+       fun getImageInsertingFailedNotification(loaders: Loaders) =
+                       ListNotification<Image>("image-insert-failed-notification", "images", loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html"), dismissable = true)
+
+       @Provides
+       @Singleton
+       @Named("imageInserted")
+       fun getImageInsertedNotification(loaders: Loaders) =
+                       ListNotification<Image>("inserted-images-notification", "images", loaders.loadTemplate("/templates/notify/inserted-images-notification.html"), dismissable = true)
+
+       @Provides
+       @Singleton
+       @Named("firstStart")
+       fun getFirstStartNotification(loaders: Loaders) =
+                       TemplateNotification("first-start-notification", loaders.loadTemplate("/templates/notify/firstStartNotification.html"))
+
+       @Provides
+       @Singleton
+       @Named("configNotRead")
+       fun getConfigNotReadNotification(loaders: Loaders) =
+                       TemplateNotification("config-not-read-notification", loaders.loadTemplate("/templates/notify/configNotReadNotification.html"))
+
+       @Provides
+       @Singleton
+       @Named("startup")
+       fun getStartupNotification(loaders: Loaders) =
+                       TemplateNotification("startup-notification", loaders.loadTemplate("/templates/notify/startupNotification.html"))
 
        private inline fun <reified T> bind(): AnnotatedBindingBuilder<T> = bind(T::class.java)
        private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)