Signal-Android/src/org/thoughtcrime/securesms/jobs/SendJob.java

50 lines
1.7 KiB
Java
Raw Normal View History

package org.thoughtcrime.securesms.jobs;
2019-06-05 15:47:14 -04:00
import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.database.AttachmentDatabase;
import org.thoughtcrime.securesms.database.DatabaseFactory;
2019-03-28 08:56:35 -07:00
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.logging.Log;
2015-01-02 15:43:28 -08:00
import org.thoughtcrime.securesms.mms.MediaConstraints;
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
import org.thoughtcrime.securesms.util.Util;
import java.util.List;
2015-01-02 15:43:28 -08:00
2019-03-28 08:56:35 -07:00
public abstract class SendJob extends BaseJob {
@SuppressWarnings("unused")
2015-01-02 15:43:28 -08:00
private final static String TAG = SendJob.class.getSimpleName();
2019-03-28 08:56:35 -07:00
public SendJob(Job.Parameters parameters) {
super(parameters);
}
@Override
public final void onRun() throws Exception {
if (Util.getDaysTillBuildExpiry() <= 0) {
throw new TextSecureExpiredException(String.format("TextSecure expired (build %d, now %d)",
BuildConfig.BUILD_TIMESTAMP,
System.currentTimeMillis()));
}
Log.i(TAG, "Starting message send attempt");
onSend();
Log.i(TAG, "Message send completed");
}
protected abstract void onSend() throws Exception;
2015-01-02 15:43:28 -08:00
protected void markAttachmentsUploaded(long messageId, @NonNull List<Attachment> attachments) {
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
for (Attachment attachment : attachments) {
database.markAttachmentUploaded(messageId, attachment);
2015-01-02 15:43:28 -08:00
}
}
}