From 0657ab23058caa513952347a2d46057b951c9e59 Mon Sep 17 00:00:00 2001 From: SessionHero01 <180888785+SessionHero01@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:04:20 +1100 Subject: [PATCH] Polling improvement for group --- .../pollers/ClosedGroupPoller.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt index f13cafaf6a..c6f181591f 100644 --- a/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt +++ b/libsession/src/main/java/org/session/libsession/messaging/sending_receiving/pollers/ClosedGroupPoller.kt @@ -27,6 +27,7 @@ import org.session.libsession.utilities.ConfigFactoryProtocol import org.session.libsession.utilities.ConfigMessage import org.session.libsession.utilities.getClosedGroup import org.session.libsignal.database.LokiAPIDatabaseProtocol +import org.session.libsignal.exceptions.NonRetryableException import org.session.libsignal.utilities.AccountId import org.session.libsignal.utilities.Log import org.session.libsignal.utilities.Namespace @@ -88,7 +89,7 @@ class ClosedGroupPoller( result.isFailure -> { val error = result.exceptionOrNull()!! - if (error is CancellationException) { + if (error is CancellationException || error is NonRetryableException) { throw error } @@ -101,6 +102,9 @@ class ClosedGroupPoller( } } catch (e: CancellationException) { throw e + } catch (e: NonRetryableException) { + Log.e(TAG, "Non-retryable error during group poller", e) + throw e } catch (e: Exception) { Log.e(TAG, "Error during group poller", e) delay(POLL_ERROR_RETRY_DELAY) @@ -131,9 +135,16 @@ class ClosedGroupPoller( } } - val adminKey = requireNotNull(configFactoryProtocol.getClosedGroup(closedGroupSessionId)) { - "Group doesn't exist" - }.adminKey + val group = configFactoryProtocol.getClosedGroup(closedGroupSessionId) + if (group == null) { + throw NonRetryableException("Group doesn't exist") + } + + if (group.kicked) { + throw NonRetryableException("Group has been kicked") + } + + val adminKey = group.adminKey val pollingTasks = mutableListOf>>()