discord-jadx/app/src/main/java/com/discord/widgets/chat/list/entries/ChatListEntry.java

314 lines
16 KiB
Java
Raw Normal View History

2021-06-27 20:44:35 +00:00
package com.discord.widgets.chat.list.entries;
import c.a.d.r0.b;
import com.discord.api.application.Application;
import com.discord.api.botuikit.Component;
import com.discord.api.channel.Channel;
import com.discord.api.message.activity.MessageActivity;
import com.discord.api.message.attachment.MessageAttachment;
import com.discord.api.message.embed.EmbedType;
import com.discord.api.message.embed.MessageEmbed;
import com.discord.api.role.GuildRole;
import com.discord.api.sticker.Sticker;
import com.discord.api.sticker.StickerPartial;
import com.discord.api.user.User;
import com.discord.models.botuikit.MessageComponent;
import com.discord.models.domain.ModelInvite;
import com.discord.models.domain.ModelMessage;
import com.discord.models.member.GuildMember;
import com.discord.stores.StoreMessageState;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreThreadMessages;
import com.discord.utilities.embed.InviteEmbedModel;
import com.discord.utilities.guilds.RoleUtils;
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.textprocessing.MessageUtils;
import com.discord.widgets.botuikit.BotComponentExperiments;
import com.discord.widgets.botuikit.ComponentChatListState;
import com.discord.widgets.botuikit.ComponentStateMapper;
import d0.t.h0;
import d0.t.n;
import d0.t.o;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.text.MatchResult;
/* compiled from: ChatListEntry.kt */
public abstract class ChatListEntry implements MGRecyclerDataPayload {
public static final int APPLICATION_COMMAND = 33;
public static final int BLOCKED_MESSAGES = 10;
public static final int BOT_UI_COMPONENT = 36;
public static final int CALL_MESSAGE = 19;
public static final Companion Companion = new Companion(null);
public static final int DIVIDER = 15;
public static final int EMPTY_PINS = 16;
public static final int EPHEMERAL_MESSAGE = 34;
public static final int GAME_INVITE = 22;
public static final int GIFT = 26;
public static final int GUILD_INVITE_REMINDER = 38;
public static final int GUILD_TEMPLATE = 30;
public static final int GUILD_WELCOME = 25;
public static final int INVITE = 24;
public static final int LOAD_INDICATOR = 2;
public static final int MENTION_FOOTER = 18;
public static final int MESSAGE = 0;
public static final int MESSAGE_ATTACHMENT = 28;
public static final int MESSAGE_EMBED = 21;
public static final int MESSAGE_FAILED = 20;
public static final int MESSAGE_HEADER = 17;
public static final int MESSAGE_MINIMAL = 1;
public static final int NEW_MESSAGES = 8;
public static final int REACTIONS = 4;
public static final int REPLY = 32;
public static final int SEARCH_EMPTY = 13;
public static final int SEARCH_ERROR = 14;
public static final int SEARCH_INDEXING = 12;
public static final int SEARCH_RESULT_COUNT = 11;
public static final int SPACER = 7;
public static final int SPOTIFY_LISTEN_TOGETHER = 23;
public static final int STAGE_INVITE = 39;
public static final int START_OF_CHAT = 3;
public static final int START_OF_PRIVATE_CHAT = 29;
public static final int STICKER = 31;
public static final int STICKER_GREET = 41;
public static final int STICKER_GREET_COMPACT = 42;
public static final int SYSTEM_MESSAGE = 5;
public static final int THREAD_DRAFT_FORM = 37;
public static final int THREAD_EMBED = 35;
public static final int THREAD_STARTER_DIVIDER = 40;
public static final int TIMESTAMP = 9;
public static final int UPLOAD_STATUS = 6;
private boolean shouldShowThreadSpine;
/* compiled from: ChatListEntry.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private final ChatListEntry createEntryForInvite(ModelMessage modelMessage, String str, InviteEmbedModel inviteEmbedModel) {
ModelInvite resolveInviteCodeForPublicStage = inviteEmbedModel.resolveInviteCodeForPublicStage(str);
Long l = 0L;
if (resolveInviteCodeForPublicStage != null) {
long i = modelMessage.getAuthor().i();
long id2 = modelMessage.getId();
Long guildId = modelMessage.getGuildId();
if (guildId != null) {
l = guildId;
}
m.checkNotNullExpressionValue(l, "message.guildId ?: 0L");
return new StageInviteEntry(i, id2, str, resolveInviteCodeForPublicStage, l.longValue());
}
long i2 = modelMessage.getAuthor().i();
long id3 = modelMessage.getId();
Long guildId2 = modelMessage.getGuildId();
if (guildId2 != null) {
l = guildId2;
}
m.checkNotNullExpressionValue(l, "message.guildId ?: 0L");
return new InviteEntry(i2, id3, str, l.longValue());
}
public final Collection<ChatListEntry> createBotComponentEntries(ModelMessage modelMessage, long j, ComponentChatListState.ComponentStoreState componentStoreState) {
m.checkNotNullParameter(modelMessage, "message");
List<Component> components = modelMessage.getComponents();
if (components == null || !(!components.isEmpty())) {
return n.emptyList();
}
List<Component> components2 = modelMessage.getComponents();
if (components2 == null) {
components2 = n.emptyList();
}
List<MessageComponent> processComponentsToMessageComponents = ComponentStateMapper.INSTANCE.processComponentsToMessageComponents(components2, componentStoreState, BotComponentExperiments.Companion.get(StoreStream.Companion.getExperiments()));
Long applicationId = modelMessage.getApplicationId();
if (applicationId == null) {
applicationId = Long.valueOf(modelMessage.getAuthor().i());
}
m.checkNotNullExpressionValue(applicationId, "message.applicationId ?: message.author.id");
return d0.t.m.listOf(new BotUiComponentEntry(modelMessage, applicationId.longValue(), Long.valueOf(j), processComponentsToMessageComponents));
}
public final List<ChatListEntry> createEmbedEntries(ModelMessage modelMessage, StoreMessageState.State state, boolean z2, boolean z3, boolean z4, boolean z5, long j, boolean z6) {
m.checkNotNullParameter(modelMessage, "message");
if (modelMessage.getAttachments().isEmpty() && (modelMessage.getEmbeds().isEmpty() || !z5)) {
return n.emptyList();
}
HashSet hashSet = new HashSet();
ArrayList<MessageEmbed> arrayList = new ArrayList();
for (MessageEmbed messageEmbed : modelMessage.getEmbeds()) {
if (!hashSet.contains(messageEmbed.l())) {
hashSet.add(messageEmbed.l());
m.checkNotNullExpressionValue(messageEmbed, "embed");
arrayList.add(messageEmbed);
} else if (messageEmbed.l() == null) {
m.checkNotNullExpressionValue(messageEmbed, "embed");
arrayList.add(messageEmbed);
}
}
ArrayList arrayList2 = new ArrayList(arrayList.size() + modelMessage.getAttachments().size());
int i = 0;
for (MessageAttachment messageAttachment : modelMessage.getAttachments()) {
m.checkNotNullExpressionValue(messageAttachment, "attachment");
arrayList2.add(new AttachmentEntry(i, j, modelMessage, state, messageAttachment, z2, z3, z4, z6));
i++;
}
for (MessageEmbed messageEmbed2 : arrayList) {
if (messageEmbed2.k() != EmbedType.APPLICATION_NEWS) {
arrayList2.add(new EmbedEntry(i, j, modelMessage, state, messageEmbed2, z2, z3, z4, z6));
i++;
}
}
return arrayList2;
}
public final List<ChatListEntry> createGameInviteEntries(ModelMessage modelMessage) {
m.checkNotNullParameter(modelMessage, "message");
Application application = modelMessage.getApplication();
MessageActivity activity = modelMessage.getActivity();
return (application == null || activity == null) ? n.emptyList() : d0.t.m.listOf(new GameInviteEntry(modelMessage.getAuthor().i(), modelMessage.getId(), activity, application));
}
public final Collection<ChatListEntry> createGiftEntries(ModelMessage modelMessage) {
m.checkNotNullParameter(modelMessage, "message");
String content = modelMessage.getContent();
if (content != null) {
if (!(content.length() == 0)) {
HashMap hashMap = new HashMap();
for (MatchResult matchResult : b.r.findAll(content, 0)) {
List<String> groupValues = matchResult.getGroupValues();
if (!groupValues.isEmpty()) {
String str = groupValues.get(groupValues.size() - 1);
hashMap.put(str, new GiftEntry(modelMessage.getAuthor().i(), modelMessage.getId(), modelMessage.getChannelId(), str));
}
}
Collection<ChatListEntry> values = hashMap.values();
m.checkNotNullExpressionValue(values, "entries.values");
return values;
}
}
return n.emptyList();
}
public final Collection<ChatListEntry> createGuildTemplateEntries(ModelMessage modelMessage) {
m.checkNotNullParameter(modelMessage, "message");
String content = modelMessage.getContent();
if (content != null) {
if (!(content.length() == 0)) {
HashMap hashMap = new HashMap();
for (MatchResult matchResult : b.q.findAll(content, 0)) {
List<String> groupValues = matchResult.getGroupValues();
if (!groupValues.isEmpty()) {
String str = groupValues.get(groupValues.size() - 1);
hashMap.put(str, new GuildTemplateEntry(modelMessage.getAuthor().i(), modelMessage.getId(), str));
}
}
Collection<ChatListEntry> values = hashMap.values();
m.checkNotNullExpressionValue(values, "entries.values");
return values;
}
}
return n.emptyList();
}
public final Collection<ChatListEntry> createInviteEntries(ModelMessage modelMessage, InviteEmbedModel inviteEmbedModel) {
m.checkNotNullParameter(modelMessage, "message");
m.checkNotNullParameter(inviteEmbedModel, "inviteEmbedModel");
String content = modelMessage.getContent();
if (content != null) {
if (!(content.length() == 0)) {
HashMap hashMap = new HashMap();
for (MatchResult matchResult : b.o.findAll(content, 0)) {
List<String> groupValues = matchResult.getGroupValues();
if (!groupValues.isEmpty()) {
String str = groupValues.get(groupValues.size() - 1);
hashMap.put(str, createEntryForInvite(modelMessage, str, inviteEmbedModel));
}
}
Collection<ChatListEntry> values = hashMap.values();
m.checkNotNullExpressionValue(values, "entries.values");
return values;
}
}
return n.emptyList();
}
public final List<ChatListEntry> createSpotifyListenTogetherEntries(ModelMessage modelMessage) {
m.checkNotNullParameter(modelMessage, "message");
MessageActivity activity = modelMessage.getActivity();
return (activity == null || !modelMessage.isSpotifyListeningActivity()) ? n.emptyList() : d0.t.m.listOf(new SpotifyListenTogetherEntry(modelMessage.getAuthor().i(), modelMessage.getId(), activity));
}
public final List<ChatListEntry> createStickerEntries(ModelMessage modelMessage) {
m.checkNotNullParameter(modelMessage, "message");
List<StickerPartial> stickerItems = modelMessage.getStickerItems();
ArrayList arrayList = null;
if (!(stickerItems == null || stickerItems.isEmpty())) {
List<StickerPartial> stickerItems2 = modelMessage.getStickerItems();
if (stickerItems2 != null) {
arrayList = new ArrayList(o.collectionSizeOrDefault(stickerItems2, 10));
for (StickerPartial stickerPartial : stickerItems2) {
m.checkNotNullExpressionValue(stickerPartial, "it");
arrayList.add(new StickerEntry(modelMessage, stickerPartial));
}
}
} else {
List<Sticker> stickers = modelMessage.getStickers();
if (stickers != null) {
arrayList = new ArrayList(o.collectionSizeOrDefault(stickers, 10));
for (Sticker sticker : stickers) {
m.checkNotNullExpressionValue(sticker, "sticker");
arrayList.add(new StickerEntry(modelMessage, sticker));
}
}
}
return arrayList != null ? arrayList : n.emptyList();
}
public final Collection<ChatListEntry> createThreadEmbedEntries(Channel channel, Map<Long, GuildMember> map, ModelMessage modelMessage, Channel channel2, StoreThreadMessages.ThreadState threadState, Map<Long, GuildRole> map2, boolean z2, boolean z3) {
Map<Long, String> map3;
ModelMessage mostRecentMessage;
User author;
ModelMessage mostRecentMessage2;
m.checkNotNullParameter(channel, "channel");
m.checkNotNullParameter(map, "channelMembers");
m.checkNotNullParameter(modelMessage, "message");
m.checkNotNullParameter(channel2, "thread");
if (!z3) {
return n.emptyList();
}
long id2 = modelMessage.getId();
int count = threadState != null ? threadState.getCount() : 0;
Long l = null;
ModelMessage mostRecentMessage3 = threadState != null ? threadState.getMostRecentMessage() : null;
Map<Long, GuildRole> map4 = RoleUtils.containsRoleMentions(modelMessage.getContent()) ? map2 : null;
if (threadState == null || (mostRecentMessage2 = threadState.getMostRecentMessage()) == null || (map3 = MessageUtils.getNickOrUsernames(mostRecentMessage2, channel, map, channel.m())) == null) {
map3 = h0.emptyMap();
}
if (!(threadState == null || (mostRecentMessage = threadState.getMostRecentMessage()) == null || (author = mostRecentMessage.getAuthor()) == null)) {
l = Long.valueOf(author.i());
}
return d0.t.m.listOf(new ThreadEmbedEntry(id2, channel2, count, mostRecentMessage3, map4, map3, z2, map.get(l), modelMessage));
}
}
public final boolean getShouldShowThreadSpine() {
return this.shouldShowThreadSpine;
}
public boolean isInExpandedBlockedMessageChunk() {
return false;
}
public final void setShouldShowThreadSpine(boolean z2) {
this.shouldShowThreadSpine = z2;
}
}