Move exists delay to send service

pull/184/head
M66B 4 years ago
parent 6c9ac31189
commit cde1d928a6

@ -132,7 +132,6 @@ import static javax.mail.Folder.READ_WRITE;
class Core {
private static final int MAX_NOTIFICATION_COUNT = 10; // per group
private static final long AFTER_SEND_DELAY = 20 * 1000L; // milliseconds
private static final int SYNC_CHUNCK_SIZE = 200;
private static final int SYNC_BATCH_SIZE = 20;
private static final int DOWNLOAD_BATCH_SIZE = 20;
@ -1443,19 +1442,6 @@ class Core {
if (message.msgid == null)
throw new IllegalArgumentException("exists without msgid");
if (EntityFolder.SENT.equals(folder.type)) {
long ago = new Date().getTime() - op.created;
long delay = AFTER_SEND_DELAY - ago;
if (delay > 0) {
Log.i(folder.name + " send delay=" + delay);
try {
Thread.sleep(delay);
} catch (InterruptedException ex) {
Log.w(ex);
}
}
}
Message[] imessages = ifolder.search(new MessageIDTerm(message.msgid));
if (imessages == null || imessages.length == 0)
try {

@ -80,6 +80,7 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
private static final int PI_SEND = 1;
private static final int RETRY_MAX = 3;
private static final int CONNECTIVITY_DELAY = 5000; // milliseconds
private static final long EXISTS_DELAY = 20 * 1000L; // milliseconds
@Override
public void onCreate() {
@ -634,13 +635,6 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
EntityOperation.queue(this, forwarded, EntityOperation.KEYWORD, "$Forwarded", true);
}
// Check sent message
if (sid != null) {
// Check for sent orphans
EntityMessage orphan = db.message().getMessage(sid);
EntityOperation.queue(this, orphan, EntityOperation.EXISTS);
}
// Reset identity
db.identity().setIdentityConnected(ident.id, new Date().getTime());
db.identity().setIdentityError(ident.id, null);
@ -650,10 +644,34 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
db.endTransaction();
}
ServiceSynchronize.eval(ServiceSend.this, "sent");
ServiceSynchronize.eval(this, "sent");
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel("send:" + message.id, 1);
// Check sent message
if (sid != null) {
try {
Thread.sleep(EXISTS_DELAY);
} catch (InterruptedException ex) {
Log.e(ex);
}
try {
db.beginTransaction();
// Message could have been deleted
EntityMessage orphan = db.message().getMessage(sid);
if (orphan != null)
EntityOperation.queue(this, orphan, EntityOperation.EXISTS);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
ServiceSynchronize.eval(this, "orphan");
}
} catch (MessagingException ex) {
Log.e(ex);

Loading…
Cancel
Save