260 lines
12 KiB
Java
260 lines
12 KiB
Java
package com.discord.stores;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
import b.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.channel.ChannelUtils;
|
|
import com.discord.api.message.Message;
|
|
import com.discord.api.permission.Permission;
|
|
import com.discord.models.domain.ModelNotificationSettings;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.StoreThreadsJoined;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.threads.ThreadUtils;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
/* compiled from: NotificationTextUtils.kt */
|
|
/* loaded from: classes.dex */
|
|
public final class NotificationTextUtils {
|
|
public static final NotificationTextUtils INSTANCE = new NotificationTextUtils();
|
|
|
|
private NotificationTextUtils() {
|
|
}
|
|
|
|
private final boolean isNotificationAllowed(ModelNotificationSettings modelNotificationSettings, User user, Collection<Long> collection, Message message, Guild guild, Channel channel, Long l, long j) {
|
|
if (modelNotificationSettings.isMobilePush() && !isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel)) {
|
|
return shouldNotifyForLevel(channelMessageNotificationLevel(modelNotificationSettings, channel, guild), user, collection, message, channel, l, j, modelNotificationSettings.isSuppressEveryone(), modelNotificationSettings.isSuppressRoles());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:25:0x005a, code lost:
|
|
if (r4 != true) goto L_0x005c;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
private final boolean isThreadNotificationAllowed(User user, Collection<Long> collection, Message message, StoreThreadsJoined.JoinedThread joinedThread, ModelNotificationSettings modelNotificationSettings, Guild guild, Channel channel, Channel channel2) {
|
|
boolean z2;
|
|
boolean z3;
|
|
boolean z4;
|
|
if (isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel)) {
|
|
return false;
|
|
}
|
|
int computeThreadNotificationSetting = ThreadUtils.INSTANCE.computeThreadNotificationSetting(joinedThread, isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel2), channelMessageNotificationLevel(modelNotificationSettings, channel2, guild));
|
|
if (computeThreadNotificationSetting != 2) {
|
|
if (computeThreadNotificationSetting == 8) {
|
|
return false;
|
|
}
|
|
if (!m.areEqual(message.r(), Boolean.TRUE)) {
|
|
List<com.discord.api.user.User> t = message.t();
|
|
if (t != null) {
|
|
if (!t.isEmpty()) {
|
|
for (com.discord.api.user.User user2 : t) {
|
|
if (user2.getId() == user.getId()) {
|
|
z4 = true;
|
|
continue;
|
|
} else {
|
|
z4 = false;
|
|
continue;
|
|
}
|
|
if (z4) {
|
|
z3 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z3 = false;
|
|
}
|
|
List<Long> s2 = message.s();
|
|
if (s2 == null) {
|
|
return false;
|
|
}
|
|
if (!s2.isEmpty()) {
|
|
for (Number number : s2) {
|
|
if (collection.contains(Long.valueOf(number.longValue()))) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (!z2) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:19:0x0040, code lost:
|
|
if (r8 != true) goto L_0x0042;
|
|
*/
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
*/
|
|
private final boolean messageContainsMention(User user, Collection<Long> collection, Message message, boolean z2, boolean z3) {
|
|
List<Long> s2;
|
|
boolean z4;
|
|
boolean z5;
|
|
boolean z6;
|
|
if (!m.areEqual(message.r(), Boolean.TRUE) || z2) {
|
|
List<com.discord.api.user.User> t = message.t();
|
|
if (t != null) {
|
|
if (!t.isEmpty()) {
|
|
for (com.discord.api.user.User user2 : t) {
|
|
if (user2.getId() == user.getId()) {
|
|
z6 = true;
|
|
continue;
|
|
} else {
|
|
z6 = false;
|
|
continue;
|
|
}
|
|
if (z6) {
|
|
z5 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z5 = false;
|
|
}
|
|
if (z3 || (s2 = message.s()) == null) {
|
|
return false;
|
|
}
|
|
if (!s2.isEmpty()) {
|
|
for (Number number : s2) {
|
|
if (collection.contains(Long.valueOf(number.longValue()))) {
|
|
z4 = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z4 = false;
|
|
if (!z4) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static /* synthetic */ boolean messageContainsMention$default(NotificationTextUtils notificationTextUtils, User user, Collection collection, Message message, boolean z2, boolean z3, int i, Object obj) {
|
|
return notificationTextUtils.messageContainsMention(user, collection, message, (i & 8) != 0 ? false : z2, (i & 16) != 0 ? false : z3);
|
|
}
|
|
|
|
private final Integer messageNotifications(ModelNotificationSettings modelNotificationSettings, long j) {
|
|
ModelNotificationSettings.ChannelOverride channelOverride = modelNotificationSettings.getChannelOverride(j);
|
|
if (channelOverride == null) {
|
|
return null;
|
|
}
|
|
Integer valueOf = Integer.valueOf(channelOverride.getMessageNotifications());
|
|
if (!(valueOf.intValue() == ModelNotificationSettings.FREQUENCY_UNSET)) {
|
|
return valueOf;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private final boolean shouldNotifyForLevel(Integer num, User user, Collection<Long> collection, Message message, Channel channel, Long l, long j, boolean z2, boolean z3) {
|
|
if (ChannelUtils.E(channel) && !PermissionUtils.can(Permission.CONNECT, l)) {
|
|
return false;
|
|
}
|
|
int i = ModelNotificationSettings.FREQUENCY_ALL;
|
|
if (num == null || num.intValue() != i) {
|
|
int i2 = ModelNotificationSettings.FREQUENCY_MENTIONS;
|
|
if (num != null && num.intValue() == i2) {
|
|
return messageContainsMention(user, collection, message, z2, z3);
|
|
}
|
|
int i3 = ModelNotificationSettings.FREQUENCY_NOTHING;
|
|
if (num != null && num.intValue() == i3) {
|
|
return false;
|
|
}
|
|
} else if (ChannelUtils.E(channel) && j != channel.h() && !messageContainsMention(user, collection, message, z2, z3)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static /* synthetic */ boolean shouldNotifyForLevel$default(NotificationTextUtils notificationTextUtils, Integer num, User user, Collection collection, Message message, Channel channel, Long l, long j, boolean z2, boolean z3, int i, Object obj) {
|
|
return notificationTextUtils.shouldNotifyForLevel(num, user, collection, message, channel, l, j, (i & 128) != 0 ? false : z2, (i & 256) != 0 ? false : z3);
|
|
}
|
|
|
|
public final Integer channelMessageNotificationLevel(ModelNotificationSettings modelNotificationSettings, Channel channel, Guild guild) {
|
|
Integer num = null;
|
|
Integer valueOf = guild != null ? Integer.valueOf(guild.getDefaultMessageNotifications()) : null;
|
|
if (channel == null || modelNotificationSettings == null) {
|
|
return valueOf;
|
|
}
|
|
Integer messageNotifications = messageNotifications(modelNotificationSettings, channel.h());
|
|
if (messageNotifications == null) {
|
|
messageNotifications = messageNotifications(modelNotificationSettings, channel.r());
|
|
}
|
|
if (messageNotifications != null) {
|
|
num = messageNotifications;
|
|
} else {
|
|
Integer valueOf2 = Integer.valueOf(modelNotificationSettings.getMessageNotifications());
|
|
if (valueOf2.intValue() != ModelNotificationSettings.FREQUENCY_UNSET) {
|
|
num = valueOf2;
|
|
}
|
|
}
|
|
return num != null ? num : valueOf;
|
|
}
|
|
|
|
public final boolean isGuildOrCategoryOrChannelMuted(ModelNotificationSettings modelNotificationSettings, Channel channel) {
|
|
if (modelNotificationSettings == null) {
|
|
return false;
|
|
}
|
|
if (modelNotificationSettings.isMuted()) {
|
|
return true;
|
|
}
|
|
if (channel == null) {
|
|
return false;
|
|
}
|
|
ModelNotificationSettings.ChannelOverride channelOverride = modelNotificationSettings.getChannelOverride(channel.r());
|
|
if (channelOverride != null && channelOverride.isMuted()) {
|
|
return true;
|
|
}
|
|
ModelNotificationSettings.ChannelOverride channelOverride2 = modelNotificationSettings.getChannelOverride(channel.h());
|
|
return channelOverride2 != null && channelOverride2.isMuted();
|
|
}
|
|
|
|
public final boolean shouldNotifyInAppPopup(User user, Message message, Channel channel, Map<Long, Integer> map, Channel channel2, Guild guild, Map<Long, ? extends Map<Long, GuildMember>> map2, Map<Long, ? extends ModelNotificationSettings> map3, Map<Long, StoreThreadsJoined.JoinedThread> map4, long j, Long l) {
|
|
com.discord.api.user.User e;
|
|
List<Long> list;
|
|
m.checkNotNullParameter(user, "me");
|
|
m.checkNotNullParameter(message, NotificationCompat.CATEGORY_MESSAGE);
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(map, "blockedRelationships");
|
|
m.checkNotNullParameter(map2, "guildMembers");
|
|
m.checkNotNullParameter(map3, "guildSettings");
|
|
m.checkNotNullParameter(map4, "joinedThreads");
|
|
if (ChannelUtils.v(channel) || (e = message.e()) == null || e.getId() == 0 || e.getId() == user.getId() || map.containsKey(Long.valueOf(e.getId()))) {
|
|
return false;
|
|
}
|
|
Integer E = message.E();
|
|
if (E != null && E.intValue() == 3) {
|
|
return false;
|
|
}
|
|
Map map5 = (Map) a.u0(channel, map2);
|
|
Integer num = null;
|
|
GuildMember guildMember = map5 != null ? (GuildMember) a.e(user, map5) : null;
|
|
if (guildMember == null || (list = guildMember.getRoles()) == null) {
|
|
list = n.emptyList();
|
|
}
|
|
ModelNotificationSettings modelNotificationSettings = (ModelNotificationSettings) a.u0(channel, map3);
|
|
if (ChannelUtils.C(channel)) {
|
|
return isThreadNotificationAllowed(user, list, message, (StoreThreadsJoined.JoinedThread) a.c(channel, map4), modelNotificationSettings, guild, channel, channel2);
|
|
}
|
|
if (modelNotificationSettings != null) {
|
|
return isNotificationAllowed(modelNotificationSettings, user, list, message, guild, channel, l, j);
|
|
}
|
|
if (guild != null) {
|
|
num = Integer.valueOf(guild.getDefaultMessageNotifications());
|
|
}
|
|
return shouldNotifyForLevel$default(this, num, user, list, message, channel, l, j, false, false, 384, null);
|
|
}
|
|
}
|