package com.discord.utilities.fcm; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import androidx.annotation.RequiresApi; import androidx.core.app.NotificationManagerCompat; import androidx.core.app.RemoteInput; import androidx.work.BackoffPolicy; import androidx.work.Constraints; import androidx.work.Data; import androidx.work.NetworkType; import androidx.work.OneTimeWorkRequest; import androidx.work.WorkManager; import c.d.b.a.a; import com.discord.app.AppLog; import com.discord.app.DiscordConnectService; import com.discord.utilities.logging.Logger; import com.discord.workers.CallActionWorker; import com.discord.workers.MessageAckWorker; import com.discord.workers.MessageSendWorker; import com.discord.workers.TimedMuteWorker; import d0.g0.s; import d0.g0.t; import d0.o; import d0.t.h0; import d0.z.d.m; import java.util.concurrent.TimeUnit; import kotlin.Pair; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: NotificationActions.kt */ public final class NotificationActions extends BroadcastReceiver { public static final Companion Companion = new Companion(null); private static final String NOTIFICATION_CHANNEL_ID = "com.discord.NOTIFICATION_DELETED_CHANNEL_ID"; private static final String NOTIFICATION_ID = "com.discord.NOTIFICATION_ID"; /* compiled from: NotificationActions.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final Intent callAction(Context context, long j, long j2, boolean z2) { m.checkNotNullParameter(context, "context"); String str = z2 ? "accept" : "decline"; return new Intent("com.discord.intent.action.ENQUEUE_WORK", Uri.parse("discord://action/channel/call/" + str + "?channelId=" + j + "&messageId=" + j2), context, NotificationActions.class); } public final Intent cancel(Context context, int i) { m.checkNotNullParameter(context, "context"); Intent putExtra = new Intent("com.discord.intent.action.NOTIFICATION_CANCEL", Uri.parse("discord://action/notif/cancel?id=" + i), context, NotificationActions.class).putExtra("com.discord.NOTIFICATION_ID", i); m.checkNotNullExpressionValue(putExtra, "Intent(\n Intent…ATION_ID, notificationId)"); return putExtra; } public final Intent delete(Context context, long j) { m.checkNotNullParameter(context, "context"); Intent putExtra = new Intent("com.discord.intent.action.NOTIFICATION_DELETED", Uri.parse("discord://action/notif/delete?channelId=" + j), context, NotificationActions.class).putExtra("com.discord.NOTIFICATION_DELETED_CHANNEL_ID", j); m.checkNotNullExpressionValue(putExtra, "Intent(\n Intent…ON_CHANNEL_ID, channelId)"); return putExtra; } public final Intent directReply(Context context, long j, CharSequence charSequence) { m.checkNotNullParameter(context, "context"); Intent intent = new Intent("com.discord.intent.action.ENQUEUE_WORK", Uri.parse("discord://action/message/reply?channelId=" + j), context, NotificationActions.class); intent.putExtra("com.discord.intent.extra.EXTRA_CHANNEL_NAME", charSequence); return intent; } public final Intent markAsRead(Context context, long j, long j2) { m.checkNotNullParameter(context, "context"); return new Intent("com.discord.intent.action.ENQUEUE_WORK", Uri.parse("discord://action/message/ack?channelId=" + j + "&messageId=" + j2), context, NotificationActions.class); } public final Intent timedMute(Context context, long j, long j2, long j3) { m.checkNotNullParameter(context, "context"); return new Intent("com.discord.intent.action.ENQUEUE_WORK", Uri.parse("discord://action/channel/mute").buildUpon().appendQueryParameter("guildId", String.valueOf(j)).appendQueryParameter("channelId", String.valueOf(j2)).appendQueryParameter("until", String.valueOf(j3)).build(), context, NotificationActions.class); } } private final void enqueueAckMessage(Context context, Intent intent) { Long longOrNull; Long longOrNull2; Uri data = intent.getData(); if (data != null) { m.checkNotNullExpressionValue(data, "intent.data ?: return"); String queryParameter = data.getQueryParameter("channelId"); if (queryParameter != null && (longOrNull = s.toLongOrNull(queryParameter)) != null) { long longValue = longOrNull.longValue(); String queryParameter2 = data.getQueryParameter("messageId"); if (queryParameter2 != null && (longOrNull2 = s.toLongOrNull(queryParameter2)) != null) { long longValue2 = longOrNull2.longValue(); m.checkNotNullParameter(context, "context"); Data build = new Data.Builder().putAll(h0.mapOf(o.to("com.discord.intent.extra.EXTRA_CHANNEL_ID", Long.valueOf(longValue)), o.to("com.discord.intent.extra.EXTRA_MESSAGE_ID", Long.valueOf(longValue2)))).build(); m.checkNotNullExpressionValue(build, "Data.Builder()\n … )\n .build()"); OneTimeWorkRequest build2 = new OneTimeWorkRequest.Builder(MessageAckWorker.class).setInputData(build).setBackoffCriteria(BackoffPolicy.LINEAR, 1, TimeUnit.SECONDS).addTag("message").addTag("ack").setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()).build(); m.checkNotNullExpressionValue(build2, "OneTimeWorkRequestBuilde… )\n .build()"); WorkManager.getInstance(context).enqueue(build2); NotificationClient.clear$default(NotificationClient.INSTANCE, longValue, context, false, 4, null); } } } } /* JADX DEBUG: Can't convert new array creation: APUT found in different block: 0x0075: APUT (r8v1 kotlin.Pair[]) (1 ??[boolean, int, float, short, byte, char]) (wrap: kotlin.Pair : 0x0071: INVOKE (r0v4 kotlin.Pair) = ("com.discord.intent.extra.EXTRA_CHANNEL_NAME"), (r1v3 java.lang.String) type: STATIC call: d0.o.to(java.lang.Object, java.lang.Object):kotlin.Pair) */ private final void enqueueDirectReply(Context context, Intent intent) { String queryParameter; Long longOrNull; CharSequence charSequence; String obj; Uri data = intent.getData(); if (data != null && (queryParameter = data.getQueryParameter("channelId")) != null && (longOrNull = s.toLongOrNull(queryParameter)) != null) { long longValue = longOrNull.longValue(); CharSequence charSequenceExtra = intent.getCharSequenceExtra("com.discord.intent.extra.EXTRA_CHANNEL_NAME"); Bundle resultsFromIntent = RemoteInput.getResultsFromIntent(intent); if (!(resultsFromIntent == null || (charSequence = resultsFromIntent.getCharSequence("discord_notif_text_input")) == null)) { m.checkNotNullExpressionValue(charSequence, "it"); if (!(!t.isBlank(charSequence))) { charSequence = null; } if (!(charSequence == null || (obj = charSequence.toString()) == null)) { NotificationCache.INSTANCE.setIgnoreNextClearForAck(longValue, true); m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(obj, "message"); Data.Builder builder = new Data.Builder(); Pair[] pairArr = new Pair[5]; pairArr[0] = o.to("com.discord.intent.extra.EXTRA_CHANNEL_ID", Long.valueOf(longValue)); pairArr[1] = o.to("com.discord.intent.extra.EXTRA_CHANNEL_NAME", charSequenceExtra != null ? charSequenceExtra.toString() : null); pairArr[2] = o.to("com.discord.intent.extra.EXTRA_MESSAGE_ID", null); pairArr[3] = o.to("MESSAGE_CONTENT", obj); pairArr[4] = o.to("com.discord.intent.extra.EXTRA_STICKER_ID", null); Data build = builder.putAll(h0.mapOf(pairArr)).build(); m.checkNotNullExpressionValue(build, "Data.Builder()\n … )\n .build()"); OneTimeWorkRequest build2 = new OneTimeWorkRequest.Builder(MessageSendWorker.class).setInputData(build).addTag("message").addTag("send").setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()).build(); m.checkNotNullExpressionValue(build2, "OneTimeWorkRequestBuilde… )\n .build()"); WorkManager.getInstance(context).enqueue(build2); return; } } NotificationClient.clear$default(NotificationClient.INSTANCE, longValue, context, false, 4, null); } } private final void enqueueTimedMute(Context context, Intent intent) { Long longOrNull; Long longOrNull2; Long longOrNull3; Uri data = intent.getData(); if (data != null) { m.checkNotNullExpressionValue(data, "intent.data ?: return"); String queryParameter = data.getQueryParameter("guildId"); if (queryParameter != null && (longOrNull = s.toLongOrNull(queryParameter)) != null) { long longValue = longOrNull.longValue(); String queryParameter2 = data.getQueryParameter("channelId"); if (queryParameter2 != null && (longOrNull2 = s.toLongOrNull(queryParameter2)) != null) { long longValue2 = longOrNull2.longValue(); String queryParameter3 = data.getQueryParameter("until"); if (queryParameter3 != null && (longOrNull3 = s.toLongOrNull(queryParameter3)) != null) { long longValue3 = longOrNull3.longValue(); m.checkNotNullParameter(context, "context"); Data build = new Data.Builder().putAll(h0.mapOf(o.to("com.discord.intent.extra.EXTRA_GUILD_ID", Long.valueOf(longValue)), o.to("com.discord.intent.extra.EXTRA_CHANNEL_ID", Long.valueOf(longValue2)), o.to("com.discord.intent.extra.EXTRA_UNTIL_TIMESTAMP_MS", Long.valueOf(longValue3)))).build(); m.checkNotNullExpressionValue(build, "Data.Builder()\n … )\n .build()"); OneTimeWorkRequest build2 = new OneTimeWorkRequest.Builder(TimedMuteWorker.class).setInputData(build).setBackoffCriteria(BackoffPolicy.LINEAR, 1, TimeUnit.SECONDS).addTag("channel").addTag("mute").setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()).build(); m.checkNotNullExpressionValue(build2, "OneTimeWorkRequestBuilde… )\n .build()"); WorkManager.getInstance(context).enqueue(build2); NotificationClient.clear$default(NotificationClient.INSTANCE, longValue2, context, false, 4, null); } } } } } @RequiresApi(24) private final void executeCallAction(Context context, Intent intent, boolean z2) { Long longOrNull; Long longOrNull2; Uri data = intent.getData(); if (data != null) { m.checkNotNullExpressionValue(data, "intent.data ?: return"); String queryParameter = data.getQueryParameter("channelId"); if (queryParameter != null && (longOrNull = s.toLongOrNull(queryParameter)) != null) { long longValue = longOrNull.longValue(); String queryParameter2 = data.getQueryParameter("messageId"); if (queryParameter2 != null && (longOrNull2 = s.toLongOrNull(queryParameter2)) != null) { long longValue2 = longOrNull2.longValue(); if (z2) { DiscordConnectService.i.b(context, longValue); } else { m.checkNotNullParameter(context, "context"); Data build = new Data.Builder().putAll(h0.mapOf(o.to("com.discord.intent.extra.EXTRA_CHANNEL_ID", Long.valueOf(longValue)), o.to("com.discord.intent.extra.EXTRA_MESSAGE_ID", Long.valueOf(longValue2)))).build(); m.checkNotNullExpressionValue(build, "Data.Builder()\n … )\n .build()"); BackoffPolicy backoffPolicy = BackoffPolicy.LINEAR; TimeUnit timeUnit = TimeUnit.SECONDS; OneTimeWorkRequest build2 = new OneTimeWorkRequest.Builder(CallActionWorker.class).setInputData(build).setBackoffCriteria(backoffPolicy, 1, timeUnit).addTag("call").addTag("decline").setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).setTriggerContentMaxDelay(10, timeUnit).build()).build(); m.checkNotNullExpressionValue(build2, "OneTimeWorkRequestBuilde… )\n .build()"); WorkManager.getInstance(context).enqueue(build2); } NotificationClient.clear$default(NotificationClient.INSTANCE, longValue, context, false, 4, null); } } } } @RequiresApi(24) public final void enqueue(Context context, Intent intent) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(intent, "intent"); Uri data = intent.getData(); if (!m.areEqual(data != null ? data.getAuthority() : null, "action")) { data = null; } if (data != null) { m.checkNotNullExpressionValue(data, "intent.data.takeIf { it?…y == \"action\" } ?: return"); String path = data.getPath(); if (path != null) { switch (path.hashCode()) { case -1030684332: if (path.equals("/channel/mute")) { enqueueTimedMute(context, intent); return; } break; case -581403885: if (path.equals("/message/reply")) { enqueueDirectReply(context, intent); return; } break; case 254025278: if (path.equals("/channel/call/accept")) { executeCallAction(context, intent, true); return; } break; case 897701618: if (path.equals("/message/ack")) { enqueueAckMessage(context, intent); return; } break; case 2004820096: if (path.equals("/channel/call/decline")) { executeCallAction(context, intent, false); return; } break; } } AppLog appLog = AppLog.g; StringBuilder L = a.L("Unknown work action "); L.append(data.getPath()); Logger.w$default(appLog, L.toString(), null, 2, null); } } @Override // android.content.BroadcastReceiver @RequiresApi(24) public void onReceive(Context context, Intent intent) { m.checkNotNullParameter(context, "context"); m.checkNotNullParameter(intent, "intent"); AppLog.i("Got notification action: " + intent); String action = intent.getAction(); if (action != null) { int hashCode = action.hashCode(); if (hashCode != -1599864135) { if (hashCode != -1350900838) { if (hashCode == -26919171 && action.equals("com.discord.intent.action.ENQUEUE_WORK")) { enqueue(context, intent); } } else if (action.equals("com.discord.intent.action.NOTIFICATION_DELETED")) { AppLog.i("Got notification deleted: " + intent); Bundle extras = intent.getExtras(); if (extras != null) { NotificationClient.clear$default(NotificationClient.INSTANCE, extras.getLong("com.discord.NOTIFICATION_DELETED_CHANNEL_ID"), context, false, 4, null); } } } else if (action.equals("com.discord.intent.action.NOTIFICATION_CANCEL")) { AppLog.i("Got notification cancel: " + intent); Bundle extras2 = intent.getExtras(); if (extras2 != null) { NotificationManagerCompat.from(context).cancel(extras2.getInt("com.discord.NOTIFICATION_ID")); } } } } }