discord-jadx/app/src/main/java/com/discord/workers/MessageAckWorker.java

94 lines
4.5 KiB
Java

package com.discord.workers;
import android.content.Context;
import androidx.work.Data;
import androidx.work.ListenableWorker;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import com.discord.app.AppLog;
import com.discord.restapi.RestAPIParams;
import com.discord.stores.StoreStream;
import com.discord.utilities.fcm.NotificationClient;
import com.discord.utilities.io.NetworkUtils;
import com.discord.utilities.logging.Logger;
import com.discord.utilities.rest.RestAPI;
import d0.z.d.m;
import j0.m.b;
import java.util.Objects;
import rx.Observable;
/* compiled from: MessageAckWorker.kt */
public final class MessageAckWorker extends Worker {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public MessageAckWorker(Context context, WorkerParameters workerParameters) {
super(context, workerParameters);
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(workerParameters, "params");
}
@Override // androidx.work.Worker
public ListenableWorker.Result doWork() {
long j;
long j2;
Throwable th;
AppLog appLog = AppLog.g;
String simpleName = MessageAckWorker.class.getSimpleName();
m.checkNotNullExpressionValue(simpleName, "javaClass.simpleName");
StringBuilder sb = new StringBuilder();
sb.append("Starting for [");
Data inputData = getInputData();
m.checkNotNullExpressionValue(inputData, "inputData");
sb.append(inputData.getKeyValueMap());
sb.append(']');
Logger.i$default(appLog, simpleName, sb.toString(), null, 4, null);
NotificationClient notificationClient = NotificationClient.INSTANCE;
if (!notificationClient.isAuthed()) {
String simpleName2 = MessageAckWorker.class.getSimpleName();
m.checkNotNullExpressionValue(simpleName2, "javaClass.simpleName");
Logger.d$default(appLog, simpleName2, "Not authenticated. Aborting job request.", null, 4, null);
ListenableWorker.Result failure = ListenableWorker.Result.failure();
m.checkNotNullExpressionValue(failure, "Result.failure()");
return failure;
}
NetworkUtils networkUtils = NetworkUtils.INSTANCE;
Context applicationContext = getApplicationContext();
m.checkNotNullExpressionValue(applicationContext, "applicationContext");
if (!NetworkUtils.isDeviceConnected$default(networkUtils, applicationContext, null, null, 6, null)) {
ListenableWorker.Result retry = ListenableWorker.Result.retry();
m.checkNotNullExpressionValue(retry, "Result.retry()");
return retry;
}
long j3 = getInputData().getLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", -1);
long j4 = getInputData().getLong("com.discord.intent.extra.EXTRA_MESSAGE_ID", -1);
try {
Observable<Void> postChannelMessagesAck = RestAPI.Companion.getApi().postChannelMessagesAck(j3, Long.valueOf(j4), new RestAPIParams.ChannelMessagesAck(Boolean.FALSE, 0));
Objects.requireNonNull(postChannelMessagesAck);
new b(postChannelMessagesAck).a();
String simpleName3 = getClass().getSimpleName();
m.checkNotNullExpressionValue(simpleName3, "javaClass.simpleName");
Logger.d$default(appLog, simpleName3, "Marked as read: " + j3 + '-' + j4, null, 4, null);
j = j4;
j2 = j3;
try {
NotificationClient.clear$default(notificationClient, j3, getApplicationContext(), false, 4, null);
StoreStream.Companion.getAnalytics().ackMessage(j2);
ListenableWorker.Result success = ListenableWorker.Result.success();
m.checkNotNullExpressionValue(success, "Result.success()");
return success;
} catch (Throwable th2) {
th = th2;
}
} catch (Throwable th3) {
th = th3;
j = j4;
j2 = j3;
AppLog appLog2 = AppLog.g;
String simpleName4 = MessageAckWorker.class.getSimpleName();
m.checkNotNullExpressionValue(simpleName4, "javaClass.simpleName");
appLog2.w(simpleName4, "Marked as read failure: " + j2 + '-' + j, th);
ListenableWorker.Result retry2 = getRunAttemptCount() < 5 ? ListenableWorker.Result.retry() : ListenableWorker.Result.failure();
m.checkNotNullExpressionValue(retry2, "if (runAttemptCount < MA…y() else Result.failure()");
return retry2;
}
}
}