234 lines
8.6 KiB
Java
234 lines
8.6 KiB
Java
package com.discord.utilities.permissions;
|
|
|
|
import c.d.b.a.a;
|
|
import com.discord.api.role.GuildRole;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.models.user.User;
|
|
import com.discord.utilities.guilds.RoleUtils;
|
|
import d0.z.d.m;
|
|
import java.util.Collection;
|
|
import java.util.Map;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: PermissionsContexts.kt */
|
|
public final class ManageUserContext {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final boolean canBan;
|
|
private final boolean canChangeNickname;
|
|
private final boolean canDeafen;
|
|
private final boolean canKick;
|
|
private final boolean canManageRoles;
|
|
private final boolean canMove;
|
|
private final boolean canMute;
|
|
private final boolean canTransferOwnership;
|
|
|
|
/* compiled from: PermissionsContexts.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final ManageUserContext from(Guild guild, MeUser meUser, User user, Collection<Long> collection, Collection<Long> collection2, Long l, Map<Long, GuildRole> map) {
|
|
m.checkNotNullParameter(guild, "guild");
|
|
m.checkNotNullParameter(meUser, "actingUser");
|
|
m.checkNotNullParameter(user, "targetUser");
|
|
m.checkNotNullParameter(collection, "actingUserRoles");
|
|
m.checkNotNullParameter(collection2, "userRoles");
|
|
m.checkNotNullParameter(map, "guildRoles");
|
|
long id2 = user.getId();
|
|
long id3 = meUser.getId();
|
|
boolean z2 = id3 == id2;
|
|
boolean z3 = id3 == guild.getOwnerId();
|
|
boolean z4 = z3 || (!((id2 > guild.getOwnerId() ? 1 : (id2 == guild.getOwnerId() ? 0 : -1)) == 0) && RoleUtils.rankIsHigher(RoleUtils.getHighestRole(map, collection), RoleUtils.getHighestRole(map, collection2)));
|
|
int mfaLevel = guild.getMfaLevel();
|
|
boolean mfaEnabled = meUser.getMfaEnabled();
|
|
boolean z5 = z3 || PermissionUtils.canAndIsElevated(8, l, mfaEnabled, mfaLevel);
|
|
return new ManageUserContext((z2 || z4) && (z5 || PermissionUtils.canAndIsElevated(268435456, l, mfaEnabled, mfaLevel)), !z2 && z4 && (z5 || PermissionUtils.canAndIsElevated(2, l, mfaEnabled, mfaLevel)), !z2 && z4 && (z5 || PermissionUtils.canAndIsElevated(4, l, mfaEnabled, mfaLevel)), z5 || PermissionUtils.can(4194304, l), z5 || PermissionUtils.can(8388608, l), z5 || PermissionUtils.can(16777216, l), !z2 ? !(!z4 || (!z5 && !PermissionUtils.canAndIsElevated(134217728, l, mfaEnabled, mfaLevel))) : !(!z5 && !PermissionUtils.can(67108864, l)), !z2 && z3);
|
|
}
|
|
}
|
|
|
|
public ManageUserContext(boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, boolean z8, boolean z9) {
|
|
this.canManageRoles = z2;
|
|
this.canKick = z3;
|
|
this.canBan = z4;
|
|
this.canMute = z5;
|
|
this.canDeafen = z6;
|
|
this.canMove = z7;
|
|
this.canChangeNickname = z8;
|
|
this.canTransferOwnership = z9;
|
|
}
|
|
|
|
private final boolean component8() {
|
|
return this.canTransferOwnership;
|
|
}
|
|
|
|
public static /* synthetic */ ManageUserContext copy$default(ManageUserContext manageUserContext, boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, boolean z8, boolean z9, int i, Object obj) {
|
|
return manageUserContext.copy((i & 1) != 0 ? manageUserContext.canManageRoles : z2, (i & 2) != 0 ? manageUserContext.canKick : z3, (i & 4) != 0 ? manageUserContext.canBan : z4, (i & 8) != 0 ? manageUserContext.canMute : z5, (i & 16) != 0 ? manageUserContext.canDeafen : z6, (i & 32) != 0 ? manageUserContext.canMove : z7, (i & 64) != 0 ? manageUserContext.canChangeNickname : z8, (i & 128) != 0 ? manageUserContext.canTransferOwnership : z9);
|
|
}
|
|
|
|
public static final ManageUserContext from(Guild guild, MeUser meUser, User user, Collection<Long> collection, Collection<Long> collection2, Long l, Map<Long, GuildRole> map) {
|
|
return Companion.from(guild, meUser, user, collection, collection2, l, map);
|
|
}
|
|
|
|
public final boolean canManage() {
|
|
return this.canManageRoles || this.canKick || this.canBan || this.canMute || this.canDeafen || this.canMove || this.canChangeNickname || this.canTransferOwnership;
|
|
}
|
|
|
|
public final boolean component1() {
|
|
return this.canManageRoles;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.canKick;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.canBan;
|
|
}
|
|
|
|
public final boolean component4() {
|
|
return this.canMute;
|
|
}
|
|
|
|
public final boolean component5() {
|
|
return this.canDeafen;
|
|
}
|
|
|
|
public final boolean component6() {
|
|
return this.canMove;
|
|
}
|
|
|
|
public final boolean component7() {
|
|
return this.canChangeNickname;
|
|
}
|
|
|
|
public final ManageUserContext copy(boolean z2, boolean z3, boolean z4, boolean z5, boolean z6, boolean z7, boolean z8, boolean z9) {
|
|
return new ManageUserContext(z2, z3, z4, z5, z6, z7, z8, z9);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ManageUserContext)) {
|
|
return false;
|
|
}
|
|
ManageUserContext manageUserContext = (ManageUserContext) obj;
|
|
return this.canManageRoles == manageUserContext.canManageRoles && this.canKick == manageUserContext.canKick && this.canBan == manageUserContext.canBan && this.canMute == manageUserContext.canMute && this.canDeafen == manageUserContext.canDeafen && this.canMove == manageUserContext.canMove && this.canChangeNickname == manageUserContext.canChangeNickname && this.canTransferOwnership == manageUserContext.canTransferOwnership;
|
|
}
|
|
|
|
public final boolean getCanBan() {
|
|
return this.canBan;
|
|
}
|
|
|
|
public final boolean getCanChangeNickname() {
|
|
return this.canChangeNickname;
|
|
}
|
|
|
|
public final boolean getCanDeafen() {
|
|
return this.canDeafen;
|
|
}
|
|
|
|
public final boolean getCanKick() {
|
|
return this.canKick;
|
|
}
|
|
|
|
public final boolean getCanManageRoles() {
|
|
return this.canManageRoles;
|
|
}
|
|
|
|
public final boolean getCanMove() {
|
|
return this.canMove;
|
|
}
|
|
|
|
public final boolean getCanMute() {
|
|
return this.canMute;
|
|
}
|
|
|
|
public int hashCode() {
|
|
boolean z2 = this.canManageRoles;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = i2 * 31;
|
|
boolean z3 = this.canKick;
|
|
if (z3) {
|
|
z3 = true;
|
|
}
|
|
int i6 = z3 ? 1 : 0;
|
|
int i7 = z3 ? 1 : 0;
|
|
int i8 = z3 ? 1 : 0;
|
|
int i9 = (i5 + i6) * 31;
|
|
boolean z4 = this.canBan;
|
|
if (z4) {
|
|
z4 = true;
|
|
}
|
|
int i10 = z4 ? 1 : 0;
|
|
int i11 = z4 ? 1 : 0;
|
|
int i12 = z4 ? 1 : 0;
|
|
int i13 = (i9 + i10) * 31;
|
|
boolean z5 = this.canMute;
|
|
if (z5) {
|
|
z5 = true;
|
|
}
|
|
int i14 = z5 ? 1 : 0;
|
|
int i15 = z5 ? 1 : 0;
|
|
int i16 = z5 ? 1 : 0;
|
|
int i17 = (i13 + i14) * 31;
|
|
boolean z6 = this.canDeafen;
|
|
if (z6) {
|
|
z6 = true;
|
|
}
|
|
int i18 = z6 ? 1 : 0;
|
|
int i19 = z6 ? 1 : 0;
|
|
int i20 = z6 ? 1 : 0;
|
|
int i21 = (i17 + i18) * 31;
|
|
boolean z7 = this.canMove;
|
|
if (z7) {
|
|
z7 = true;
|
|
}
|
|
int i22 = z7 ? 1 : 0;
|
|
int i23 = z7 ? 1 : 0;
|
|
int i24 = z7 ? 1 : 0;
|
|
int i25 = (i21 + i22) * 31;
|
|
boolean z8 = this.canChangeNickname;
|
|
if (z8) {
|
|
z8 = true;
|
|
}
|
|
int i26 = z8 ? 1 : 0;
|
|
int i27 = z8 ? 1 : 0;
|
|
int i28 = z8 ? 1 : 0;
|
|
int i29 = (i25 + i26) * 31;
|
|
boolean z9 = this.canTransferOwnership;
|
|
if (!z9) {
|
|
i = z9 ? 1 : 0;
|
|
}
|
|
return i29 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ManageUserContext(canManageRoles=");
|
|
K.append(this.canManageRoles);
|
|
K.append(", canKick=");
|
|
K.append(this.canKick);
|
|
K.append(", canBan=");
|
|
K.append(this.canBan);
|
|
K.append(", canMute=");
|
|
K.append(this.canMute);
|
|
K.append(", canDeafen=");
|
|
K.append(this.canDeafen);
|
|
K.append(", canMove=");
|
|
K.append(this.canMove);
|
|
K.append(", canChangeNickname=");
|
|
K.append(this.canChangeNickname);
|
|
K.append(", canTransferOwnership=");
|
|
return a.F(K, this.canTransferOwnership, ")");
|
|
}
|
|
}
|