✨ Send event when Sone is locked on startup
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 29 Nov 2019 10:58:52 +0000 (11:58 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 29 Nov 2019 17:27:08 +0000 (18:27 +0100)
src/main/java/net/pterodactylus/sone/core/Core.java
src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedOnStartup.kt [new file with mode: 0644]

index d53e33d..0228951 100644 (file)
@@ -638,6 +638,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider,
                if (sone.getPosts().isEmpty() && sone.getReplies().isEmpty() && getAllImages(sone.getRootAlbum()).isEmpty()) {
                        // dirty hack
                        lockSone(sone);
+                       eventBus.post(new SoneLockedOnStartup(sone));
                }
                soneInserter.start();
                return sone;
diff --git a/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedOnStartup.kt b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedOnStartup.kt
new file mode 100644 (file)
index 0000000..21c5738
--- /dev/null
@@ -0,0 +1,25 @@
+/**
+ * Sone - SoneLockedOnStartup.kt - Copyright © 2019 David ‘Bombe’ Roden
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.pterodactylus.sone.core.event
+
+import net.pterodactylus.sone.data.*
+
+/**
+ * Signals that a Sone was locked on startup because it’s empty.
+ */
+class SoneLockedOnStartup(sone: Sone) : SoneEvent(sone)