@@ -47,10 +47,6 @@ public final class HelpThreadCreatedListener extends ListenerAdapter
4747 private static final Logger log = LoggerFactory .getLogger (HelpThreadCreatedListener .class );
4848 private final HelpSystemHelper helper ;
4949
50- private static final String MARK_ACTIVE_ID = "mark-active" ;
51- private final ComponentIdInteractor inactivityInteractor =
52- new ComponentIdInteractor (UserInteractionType .OTHER , "thread-inactivity" );
53-
5450 private final Cache <Long , Instant > threadIdToCreatedAtCache = Caffeine .newBuilder ()
5551 .maximumSize (1_000 )
5652 .expireAfterAccess (2 , TimeUnit .of (ChronoUnit .MINUTES ))
@@ -191,16 +187,14 @@ private Consumer<Throwable> handleParentMessageDeleted(Member user, ThreadChanne
191187
192188 @ Override
193189 public void onButtonClick (ButtonInteractionEvent event , List <String > args ) {
194- // Check if the button belongs to the "thread-inactivity" namespace
195- if (inactivityInteractor .isMatch (event .getComponentId ())) {
196- String subId = inactivityInteractor .getComponentId (event .getComponentId ());
197-
198- if (subId .equals ("mark-active" )) {
199- handleMarkActiveInteraction (event );
200- return ; // EXIT: This logic is owned by handleMarkActiveInteraction
201- }
190+ if (args .contains ("mark-active" )) {
191+ onInactivityButton (event );
192+ } else {
193+ onAiHelpDismissButton (event , args );
202194 }
203- // Handle chatgpt's automatic response "dismiss" button
195+ }
196+
197+ private void onAiHelpDismissButton (ButtonInteractionEvent event , List <String > args ) {
204198 event .deferEdit ().queue ();
205199
206200 ThreadChannel channel = event .getChannel ().asThreadChannel ();
@@ -210,7 +204,6 @@ public void onButtonClick(ButtonInteractionEvent event, List<String> args) {
210204 .queue (forumPostMessage -> handleDismiss (interactionUser , channel , forumPostMessage ,
211205 event , args ),
212206 handleParentMessageDeleted (interactionUser , channel , event , args ));
213-
214207 }
215208
216209 private boolean isPostAuthor (Member interactionUser , Message message ) {
@@ -262,16 +255,18 @@ private void registerThreadDataInDB(Message message, ThreadChannel threadChannel
262255 helper .writeHelpThreadToDatabase (authorId , threadChannel );
263256 }
264257
265- private void handleMarkActiveInteraction (ButtonInteractionEvent event ) {
258+ private void onInactivityButton (ButtonInteractionEvent event ) {
266259 event .deferEdit ().queue ();
267260
268261 if (event .getChannel () instanceof ThreadChannel thread ) {
269- // Reopen the thread so people can chat, then delete the bot's warning
270- thread .getManager ().setArchived (false ).queue ();
271- event .getMessage ().delete ().queue ();
262+ Message botClosedThreadMessage = event .getMessage ();
263+
264+ thread .getManager ().setArchived (false )
265+ .flatMap (v -> botClosedThreadMessage .delete ())
266+ .queue ();
272267
273- log .info ("Thread {} was manually reactivated via button by {}" ,
274- thread .getId (), event .getUser ().getName ());
268+ log .debug ("Thread {} was manually reactivated via button by {}" ,
269+ thread .getId (), event .getUser ().getId ());
275270 }
276271 }
277272}
0 commit comments