forked from Juby210/discord-jadx
180 lines
7.9 KiB
Java
180 lines
7.9 KiB
Java
package com.discord.utilities.experiments;
|
|
|
|
import com.discord.api.guild.GuildFeature;
|
|
import com.discord.api.guild.GuildHubType;
|
|
import com.discord.models.experiments.domain.ExperimentHash;
|
|
import com.discord.models.experiments.dto.GuildExperimentBucketDto;
|
|
import com.discord.models.experiments.dto.GuildExperimentDto;
|
|
import com.discord.models.experiments.dto.GuildExperimentFilter;
|
|
import com.discord.models.experiments.dto.GuildExperimentOverridesDto;
|
|
import com.discord.models.experiments.dto.GuildExperimentPopulationDto;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.widgets.chat.input.MentionUtilsKt;
|
|
import d0.d0.f;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import kotlin.ranges.IntRange;
|
|
/* compiled from: ExperimentUtils.kt */
|
|
public final class ExperimentUtils {
|
|
public static final int BUCKET_NOT_ELIGIBLE = -1;
|
|
public static final ExperimentUtils INSTANCE = new ExperimentUtils();
|
|
|
|
private ExperimentUtils() {
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:113:0x00a0 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:116:0x00a0 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:121:0x007c A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:123:0x007c A[SYNTHETIC] */
|
|
public final int computeGuildExperimentBucket(String str, long j, int i, Guild guild, GuildExperimentDto guildExperimentDto) {
|
|
Object obj;
|
|
boolean z2;
|
|
boolean z3;
|
|
boolean z4;
|
|
boolean z5;
|
|
boolean z6;
|
|
boolean z7;
|
|
String str2 = str;
|
|
m.checkNotNullParameter(str2, "experimentName");
|
|
m.checkNotNullParameter(guildExperimentDto, "experiment");
|
|
for (GuildExperimentOverridesDto guildExperimentOverridesDto : guildExperimentDto.getOverrides()) {
|
|
if (guildExperimentOverridesDto.getGuilds().contains(Long.valueOf(j))) {
|
|
return guildExperimentOverridesDto.getBucket();
|
|
}
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
String hashKey = guildExperimentDto.getHashKey();
|
|
if (hashKey != null) {
|
|
str2 = hashKey;
|
|
}
|
|
sb.append(str2);
|
|
sb.append(MentionUtilsKt.EMOJIS_AND_STICKERS_CHAR);
|
|
sb.append(j);
|
|
long from = ExperimentHash.INSTANCE.from(sb.toString()) % ((long) 10000);
|
|
for (GuildExperimentPopulationDto guildExperimentPopulationDto : guildExperimentDto.getPopulations()) {
|
|
Iterator<GuildExperimentFilter> it = guildExperimentPopulationDto.getFilters().iterator();
|
|
boolean z8 = true;
|
|
while (true) {
|
|
obj = null;
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
GuildExperimentFilter next = it.next();
|
|
if (next instanceof GuildExperimentFilter.GuildIdsFilter) {
|
|
if (!((GuildExperimentFilter.GuildIdsFilter) next).getGuildIds().contains(Long.valueOf(j))) {
|
|
}
|
|
} else if (next instanceof GuildExperimentFilter.GuildIdRangeFilter) {
|
|
if (!((GuildExperimentFilter.GuildIdRangeFilter) next).getRange().contains(j)) {
|
|
}
|
|
} else if (next instanceof GuildExperimentFilter.GuildMemberCountRangeFilter) {
|
|
if (!f.longRangeContains(((GuildExperimentFilter.GuildMemberCountRangeFilter) next).getRange(), i)) {
|
|
z8 = false;
|
|
}
|
|
} else if (next instanceof GuildExperimentFilter.GuildHasFeatureFilter) {
|
|
Set<GuildFeature> features = ((GuildExperimentFilter.GuildHasFeatureFilter) next).getFeatures();
|
|
if (!(features instanceof Collection) || !features.isEmpty()) {
|
|
Iterator<T> it2 = features.iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
break;
|
|
}
|
|
GuildFeature guildFeature = (GuildFeature) it2.next();
|
|
if (guild == null || !guild.hasFeature(guildFeature)) {
|
|
z5 = false;
|
|
continue;
|
|
} else {
|
|
z5 = true;
|
|
continue;
|
|
}
|
|
if (z5) {
|
|
z4 = false;
|
|
break;
|
|
}
|
|
}
|
|
if (!z4) {
|
|
z8 = false;
|
|
}
|
|
}
|
|
z4 = true;
|
|
if (!z4) {
|
|
}
|
|
} else if (next instanceof GuildExperimentFilter.GuildHubTypesFeatureFilter) {
|
|
Set<GuildHubType> hubTypes = ((GuildExperimentFilter.GuildHubTypesFeatureFilter) next).getHubTypes();
|
|
if (!(hubTypes instanceof Collection) || !hubTypes.isEmpty()) {
|
|
Iterator<T> it3 = hubTypes.iterator();
|
|
while (true) {
|
|
if (!it3.hasNext()) {
|
|
break;
|
|
}
|
|
if ((guild != null ? guild.getHubType() : null) == ((GuildHubType) it3.next())) {
|
|
z7 = true;
|
|
continue;
|
|
} else {
|
|
z7 = false;
|
|
continue;
|
|
}
|
|
if (z7) {
|
|
z6 = false;
|
|
break;
|
|
}
|
|
}
|
|
if (!z6) {
|
|
z8 = false;
|
|
}
|
|
}
|
|
z6 = true;
|
|
if (!z6) {
|
|
}
|
|
}
|
|
z8 = false;
|
|
}
|
|
if (z8) {
|
|
Iterator<T> it4 = guildExperimentPopulationDto.getBuckets().iterator();
|
|
while (true) {
|
|
if (!it4.hasNext()) {
|
|
break;
|
|
}
|
|
Object next2 = it4.next();
|
|
List<IntRange> positions = ((GuildExperimentBucketDto) next2).getPositions();
|
|
if (!(positions instanceof Collection) || !positions.isEmpty()) {
|
|
Iterator<T> it5 = positions.iterator();
|
|
while (true) {
|
|
if (!it5.hasNext()) {
|
|
break;
|
|
}
|
|
IntRange intRange = (IntRange) it5.next();
|
|
if (from < ((long) intRange.getFirst()) || from >= ((long) intRange.getLast())) {
|
|
z3 = false;
|
|
continue;
|
|
} else {
|
|
z3 = true;
|
|
continue;
|
|
}
|
|
if (z3) {
|
|
z2 = true;
|
|
continue;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
continue;
|
|
if (z2) {
|
|
obj = next2;
|
|
break;
|
|
}
|
|
}
|
|
GuildExperimentBucketDto guildExperimentBucketDto = (GuildExperimentBucketDto) obj;
|
|
if (guildExperimentBucketDto != null) {
|
|
return guildExperimentBucketDto.getBucket();
|
|
}
|
|
return 0;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
}
|