+ @Named("localPost")
+ fun getLocalPostNotification(loaders: Loaders) =
+ ListNotification<Post>("local-post-notification", "posts", loaders.loadTemplate("/templates/notify/newPostNotification.html"), dismissable = false)
+
+ @Provides
+ @Singleton
+ @Named("localReply")
+ fun getLocalReplyNotification(loaders: Loaders) =
+ ListNotification<PostReply>("local-reply-notification", "replies", loaders.loadTemplate("/templates/notify/newReplyNotification.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"))
+
+ @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<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)
+
+ @Provides
+ @Singleton
+ fun getSoneNotificationSupplier(loaders: Loaders): SoneInsertNotificationSupplier =
+ mutableMapOf<Sone, TemplateNotification>()
+ .let { cache ->
+ { sone ->
+ cache.computeIfAbsent(sone) {
+ loaders.loadTemplate("/templates/notify/soneInsertNotification.html")
+ .let(::TemplateNotification)
+ .also { it["insertSone"] = sone }
+ }
+ }
+ }