Make sure answers are being sent

pull/174/head
M66B 5 years ago
parent d7fc63aa77
commit 9df27c1240

@ -104,6 +104,8 @@ public class EntityRule {
static final String EXTRA_SENDER = "sender";
static final String EXTRA_SUBJECT = "subject";
private static final long SEND_DELAY = 5000L; // milliseconds
boolean matches(Context context, EntityMessage message, Message imessage) throws MessagingException {
try {
JSONObject jcondition = new JSONObject(condition);
@ -422,6 +424,9 @@ public class EntityRule {
EntityOperation.queue(context, reply, EntityOperation.SEND);
// Batch send operations, wait until after commit
ServiceSend.schedule(context, SEND_DELAY);
return true;
}

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2020 by Marcel Bokhorst (M66B)
*/
import android.app.AlarmManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@ -34,6 +35,7 @@ import android.os.PowerManager;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import androidx.core.app.AlarmManagerCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.lifecycle.Observer;
@ -67,6 +69,7 @@ public class ServiceSend extends ServiceBase {
private PowerManager.WakeLock wlOutbox;
private ExecutorService executor = Helper.getBackgroundExecutor(1, "send");
private static final int PI_SEND = 1;
private static final int IDENTITY_ERROR_AFTER = 30; // minutes
@Override
@ -542,6 +545,17 @@ public class ServiceSend extends ServiceBase {
new Intent(context, ServiceSend.class));
}
static void schedule(Context context, long delay) {
Intent intent = new Intent(context, ServiceSend.class);
PendingIntent pi = PendingIntentCompat.getForegroundService(
context, PI_SEND, intent, PendingIntent.FLAG_UPDATE_CURRENT);
long trigger = System.currentTimeMillis() + delay;
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(pi);
AlarmManagerCompat.setAndAllowWhileIdle(am, AlarmManager.RTC_WAKEUP, trigger, pi);
}
static void watchdog(Context context) {
boot(context);
}

Loading…
Cancel
Save