X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fweb%2Fnotification%2FNotificationHandlerModule.kt;h=74c9f432c85871181f0d525d2f78c4954f412076;hb=2ec60e8d6d2efadd7b4d35de3c3d257a0bc5f190;hp=0d7bb2561aa65980f155b48d5c8fa7534d6e147d;hpb=439fb3dfa1ccf157388a0e0b306013d0aa46bb50;p=Sone.git 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 0d7bb25..74c9f43 100644 --- a/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt +++ b/src/main/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModule.kt @@ -21,11 +21,12 @@ 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.util.notify.* import java.util.concurrent.* -import java.util.concurrent.Executors.* +import java.util.concurrent.TimeUnit.* import java.util.function.* import javax.inject.* import javax.inject.Singleton @@ -48,6 +49,7 @@ class NotificationHandlerModule : AbstractModule() { bind().asSingleton() bind().asSingleton() bind().asSingleton() + bind().asSingleton() } @Provides @@ -124,6 +126,24 @@ class NotificationHandlerModule : AbstractModule() { 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) } + private inline fun bind(): AnnotatedBindingBuilder = bind(T::class.java) private fun ScopedBindingBuilder.asSingleton() = `in`(Singleton::class.java)