[AB-109] fixing streamers not being marked online if the post target is disabled

This commit is contained in:
Sheldan
2023-12-25 01:00:54 +01:00
parent befef1f61d
commit 8e6339a99b

View File

@@ -400,24 +400,38 @@ public class StreamerServiceBean implements StreamerService {
} }
streamer.setCurrentGameId(stream.getGameId()); streamer.setCurrentGameId(stream.getGameId());
} }
return; } else if(currentSession == null &&
!postTargetService.postTargetUsableInServer(TwitchPostTarget.TWITCH_LIVE_NOTIFICATION, server.getId())) {
// this is the case in which the streamer is online, and we should in theory notify about the online status
// _but_ the difference is that there is no current session on going - as the sessions in our database are
// bound to actual notifications sent, and this is the case in which the post target has been disabled.
// In this case we only update current game if necessary
// this only really serves as a shortcut to not evaluate and create a full MessageToSend object
// just to not actually send it
if(streamer.getCurrentGameId() == null || !streamer.getCurrentGameId().equals(stream.getGameId())) {
log.info("Game for streamer {} has changed - updating game.", streamerId);
streamer.setCurrentGameId(stream.getGameId());
} }
streamer.setOnline(true);
streamerManagementService.saveStreamer(streamer);
} else {
CompletableFutureList<Message> messages = notifyAboutOnlineStream(stream, streamer, streamerUser); CompletableFutureList<Message> messages = notifyAboutOnlineStream(stream, streamer, streamerUser);
messages.getMainFuture() messages.getMainFuture()
.thenAccept(unused -> { .thenAccept(unused -> {
Message message = messages.getFutures().get(0).join(); Message message = messages.getFutures().get(0).join();
if(message != null) {
try { try {
if(message != null) {
self.storeStreamNotificationMessage(message, streamerId, stream); self.storeStreamNotificationMessage(message, streamerId, stream);
} catch (Exception exception) {
log.error("Failed to store stream notification message of streamer {}.", streamerId, exception);
} }
} catch (Exception exception) {
log.error("Failed to update streamer {} in database.", streamerId, exception);
} }
}).exceptionally(throwable -> { }).exceptionally(throwable -> {
log.error("Failed to notify about online stream of streamer {}.", streamerId, throwable); log.error("Failed to notify about online stream of streamer {}.", streamerId, throwable);
return null; return null;
}); });
} }
}
@Transactional @Transactional
public void storeStreamNotificationMessage(Message message, Long streamerId, Stream stream) { public void storeStreamNotificationMessage(Message message, Long streamerId, Stream stream) {