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;
|
2021-06-27 20:53:42 +00:00
|
|
|
import com.discord.api.message.Message;
|
2021-06-27 20:44:35 +00:00
|
|
|
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.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;
|
2021-06-27 20:53:42 +00:00
|
|
|
import com.discord.utilities.message.MessageUtils;
|
2021-06-27 20:44:35 +00:00
|
|
|
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
private final ChatListEntry createEntryForInvite(Message message, String str, InviteEmbedModel inviteEmbedModel) {
|
2021-06-27 20:44:35 +00:00
|
|
|
ModelInvite resolveInviteCodeForPublicStage = inviteEmbedModel.resolveInviteCodeForPublicStage(str);
|
2021-06-27 20:53:42 +00:00
|
|
|
long j = 0;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (resolveInviteCodeForPublicStage != null) {
|
2021-06-27 20:53:42 +00:00
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
long i = g.i();
|
|
|
|
long r = message.r();
|
|
|
|
Long o = message.o();
|
|
|
|
if (o != null) {
|
|
|
|
j = o.longValue();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
return new StageInviteEntry(i, r, str, resolveInviteCodeForPublicStage, j);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
User g2 = message.g();
|
|
|
|
m.checkNotNull(g2);
|
|
|
|
long i2 = g2.i();
|
|
|
|
long r2 = message.r();
|
|
|
|
Long o2 = message.o();
|
|
|
|
if (o2 != null) {
|
|
|
|
j = o2.longValue();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
return new InviteEntry(i2, r2, str, j);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final Collection<ChatListEntry> createBotComponentEntries(Message message, long j, ComponentChatListState.ComponentStoreState componentStoreState) {
|
|
|
|
long j2;
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
List<Component> j3 = message.j();
|
|
|
|
if (j3 == null || !(!j3.isEmpty())) {
|
2021-06-27 20:44:35 +00:00
|
|
|
return n.emptyList();
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
List<Component> j4 = message.j();
|
|
|
|
if (j4 == null) {
|
|
|
|
j4 = n.emptyList();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
List<MessageComponent> processComponentsToMessageComponents = ComponentStateMapper.INSTANCE.processComponentsToMessageComponents(j4, componentStoreState, BotComponentExperiments.Companion.get(StoreStream.Companion.getExperiments()));
|
|
|
|
Long e = message.e();
|
|
|
|
if (e != null) {
|
|
|
|
j2 = e.longValue();
|
|
|
|
} else {
|
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
j2 = g.i();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
return d0.t.m.listOf(new BotUiComponentEntry(message, j2, Long.valueOf(j), processComponentsToMessageComponents));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final List<ChatListEntry> createEmbedEntries(Message message, StoreMessageState.State state, boolean z2, boolean z3, boolean z4, boolean z5, long j, boolean z6) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
MessageUtils messageUtils = MessageUtils.INSTANCE;
|
|
|
|
if (!(messageUtils.hasAttachments(message) || (messageUtils.hasEmbeds(message) && z5))) {
|
2021-06-27 20:44:35 +00:00
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
HashSet hashSet = new HashSet();
|
|
|
|
ArrayList<MessageEmbed> arrayList = new ArrayList();
|
2021-06-27 20:53:42 +00:00
|
|
|
List<MessageEmbed> m = message.m();
|
|
|
|
if (m != null) {
|
|
|
|
for (MessageEmbed messageEmbed : m) {
|
|
|
|
if (!hashSet.contains(messageEmbed.l())) {
|
|
|
|
hashSet.add(messageEmbed.l());
|
|
|
|
arrayList.add(messageEmbed);
|
|
|
|
} else if (messageEmbed.l() == null) {
|
|
|
|
arrayList.add(messageEmbed);
|
|
|
|
}
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
List<MessageAttachment> f = message.f();
|
2021-06-27 20:44:35 +00:00
|
|
|
int i = 0;
|
2021-06-27 20:53:42 +00:00
|
|
|
ArrayList arrayList2 = new ArrayList(arrayList.size() + (f != null ? f.size() : 0));
|
|
|
|
List<MessageAttachment> f2 = message.f();
|
|
|
|
if (f2 != null) {
|
|
|
|
for (MessageAttachment messageAttachment : f2) {
|
|
|
|
arrayList2.add(new AttachmentEntry(i, j, message, state, messageAttachment, z2, z3, z4, z6));
|
|
|
|
i++;
|
|
|
|
}
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
for (MessageEmbed messageEmbed2 : arrayList) {
|
|
|
|
if (messageEmbed2.k() != EmbedType.APPLICATION_NEWS) {
|
2021-06-27 20:53:42 +00:00
|
|
|
arrayList2.add(new EmbedEntry(i, j, message, state, messageEmbed2, z2, z3, z4, z6));
|
2021-06-27 20:44:35 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return arrayList2;
|
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final List<ChatListEntry> createGameInviteEntries(Message message) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
Application d = message.d();
|
|
|
|
MessageActivity b = message.b();
|
|
|
|
if (d == null || b == null) {
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
return d0.t.m.listOf(new GameInviteEntry(g.i(), message.r(), b, d));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final Collection<ChatListEntry> createGiftEntries(Message message) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
String k = message.k();
|
|
|
|
if (k == null || k.length() == 0) {
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
HashMap hashMap = new HashMap();
|
|
|
|
for (MatchResult matchResult : b.r.findAll(k, 0)) {
|
|
|
|
List<String> groupValues = matchResult.getGroupValues();
|
|
|
|
if (!groupValues.isEmpty()) {
|
|
|
|
String str = groupValues.get(groupValues.size() - 1);
|
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
hashMap.put(str, new GiftEntry(g.i(), message.r(), message.i(), str));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
Collection<ChatListEntry> values = hashMap.values();
|
|
|
|
m.checkNotNullExpressionValue(values, "entries.values");
|
|
|
|
return values;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final Collection<ChatListEntry> createGuildTemplateEntries(Message message) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
String k = message.k();
|
|
|
|
if (k != null) {
|
|
|
|
if (!(k.length() == 0)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
HashMap hashMap = new HashMap();
|
2021-06-27 20:53:42 +00:00
|
|
|
for (MatchResult matchResult : b.q.findAll(k, 0)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
List<String> groupValues = matchResult.getGroupValues();
|
|
|
|
if (!groupValues.isEmpty()) {
|
|
|
|
String str = groupValues.get(groupValues.size() - 1);
|
2021-06-27 20:53:42 +00:00
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
hashMap.put(str, new GuildTemplateEntry(g.i(), message.r(), str));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Collection<ChatListEntry> values = hashMap.values();
|
|
|
|
m.checkNotNullExpressionValue(values, "entries.values");
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final Collection<ChatListEntry> createInviteEntries(Message message, InviteEmbedModel inviteEmbedModel) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkNotNullParameter(inviteEmbedModel, "inviteEmbedModel");
|
2021-06-27 20:53:42 +00:00
|
|
|
String k = message.k();
|
|
|
|
if (k == null || k.length() == 0) {
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
HashMap hashMap = new HashMap();
|
|
|
|
for (MatchResult matchResult : b.o.findAll(k, 0)) {
|
|
|
|
List<String> groupValues = matchResult.getGroupValues();
|
|
|
|
if (!groupValues.isEmpty()) {
|
|
|
|
String str = groupValues.get(groupValues.size() - 1);
|
|
|
|
hashMap.put(str, createEntryForInvite(message, str, inviteEmbedModel));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
Collection<ChatListEntry> values = hashMap.values();
|
|
|
|
m.checkNotNullExpressionValue(values, "entries.values");
|
|
|
|
return values;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final List<ChatListEntry> createSpotifyListenTogetherEntries(Message message) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
|
|
|
MessageActivity b = message.b();
|
|
|
|
if (b == null || !MessageUtils.INSTANCE.isSpotifyListeningActivity(message)) {
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
|
|
|
User g = message.g();
|
|
|
|
m.checkNotNull(g);
|
|
|
|
return d0.t.m.listOf(new SpotifyListenTogetherEntry(g.i(), message.r(), b));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final List<ChatListEntry> createStickerEntries(Message message) {
|
|
|
|
m.checkNotNullParameter(message, "message");
|
2021-06-27 20:44:35 +00:00
|
|
|
ArrayList arrayList = null;
|
2021-06-27 20:53:42 +00:00
|
|
|
if (MessageUtils.INSTANCE.hasStickerItems(message)) {
|
|
|
|
List<StickerPartial> H = message.H();
|
|
|
|
if (H != null) {
|
|
|
|
arrayList = new ArrayList(o.collectionSizeOrDefault(H, 10));
|
|
|
|
for (StickerPartial stickerPartial : H) {
|
|
|
|
arrayList.add(new StickerEntry(message, stickerPartial));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2021-06-27 20:53:42 +00:00
|
|
|
List<Sticker> I = message.I();
|
|
|
|
if (I != null) {
|
|
|
|
arrayList = new ArrayList(o.collectionSizeOrDefault(I, 10));
|
|
|
|
for (Sticker sticker : I) {
|
|
|
|
arrayList.add(new StickerEntry(message, sticker));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return arrayList != null ? arrayList : n.emptyList();
|
|
|
|
}
|
|
|
|
|
2021-06-27 20:53:42 +00:00
|
|
|
public final Collection<ChatListEntry> createThreadEmbedEntries(Channel channel, Map<Long, GuildMember> map, Message message, Channel channel2, StoreThreadMessages.ThreadState threadState, Map<Long, GuildRole> map2, boolean z2, boolean z3) {
|
2021-06-27 20:44:35 +00:00
|
|
|
Map<Long, String> map3;
|
2021-06-27 20:53:42 +00:00
|
|
|
Message mostRecentMessage;
|
|
|
|
User g;
|
|
|
|
Message mostRecentMessage2;
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkNotNullParameter(channel, "channel");
|
|
|
|
m.checkNotNullParameter(map, "channelMembers");
|
2021-06-27 20:53:42 +00:00
|
|
|
m.checkNotNullParameter(message, "message");
|
2021-06-27 20:44:35 +00:00
|
|
|
m.checkNotNullParameter(channel2, "thread");
|
|
|
|
if (!z3) {
|
|
|
|
return n.emptyList();
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
long r = message.r();
|
2021-06-27 20:44:35 +00:00
|
|
|
int count = threadState != null ? threadState.getCount() : 0;
|
|
|
|
Long l = null;
|
2021-06-27 20:53:42 +00:00
|
|
|
Message mostRecentMessage3 = threadState != null ? threadState.getMostRecentMessage() : null;
|
|
|
|
Map<Long, GuildRole> map4 = RoleUtils.containsRoleMentions(message.k()) ? map2 : null;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (threadState == null || (mostRecentMessage2 = threadState.getMostRecentMessage()) == null || (map3 = MessageUtils.getNickOrUsernames(mostRecentMessage2, channel, map, channel.m())) == null) {
|
|
|
|
map3 = h0.emptyMap();
|
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
if (!(threadState == null || (mostRecentMessage = threadState.getMostRecentMessage()) == null || (g = mostRecentMessage.g()) == null)) {
|
|
|
|
l = Long.valueOf(g.i());
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
2021-06-27 20:53:42 +00:00
|
|
|
return d0.t.m.listOf(new ThreadEmbedEntry(r, channel2, count, mostRecentMessage3, map4, map3, z2, map.get(l), message));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean getShouldShowThreadSpine() {
|
|
|
|
return this.shouldShowThreadSpine;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isInExpandedBlockedMessageChunk() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void setShouldShowThreadSpine(boolean z2) {
|
|
|
|
this.shouldShowThreadSpine = z2;
|
|
|
|
}
|
|
|
|
}
|