260 lines
12 KiB
Java
260 lines
12 KiB
Java
package com.discord.stores;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
import c.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.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.threads.ThreadUtils;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
/* compiled from: NotificationTextUtils.kt */
|
|
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) {
|
|
if (modelNotificationSettings.isMobilePush() && !isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel)) {
|
|
return shouldNotifyForLevel(channelMessageNotificationLevel(modelNotificationSettings, channel, guild), user, collection, message, modelNotificationSettings.isSuppressEveryone(), modelNotificationSettings.isSuppressRoles());
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:23:0x005a, code lost:
|
|
if (r4 == true) goto L_0x008b;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:45:? A[RETURN, SYNTHETIC] */
|
|
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()) {
|
|
Iterator<T> it = t.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (((com.discord.api.user.User) it.next()).i() == 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()) {
|
|
Iterator<T> it2 = s2.iterator();
|
|
while (true) {
|
|
if (it2.hasNext()) {
|
|
if (collection.contains(Long.valueOf(((Number) it2.next()).longValue()))) {
|
|
z2 = true;
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (z2) {
|
|
return false;
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (z2) {
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:30:0x0066, code lost:
|
|
if (r8 != true) goto L_0x0068;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:52:? A[RETURN, SYNTHETIC] */
|
|
private final boolean shouldNotifyForLevel(Integer num, User user, Collection<Long> collection, Message message, boolean z2, boolean z3) {
|
|
List<Long> s2;
|
|
boolean z4;
|
|
boolean z5;
|
|
boolean z6;
|
|
int i = ModelNotificationSettings.FREQUENCY_ALL;
|
|
if (num == null || num.intValue() != i) {
|
|
int i2 = ModelNotificationSettings.FREQUENCY_NOTHING;
|
|
if (num != null && num.intValue() == i2) {
|
|
return false;
|
|
}
|
|
int i3 = ModelNotificationSettings.FREQUENCY_MENTIONS;
|
|
if (num != null && num.intValue() == i3 && (!m.areEqual(message.r(), Boolean.TRUE) || z2)) {
|
|
List<com.discord.api.user.User> t = message.t();
|
|
if (t != null) {
|
|
if (!t.isEmpty()) {
|
|
Iterator<T> it = t.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
if (((com.discord.api.user.User) it.next()).i() == 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()) {
|
|
Iterator<T> it2 = s2.iterator();
|
|
while (true) {
|
|
if (it2.hasNext()) {
|
|
if (collection.contains(Long.valueOf(((Number) it2.next()).longValue()))) {
|
|
z4 = true;
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (z4) {
|
|
return false;
|
|
}
|
|
}
|
|
z4 = false;
|
|
if (z4) {
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static /* synthetic */ boolean shouldNotifyForLevel$default(NotificationTextUtils notificationTextUtils, Integer num, User user, Collection collection, Message message, boolean z2, boolean z3, int i, Object obj) {
|
|
return notificationTextUtils.shouldNotifyForLevel(num, user, collection, message, (i & 16) != 0 ? false : z2, (i & 32) != 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) {
|
|
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.u(channel) || (e = message.e()) == null || e.i() == 0 || e.i() == user.getId() || map.containsKey(Long.valueOf(e.i()))) {
|
|
return false;
|
|
}
|
|
Integer E = message.E();
|
|
if (E != null && E.intValue() == 3) {
|
|
return false;
|
|
}
|
|
Map map5 = (Map) a.s0(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.s0(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);
|
|
}
|
|
if (guild != null) {
|
|
num = Integer.valueOf(guild.getDefaultMessageNotifications());
|
|
}
|
|
return shouldNotifyForLevel$default(this, num, user, list, message, false, false, 48, null);
|
|
}
|
|
}
|