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>>()