mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-29 03:07:47 +00:00
fix open group spam
This commit is contained in:
parent
747a27ddda
commit
f13b5ab9d7
@ -206,10 +206,8 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
|
||||
poller.setCaughtUp(false);
|
||||
}
|
||||
startPollingIfNeeded();
|
||||
// FIXME: Open group handling
|
||||
/*
|
||||
publicChatManager.markAllAsNotCaughtUp();
|
||||
*/
|
||||
|
||||
OpenGroupManager.INSTANCE.markAllAsNotCaughtUp();
|
||||
OpenGroupManager.INSTANCE.startPolling();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,22 @@ object OpenGroupManager {
|
||||
private var pollers = mutableMapOf<String, OpenGroupPollerV2>() // One for each server
|
||||
private var isPolling = false
|
||||
|
||||
val isAllCaughtUp: Boolean
|
||||
get() {
|
||||
pollers.values.forEach { poller ->
|
||||
if (!poller.isCaughtUp) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun markAllAsNotCaughtUp() {
|
||||
pollers.values.forEach { poller ->
|
||||
poller.isCaughtUp = false
|
||||
}
|
||||
}
|
||||
|
||||
fun startPolling() {
|
||||
if (isPolling) { return }
|
||||
isPolling = true
|
||||
|
@ -12,6 +12,7 @@ import org.session.libsession.utilities.recipients.Recipient;
|
||||
import org.session.libsession.utilities.Debouncer;
|
||||
import org.session.libsignal.utilities.ThreadUtils;
|
||||
import org.thoughtcrime.securesms.ApplicationContext;
|
||||
import org.thoughtcrime.securesms.loki.api.OpenGroupManager;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -42,18 +43,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@Override
|
||||
public void updateNotification(@NonNull Context context) {
|
||||
Poller poller = ApplicationContext.getInstance(context).poller;
|
||||
// FIXME: Open group handling
|
||||
boolean isCaughtUp = true;
|
||||
if (poller != null) {
|
||||
isCaughtUp = isCaughtUp && poller.isCaughtUp();
|
||||
}
|
||||
|
||||
// FIXME: Open group handling
|
||||
/*
|
||||
if (publicChatManager != null) {
|
||||
isCaughtUp = isCaughtUp && publicChatManager.areAllCaughtUp();
|
||||
}
|
||||
*/
|
||||
isCaughtUp = isCaughtUp && OpenGroupManager.INSTANCE.isAllCaughtUp();
|
||||
|
||||
if (isCaughtUp) {
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context));
|
||||
@ -65,18 +60,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@Override
|
||||
public void updateNotification(@NonNull Context context, long threadId) {
|
||||
Poller lokiPoller = ApplicationContext.getInstance(context).poller;
|
||||
// FIXME: Open group handling
|
||||
boolean isCaughtUp = true;
|
||||
if (lokiPoller != null) {
|
||||
isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp();
|
||||
}
|
||||
|
||||
// FIXME: Open group handling
|
||||
/*
|
||||
if (publicChatManager != null) {
|
||||
isCaughtUp = isCaughtUp && publicChatManager.areAllCaughtUp();
|
||||
}
|
||||
*/
|
||||
isCaughtUp = isCaughtUp && OpenGroupManager.INSTANCE.isAllCaughtUp();
|
||||
|
||||
if (isCaughtUp) {
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId));
|
||||
@ -88,18 +77,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@Override
|
||||
public void updateNotification(@NonNull Context context, long threadId, boolean signal) {
|
||||
Poller lokiPoller = ApplicationContext.getInstance(context).poller;
|
||||
// FIXME: Open group handling
|
||||
boolean isCaughtUp = true;
|
||||
if (lokiPoller != null) {
|
||||
isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp();
|
||||
}
|
||||
|
||||
// FIXME: Open group handling
|
||||
/*
|
||||
if (publicChatManager != null) {
|
||||
isCaughtUp = isCaughtUp && publicChatManager.areAllCaughtUp();
|
||||
}
|
||||
*/
|
||||
isCaughtUp = isCaughtUp && OpenGroupManager.INSTANCE.isAllCaughtUp();
|
||||
|
||||
if (isCaughtUp) {
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, threadId, signal));
|
||||
@ -111,18 +94,12 @@ public class OptimizedMessageNotifier implements MessageNotifier {
|
||||
@Override
|
||||
public void updateNotification(@androidx.annotation.NonNull Context context, boolean signal, int reminderCount) {
|
||||
Poller lokiPoller = ApplicationContext.getInstance(context).poller;
|
||||
// FIXME: Open group handling
|
||||
boolean isCaughtUp = true;
|
||||
if (lokiPoller != null) {
|
||||
isCaughtUp = isCaughtUp && lokiPoller.isCaughtUp();
|
||||
}
|
||||
|
||||
// FIXME: Open group handling
|
||||
/*
|
||||
if (publicChatManager != null) {
|
||||
isCaughtUp = isCaughtUp && publicChatManager.areAllCaughtUp();
|
||||
}
|
||||
*/
|
||||
isCaughtUp = isCaughtUp && OpenGroupManager.INSTANCE.isAllCaughtUp();
|
||||
|
||||
if (isCaughtUp) {
|
||||
performOnBackgroundThreadIfNeeded(() -> wrapped.updateNotification(context, signal, reminderCount));
|
||||
|
@ -18,6 +18,7 @@ import java.util.concurrent.TimeUnit
|
||||
|
||||
class OpenGroupPollerV2(private val server: String, private val executorService: ScheduledExecutorService?) {
|
||||
var hasStarted = false
|
||||
var isCaughtUp = false
|
||||
private var future: ScheduledFuture<*>? = null
|
||||
|
||||
companion object {
|
||||
@ -44,6 +45,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
|
||||
handleNewMessages(openGroupID, response.messages, isBackgroundPoll)
|
||||
handleDeletedMessages(openGroupID, response.deletions)
|
||||
}
|
||||
isCaughtUp = true
|
||||
}.always {
|
||||
executorService?.schedule(this@OpenGroupPollerV2::poll, OpenGroupPollerV2.pollInterval, TimeUnit.MILLISECONDS)
|
||||
}.map { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user