114 lines
6.3 KiB
Java
114 lines
6.3 KiB
Java
package com.discord.utilities.guilds;
|
|
|
|
import com.discord.api.guild.GuildVerificationLevel;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreGuilds;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.guildmember.GuildMemberUtilsKt;
|
|
import com.discord.utilities.rx.LeadingEdgeThrottle;
|
|
import com.discord.utilities.time.Clock;
|
|
import com.discord.utilities.time.ClockFactory;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import d0.z.d.m;
|
|
import j0.l.a.r;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.concurrent.TimeUnit;
|
|
import rx.Observable;
|
|
/* compiled from: GuildVerificationLevelUtils.kt */
|
|
public final class GuildVerificationLevelUtils {
|
|
public static final GuildVerificationLevelUtils INSTANCE = new GuildVerificationLevelUtils();
|
|
|
|
private GuildVerificationLevelUtils() {
|
|
}
|
|
|
|
public static final /* synthetic */ GuildVerificationLevel access$computeVerificationLevelTriggered(GuildVerificationLevelUtils guildVerificationLevelUtils, MeUser meUser, Guild guild, GuildMember guildMember, GuildVerificationLevel guildVerificationLevel, long j, Clock clock) {
|
|
return guildVerificationLevelUtils.computeVerificationLevelTriggered(meUser, guild, guildMember, guildVerificationLevel, j, clock);
|
|
}
|
|
|
|
private final GuildVerificationLevel computeVerificationLevelTriggered(MeUser meUser, Guild guild, GuildMember guildMember, GuildVerificationLevel guildVerificationLevel, long j, Clock clock) {
|
|
List<Long> roles;
|
|
boolean z2 = false;
|
|
boolean z3 = guild != null && guild.isOwner(meUser.getId());
|
|
if (!(guildMember == null || (roles = guildMember.getRoles()) == null || !(!roles.isEmpty()))) {
|
|
z2 = true;
|
|
}
|
|
UserUtils userUtils = UserUtils.INSTANCE;
|
|
boolean hasPhone = userUtils.getHasPhone(meUser);
|
|
boolean isStaff = userUtils.isStaff(meUser);
|
|
if (z3 || z2 || hasPhone || isStaff) {
|
|
return GuildVerificationLevel.NONE;
|
|
}
|
|
GuildVerificationLevel guildVerificationLevel2 = GuildVerificationLevel.HIGHEST;
|
|
if (guildVerificationLevel == guildVerificationLevel2) {
|
|
return guildVerificationLevel2;
|
|
}
|
|
GuildVerificationLevel guildVerificationLevel3 = GuildVerificationLevel.HIGH;
|
|
if (guildVerificationLevel == guildVerificationLevel3 && !GuildMemberUtilsKt.isGuildMemberOldEnough(j)) {
|
|
return guildVerificationLevel3;
|
|
}
|
|
GuildVerificationLevel guildVerificationLevel4 = GuildVerificationLevel.MEDIUM;
|
|
if (guildVerificationLevel == guildVerificationLevel4 && !userUtils.isAccountOldEnough(meUser, clock)) {
|
|
return guildVerificationLevel4;
|
|
}
|
|
GuildVerificationLevel guildVerificationLevel5 = GuildVerificationLevel.LOW;
|
|
return (guildVerificationLevel != guildVerificationLevel5 || meUser.isVerified()) ? GuildVerificationLevel.NONE : guildVerificationLevel5;
|
|
}
|
|
|
|
public static /* synthetic */ GuildVerificationLevel getVerificationLevelTriggered$default(GuildVerificationLevelUtils guildVerificationLevelUtils, long j, StoreGuilds storeGuilds, StoreUser storeUser, Clock clock, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
storeGuilds = StoreStream.Companion.getGuilds();
|
|
}
|
|
if ((i & 4) != 0) {
|
|
storeUser = StoreStream.Companion.getUsers();
|
|
}
|
|
if ((i & 8) != 0) {
|
|
clock = ClockFactory.get();
|
|
}
|
|
return guildVerificationLevelUtils.getVerificationLevelTriggered(j, storeGuilds, storeUser, clock);
|
|
}
|
|
|
|
public static /* synthetic */ Observable observeVerificationLevelTriggered$default(GuildVerificationLevelUtils guildVerificationLevelUtils, long j, StoreGuilds storeGuilds, StoreUser storeUser, Clock clock, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
storeGuilds = StoreStream.Companion.getGuilds();
|
|
}
|
|
if ((i & 4) != 0) {
|
|
storeUser = StoreStream.Companion.getUsers();
|
|
}
|
|
if ((i & 8) != 0) {
|
|
clock = ClockFactory.get();
|
|
}
|
|
return guildVerificationLevelUtils.observeVerificationLevelTriggered(j, storeGuilds, storeUser, clock);
|
|
}
|
|
|
|
public final GuildVerificationLevel getVerificationLevelTriggered(long j, StoreGuilds storeGuilds, StoreUser storeUser, Clock clock) {
|
|
GuildVerificationLevel guildVerificationLevel;
|
|
m.checkNotNullParameter(storeGuilds, "guildStore");
|
|
m.checkNotNullParameter(storeUser, "userStore");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
Guild guild = storeGuilds.getGuild(j);
|
|
Map<Long, GuildMember> map = storeGuilds.getMembers().get(Long.valueOf(j));
|
|
MeUser me2 = storeUser.getMe();
|
|
GuildMember guildMember = map != null ? map.get(Long.valueOf(me2.getId())) : null;
|
|
if (guild == null || (guildVerificationLevel = guild.getVerificationLevel()) == null) {
|
|
guildVerificationLevel = GuildVerificationLevel.NONE;
|
|
}
|
|
return computeVerificationLevelTriggered(me2, guild, guildMember, guildVerificationLevel, GuildMemberUtilsKt.getJoinedAtOrNow(storeGuilds.getGuildsJoinedAt().get(Long.valueOf(j))), clock);
|
|
}
|
|
|
|
public final Observable<GuildVerificationLevel> observeVerificationLevelTriggered(long j, StoreGuilds storeGuilds, StoreUser storeUser, Clock clock) {
|
|
m.checkNotNullParameter(storeGuilds, "guildStore");
|
|
m.checkNotNullParameter(storeUser, "userStore");
|
|
m.checkNotNullParameter(clock, "clock");
|
|
Observable<Long> observeJoinedAt = storeGuilds.observeJoinedAt(j);
|
|
Observable<Guild> observeGuild = storeGuilds.observeGuild(j);
|
|
Observable<GuildVerificationLevel> observeVerificationLevel = storeGuilds.observeVerificationLevel(j);
|
|
Observable<Map<Long, GuildMember>> observeComputed = storeGuilds.observeComputed(j);
|
|
Observable<GuildVerificationLevel> r = Observable.g(observeJoinedAt, observeGuild, observeVerificationLevel, Observable.h0(new r(observeComputed.i, new LeadingEdgeThrottle(1500, TimeUnit.MILLISECONDS))), storeUser.observeMe(true), new GuildVerificationLevelUtils$observeVerificationLevelTriggered$1(clock)).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n .comb… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
}
|