X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNotificationHandlerModule.kt;h=2b147fc75105f69cddd8e0c343e29646d67ad5a1;hp=a3c10a6fc4f3cbbe540627665995e5ddbfe130eb;hb=7a4ce0402bb7146ad791fbc52c0cf9b4d6871c91;hpb=b31f0234988a509ca831785c87433ab264374d0a diff --git a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt index a3c10a6..2b147fc 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt @@ -21,10 +21,13 @@ import com.google.inject.* import com.google.inject.binder.* import net.pterodactylus.sone.core.* import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.freenet.wot.* import net.pterodactylus.sone.main.* import net.pterodactylus.sone.notify.* +import net.pterodactylus.sone.text.* import net.pterodactylus.util.notify.* -import java.util.concurrent.Executors.* +import java.util.concurrent.* +import java.util.concurrent.TimeUnit.* import java.util.function.* import javax.inject.* import javax.inject.Singleton @@ -37,6 +40,7 @@ class NotificationHandlerModule : AbstractModule() { override fun configure() { bind(NotificationHandler::class.java).`in`(Singleton::class.java) bind().asSingleton() + bind().asSingleton() bind().asSingleton() bind().asSingleton() bind().asSingleton() @@ -46,12 +50,19 @@ class NotificationHandlerModule : AbstractModule() { bind().asSingleton() bind().asSingleton() bind().asSingleton() + bind().asSingleton() + bind().asSingleton() + bind().asSingleton() + bind().asSingleton() } @Provides fun getMarkPostKnownHandler(core: Core): Consumer = Consumer { core.markPostKnown(it) } @Provides + fun getMarkPostReplyKnownHandler(core: Core): Consumer = Consumer { core.markReplyKnown(it) } + + @Provides @Singleton @Named("soneLockedOnStartup") fun getSoneLockedOnStartupNotification(loaders: Loaders) = @@ -75,10 +86,6 @@ class NotificationHandlerModule : AbstractModule() { ListNotification("sones-locked-notification", "sones", loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"), dismissable = true) @Provides - fun getScheduledExecutorService() = - newScheduledThreadPool(1) - - @Provides @Singleton @Named("localPost") fun getLocalPostNotification(loaders: Loaders) = @@ -120,6 +127,36 @@ class NotificationHandlerModule : AbstractModule() { 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")) + + @Provides + @Singleton + @Named("webOfTrust") + fun getWebOfTrustNotification(loaders: Loaders) = + TemplateNotification("wot-missing-notification", loaders.loadTemplate("/templates/notify/wotMissingNotification.html")) + + @Provides + @Singleton + @Named("webOfTrustReacher") + fun getWebOfTrustReacher(webOfTrustConnector: WebOfTrustConnector): Runnable = + Runnable { webOfTrustConnector.ping() } + + @Provides + @Singleton + @Named("webOfTrustReschedule") + fun getWebOfTrustReschedule(@Named("notification") ticker: ScheduledExecutorService) = + Consumer { ticker.schedule(it, 15, SECONDS) } + + @Provides + @Singleton + @Named("soneMentioned") + fun getSoneMentionedNotification(loaders: Loaders) = + ListNotification("mention-notification", "posts", loaders.loadTemplate("/templates/notify/mentionNotification.html"), dismissable = false) + private inline fun bind(): AnnotatedBindingBuilder = bind(T::class.java) private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)