package com.discord.stores; import c.d.b.a.a; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; 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 collection, Message message, Guild guild, Channel channel) { Integer num; boolean z2 = false; if (!modelNotificationSettings.isMobilePush() || isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel)) { return false; } Integer messageNotifications = messageNotifications(modelNotificationSettings, channel.h()); if (messageNotifications == null) { messageNotifications = messageNotifications(modelNotificationSettings, channel.r()); } Integer num2 = null; if (messageNotifications == null) { messageNotifications = Integer.valueOf(modelNotificationSettings.getMessageNotifications()); if (messageNotifications.intValue() != ModelNotificationSettings.FREQUENCY_UNSET) { z2 = true; } if (!z2) { messageNotifications = null; } } if (messageNotifications != null) { num = messageNotifications; } else { if (guild != null) { num2 = Integer.valueOf(guild.getDefaultMessageNotifications()); } num = num2; } return shouldNotifyForLevel(num, user, collection, message, modelNotificationSettings.isSuppressEveryone(), modelNotificationSettings.isSuppressRoles()); } /* JADX WARNING: Code restructure failed: missing block: B:20:0x004f, code lost: if (r6 == true) goto L_0x0080; */ /* JADX WARNING: Removed duplicated region for block: B:42:? A[RETURN, SYNTHETIC] */ private final boolean isThreadNotificationAllowed(User user, Collection collection, Message message, StoreThreadsJoined.JoinedThread joinedThread, ModelNotificationSettings modelNotificationSettings, Channel channel) { boolean z2; boolean z3; boolean z4; int computeThreadNotificationSetting = ThreadUtils.INSTANCE.computeThreadNotificationSetting(joinedThread, isGuildOrCategoryOrChannelMuted(modelNotificationSettings, channel)); if (computeThreadNotificationSetting != 2) { if (computeThreadNotificationSetting == 8) { return false; } if (!m.areEqual(message.r(), Boolean.TRUE)) { List t = message.t(); if (t != null) { if (!t.isEmpty()) { Iterator 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 s2 = message.s(); if (s2 == null) { return false; } if (!s2.isEmpty()) { Iterator 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 collection, Message message, boolean z2, boolean z3) { List 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 t = message.t(); if (t != null) { if (!t.isEmpty()) { Iterator 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 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 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 map, Channel channel2, Guild guild, Map> map2, Map map3, Map map4) { com.discord.api.user.User e; List list; m.checkNotNullParameter(user, "me"); m.checkNotNullParameter(message, "msg"); m.checkNotNullParameter(channel, "channel"); m.checkNotNullParameter(map, "blockedRelationships"); m.checkNotNullParameter(map2, "guildMembers"); m.checkNotNullParameter(map3, "guildSettings"); m.checkNotNullParameter(map4, "joinedThreads"); if (AnimatableValueParser.q1(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.n0(channel, map2); Integer num = null; GuildMember guildMember = map5 != null ? (GuildMember) a.c(user, map5) : null; if (guildMember == null || (list = guildMember.getRoles()) == null) { list = n.emptyList(); } ModelNotificationSettings modelNotificationSettings = (ModelNotificationSettings) a.n0(channel, map3); if (AnimatableValueParser.A1(channel)) { return isThreadNotificationAllowed(user, list, message, (StoreThreadsJoined.JoinedThread) a.o0(channel, map4), modelNotificationSettings, 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); } }