import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.sone.template.SubstringFilter;
import net.pterodactylus.sone.template.TrustAccessor;
+import net.pterodactylus.sone.template.UniqueElementFilter;
import net.pterodactylus.sone.template.UnknownDateFilter;
import net.pterodactylus.sone.text.Part;
import net.pterodactylus.sone.text.SonePart;
/** The “you have been mentioned” notification. */
private final ListNotification<Post> mentionNotification;
- /** The “rescuing Sone” notification. */
- private final ListNotification<Sone> rescuingSonesNotification;
-
- /** The “Sone rescued” notification. */
- private final ListNotification<Sone> sonesRescuedNotification;
-
/** Notifications for sone inserts. */
private final Map<Sone, TemplateNotification> soneInsertNotifications = new HashMap<Sone, TemplateNotification>();
templateContextFactory.addFilter("sort", new CollectionSortFilter());
templateContextFactory.addFilter("replyGroup", new ReplyGroupFilter());
templateContextFactory.addFilter("in", new ContainsFilter());
+ templateContextFactory.addFilter("unique", new UniqueElementFilter());
templateContextFactory.addProvider(Provider.TEMPLATE_CONTEXT_PROVIDER);
templateContextFactory.addProvider(new ClassPathTemplateProvider());
templateContextFactory.addTemplateObject("webInterface", this);
Template mentionNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/mentionNotification.html"));
mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);
- Template rescuingSonesTemplate = TemplateParser.parse(createReader("/templates/notify/rescuingSonesNotification.html"));
- rescuingSonesNotification = new ListNotification<Sone>("sones-being-rescued-notification", "sones", rescuingSonesTemplate);
-
- Template sonesRescuedTemplate = TemplateParser.parse(createReader("/templates/notify/sonesRescuedNotification.html"));
- sonesRescuedNotification = new ListNotification<Sone>("sones-rescued-notification", "sones", sonesRescuedTemplate);
-
Template lockedSonesTemplate = TemplateParser.parse(createReader("/templates/notify/lockedSonesNotification.html"));
lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);
TemplateNotification templateNotification = soneInsertNotifications.get(sone);
if (templateNotification == null) {
templateNotification = new TemplateNotification(TemplateParser.parse(createReader("/templates/notify/soneInsertNotification.html")));
- templateNotification.set("sone", sone);
+ templateNotification.set("insertSone", sone);
soneInsertNotifications.put(sone, templateNotification);
}
return templateNotification;
* {@inheritDoc}
*/
@Override
- public void rescuingSone(Sone sone) {
- rescuingSonesNotification.add(sone);
- notificationManager.addNotification(rescuingSonesNotification);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void rescuedSone(Sone sone) {
- rescuingSonesNotification.remove(sone);
- sonesRescuedNotification.add(sone);
- notificationManager.addNotification(sonesRescuedNotification);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
public void newSoneFound(Sone sone) {
newSoneNotification.add(sone);
if (!hasFirstStartNotification()) {
public void soneInserting(Sone sone) {
TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
soneInsertNotification.set("soneStatus", "inserting");
- notificationManager.addNotification(soneInsertNotification);
+ if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ notificationManager.addNotification(soneInsertNotification);
+ }
}
/**
TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
soneInsertNotification.set("soneStatus", "inserted");
soneInsertNotification.set("insertDuration", insertDuration / 1000);
- notificationManager.addNotification(soneInsertNotification);
+ if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ notificationManager.addNotification(soneInsertNotification);
+ }
}
/**
*/
@Override
public void soneInsertAborted(Sone sone, Throwable cause) {
- notificationManager.addNotification(getSoneInsertNotification(sone).set("soneStatus", "insert-aborted").set("insert-error", cause));
+ TemplateNotification soneInsertNotification = getSoneInsertNotification(sone);
+ soneInsertNotification.set("soneStatus", "insert-aborted");
+ soneInsertNotification.set("insert-error", cause);
+ if (sone.getOptions().getBooleanOption("EnableSoneInsertNotifications").get()) {
+ notificationManager.addNotification(soneInsertNotification);
+ }
}
/**