discord-jadx/app/src/main/java/com/discord/utilities/rest/RestAPIAbortMessages.java

78 lines
4.6 KiB
Java

package com.discord.utilities.rest;
import android.content.Context;
import b.a.k.b;
import com.discord.R;
import com.discord.restapi.RestAPIAbortCodes;
import com.discord.utilities.error.Error;
import d0.o;
import d0.t.h0;
import d0.z.d.m;
import java.util.Map;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
/* compiled from: RestAPIAbortMessages.kt */
public final class RestAPIAbortMessages {
public static final RestAPIAbortMessages INSTANCE = new RestAPIAbortMessages();
private static final Map<Integer, Integer> MESSAGES;
/* compiled from: RestAPIAbortMessages.kt */
public static final class ResponseResolver {
public static final ResponseResolver INSTANCE = new ResponseResolver();
private ResponseResolver() {
}
public final CharSequence getRelationshipResponse(Context context, int i, String str) {
m.checkNotNullParameter(str, "username");
Integer abortCodeMessageResId = RestAPIAbortMessages.getAbortCodeMessageResId(i);
int intValue = abortCodeMessageResId != null ? abortCodeMessageResId.intValue() : R.string.add_friend_error_other;
if (i != 80000) {
if (context != null) {
return b.h(context, intValue, new Object[0], null, 4);
}
return null;
} else if (context != null) {
return b.h(context, intValue, new Object[]{str}, null, 4);
} else {
return null;
}
}
}
static {
Integer valueOf = Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_INCOMING_DISABLED);
Integer valueOf2 = Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_INCOMING_BLOCKED);
Integer valueOf3 = Integer.valueOf((int) R.string.add_friend_error_other);
MESSAGES = h0.mapOf(o.to(valueOf, Integer.valueOf((int) R.string.bot_requires_email_verification)), o.to(Integer.valueOf((int) RestAPIAbortCodes.INVALID_MESSAGE_SEND_USER), Integer.valueOf((int) R.string.bot_dm_send_failed)), o.to(Integer.valueOf((int) RestAPIAbortCodes.RATE_LIMIT_DM_OPEN), Integer.valueOf((int) R.string.bot_dm_rate_limited)), o.to(Integer.valueOf((int) RestAPIAbortCodes.SEND_MESSAGE_TEMPORARILY_DISABLED), Integer.valueOf((int) R.string.bot_dm_send_message_temporarily_disabled)), o.to(valueOf, Integer.valueOf((int) R.string.add_friend_error_invalid_discord_tag)), o.to(Integer.valueOf((int) RestAPIAbortCodes.TOO_MANY_FRIENDS), Integer.valueOf((int) R.string.add_friend_error_too_many_friends)), o.to(valueOf2, valueOf3), o.to(Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_INVALID_SELF), valueOf3), o.to(Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_INVALID_USER_BOT), valueOf3), o.to(Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_INVALID_DISCORD_TAG), valueOf3), o.to(Integer.valueOf((int) RestAPIAbortCodes.RELATIONSHIP_ALREADY_FRIENDS), Integer.valueOf((int) R.string.add_friend_error_already_friends)), o.to(Integer.valueOf((int) RestAPIAbortCodes.TOO_MANY_THREADS), Integer.valueOf((int) R.string.too_many_threads_message)), o.to(Integer.valueOf((int) RestAPIAbortCodes.TOO_MANY_ANNOUNCEMENT_THREADS), Integer.valueOf((int) R.string.too_many_announcement_threads_message)), o.to(Integer.valueOf((int) RestAPIAbortCodes.SLOWMODE_RATE_LIMITED), Integer.valueOf((int) R.string.channel_slowmode_desc_short)));
}
private RestAPIAbortMessages() {
}
public static final Integer getAbortCodeMessageResId(int i) {
return MESSAGES.get(Integer.valueOf(i));
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.utilities.rest.RestAPIAbortMessages */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ void handleAbortCodeOrDefault$default(RestAPIAbortMessages restAPIAbortMessages, Error error, Function0 function0, Function0 function02, int i, Object obj) {
if ((i & 4) != 0) {
function02 = RestAPIAbortMessages$handleAbortCodeOrDefault$1.INSTANCE;
}
restAPIAbortMessages.handleAbortCodeOrDefault(error, function0, function02);
}
public final void handleAbortCodeOrDefault(Error error, Function0<Unit> function0, Function0<Boolean> function02) {
m.checkNotNullParameter(error, "errorResponse");
m.checkNotNullParameter(function0, "onHandle");
m.checkNotNullParameter(function02, "onDefault");
if (error.getType() == Error.Type.DISCORD_BAD_REQUEST) {
error.setShowErrorToasts(false);
function0.mo1invoke();
return;
}
error.setShowErrorToasts(function02.mo1invoke().booleanValue());
}
}