From 6d422fb5879ac6f6211973cf99de9b55f16f1f72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 29 Nov 2019 11:58:52 +0100 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Send=20event=20when=20Sone=20is=20lo?= =?utf8?q?cked=20on=20startup?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../java/net/pterodactylus/sone/core/Core.java | 1 + .../sone/core/event/SoneLockedOnStartup.kt | 25 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedOnStartup.kt diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index d53e33d..0228951 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -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 index 0000000..21c5738 --- /dev/null +++ b/src/main/kotlin/net/pterodactylus/sone/core/event/SoneLockedOnStartup.kt @@ -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 . + */ + +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) -- 2.7.4