379 lines
15 KiB
Java
379 lines
15 KiB
Java
package com.discord.widgets.channels.permissions;
|
|
|
|
import a0.a.a.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.channel.Channel;
|
|
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.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import d0.z.d.m;
|
|
import j0.l.e.j;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetChannelSettingsEditPermissionsModel.kt */
|
|
public abstract class WidgetChannelSettingsEditPermissionsModel {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final Channel channel;
|
|
private final long targetId;
|
|
private final int type;
|
|
|
|
/* compiled from: WidgetChannelSettingsEditPermissionsModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public static final /* synthetic */ boolean access$isAbleToManagePerms(Companion companion, Guild guild, MeUser meUser, long j) {
|
|
return companion.isAbleToManagePerms(guild, meUser, j);
|
|
}
|
|
|
|
private final Observable<WidgetChannelSettingsEditPermissionsModel> getForRole(long j, long j2, long j3) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable f = Observable.f(companion.getChannels().observeChannel(j2), StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getGuilds().observeGuild(j), companion.getPermissions().observePermissionsForChannel(j2), companion.getGuilds().observeRoles(j), companion.getGuilds().observeComputed(j), new WidgetChannelSettingsEditPermissionsModel$Companion$getForRole$1(j3));
|
|
m.checkNotNullExpressionValue(f, "Observable\n .… }\n }");
|
|
Observable<WidgetChannelSettingsEditPermissionsModel> r = ObservableExtensionsKt.computationLatest(f).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n .… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
private final Observable<WidgetChannelSettingsEditPermissionsModel> getForUser(long j, long j2, long j3) {
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
Observable g = Observable.g(companion.getChannels().observeChannel(j2), StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getUsers().observeUser(j3), companion.getGuilds().observeGuild(j), companion.getPermissions().observePermissionsForChannel(j2), WidgetChannelSettingsEditPermissionsModel$Companion$getForUser$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(g, "Observable\n .… }\n }");
|
|
Observable<WidgetChannelSettingsEditPermissionsModel> r = ObservableExtensionsKt.computationLatest(g).r();
|
|
m.checkNotNullExpressionValue(r, "Observable\n .… .distinctUntilChanged()");
|
|
return r;
|
|
}
|
|
|
|
private final boolean isAbleToManagePerms(Guild guild, MeUser meUser, long j) {
|
|
return ((guild.getOwnerId() > meUser.getId() ? 1 : (guild.getOwnerId() == meUser.getId() ? 0 : -1)) == 0) || PermissionUtils.canAndIsElevated(268435456, Long.valueOf(j), meUser.getMfaEnabled(), guild.getMfaLevel()) || PermissionUtils.canAndIsElevated(8, Long.valueOf(j), meUser.getMfaEnabled(), guild.getMfaLevel());
|
|
}
|
|
|
|
public final Observable<WidgetChannelSettingsEditPermissionsModel> get(long j, long j2, long j3, int i) {
|
|
if (i == 0) {
|
|
return getForUser(j, j2, j3);
|
|
}
|
|
if (i == 1) {
|
|
return getForRole(j, j2, j3);
|
|
}
|
|
j jVar = new j(null);
|
|
m.checkNotNullExpressionValue(jVar, "Observable\n .just(null)");
|
|
return jVar;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChannelSettingsEditPermissionsModel.kt */
|
|
public static final class ModelForRole extends WidgetChannelSettingsEditPermissionsModel {
|
|
private final Channel channel;
|
|
private final GuildRole guildRole;
|
|
private final boolean isEveryoneRole;
|
|
private final boolean meHasRole;
|
|
private final long myPermissionsForChannel;
|
|
private final long myPermissionsWithRoleDenied;
|
|
private final long myPermissionsWithRoleNeutral;
|
|
private final long targetId;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ModelForRole(Channel channel, long j, GuildRole guildRole, long j2, long j3, long j4, boolean z2, boolean z3) {
|
|
super(channel, j2, 1, null);
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(guildRole, "guildRole");
|
|
this.channel = channel;
|
|
this.myPermissionsForChannel = j;
|
|
this.guildRole = guildRole;
|
|
this.targetId = j2;
|
|
this.myPermissionsWithRoleNeutral = j3;
|
|
this.myPermissionsWithRoleDenied = j4;
|
|
this.meHasRole = z2;
|
|
this.isEveryoneRole = z3;
|
|
}
|
|
|
|
public static /* synthetic */ ModelForRole copy$default(ModelForRole modelForRole, Channel channel, long j, GuildRole guildRole, long j2, long j3, long j4, boolean z2, boolean z3, int i, Object obj) {
|
|
return modelForRole.copy((i & 1) != 0 ? modelForRole.getChannel() : channel, (i & 2) != 0 ? modelForRole.myPermissionsForChannel : j, (i & 4) != 0 ? modelForRole.guildRole : guildRole, (i & 8) != 0 ? modelForRole.getTargetId() : j2, (i & 16) != 0 ? modelForRole.myPermissionsWithRoleNeutral : j3, (i & 32) != 0 ? modelForRole.myPermissionsWithRoleDenied : j4, (i & 64) != 0 ? modelForRole.meHasRole : z2, (i & 128) != 0 ? modelForRole.isEveryoneRole : z3);
|
|
}
|
|
|
|
public final boolean canDenyRolePermission(long j) {
|
|
return (this.myPermissionsWithRoleDenied & j) == (j & this.myPermissionsForChannel);
|
|
}
|
|
|
|
public final boolean canNeutralizeRolePermission(long j) {
|
|
return (this.myPermissionsWithRoleNeutral & j) == (j & this.myPermissionsForChannel);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return getChannel();
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.myPermissionsForChannel;
|
|
}
|
|
|
|
public final GuildRole component3() {
|
|
return this.guildRole;
|
|
}
|
|
|
|
public final long component4() {
|
|
return getTargetId();
|
|
}
|
|
|
|
public final long component5() {
|
|
return this.myPermissionsWithRoleNeutral;
|
|
}
|
|
|
|
public final long component6() {
|
|
return this.myPermissionsWithRoleDenied;
|
|
}
|
|
|
|
public final boolean component7() {
|
|
return this.meHasRole;
|
|
}
|
|
|
|
public final boolean component8() {
|
|
return this.isEveryoneRole;
|
|
}
|
|
|
|
public final ModelForRole copy(Channel channel, long j, GuildRole guildRole, long j2, long j3, long j4, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(guildRole, "guildRole");
|
|
return new ModelForRole(channel, j, guildRole, j2, j3, j4, z2, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ModelForRole)) {
|
|
return false;
|
|
}
|
|
ModelForRole modelForRole = (ModelForRole) obj;
|
|
return m.areEqual(getChannel(), modelForRole.getChannel()) && this.myPermissionsForChannel == modelForRole.myPermissionsForChannel && m.areEqual(this.guildRole, modelForRole.guildRole) && getTargetId() == modelForRole.getTargetId() && this.myPermissionsWithRoleNeutral == modelForRole.myPermissionsWithRoleNeutral && this.myPermissionsWithRoleDenied == modelForRole.myPermissionsWithRoleDenied && this.meHasRole == modelForRole.meHasRole && this.isEveryoneRole == modelForRole.isEveryoneRole;
|
|
}
|
|
|
|
@Override // com.discord.widgets.channels.permissions.WidgetChannelSettingsEditPermissionsModel
|
|
public Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final GuildRole getGuildRole() {
|
|
return this.guildRole;
|
|
}
|
|
|
|
public final boolean getMeHasRole() {
|
|
return this.meHasRole;
|
|
}
|
|
|
|
public final long getMyPermissionsForChannel() {
|
|
return this.myPermissionsForChannel;
|
|
}
|
|
|
|
public final long getMyPermissionsWithRoleDenied() {
|
|
return this.myPermissionsWithRoleDenied;
|
|
}
|
|
|
|
public final long getMyPermissionsWithRoleNeutral() {
|
|
return this.myPermissionsWithRoleNeutral;
|
|
}
|
|
|
|
@Override // com.discord.widgets.channels.permissions.WidgetChannelSettingsEditPermissionsModel
|
|
public long getTargetId() {
|
|
return this.targetId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = getChannel();
|
|
int i = 0;
|
|
int a = (b.a(this.myPermissionsForChannel) + ((channel != null ? channel.hashCode() : 0) * 31)) * 31;
|
|
GuildRole guildRole = this.guildRole;
|
|
if (guildRole != null) {
|
|
i = guildRole.hashCode();
|
|
}
|
|
int a2 = b.a(getTargetId());
|
|
int a3 = (b.a(this.myPermissionsWithRoleDenied) + ((b.a(this.myPermissionsWithRoleNeutral) + ((a2 + ((a + i) * 31)) * 31)) * 31)) * 31;
|
|
boolean z2 = this.meHasRole;
|
|
int i2 = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
int i6 = (a3 + i3) * 31;
|
|
boolean z3 = this.isEveryoneRole;
|
|
if (!z3) {
|
|
i2 = z3 ? 1 : 0;
|
|
}
|
|
return i6 + i2;
|
|
}
|
|
|
|
public final boolean isEveryoneRole() {
|
|
return this.isEveryoneRole;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ModelForRole(channel=");
|
|
K.append(getChannel());
|
|
K.append(", myPermissionsForChannel=");
|
|
K.append(this.myPermissionsForChannel);
|
|
K.append(", guildRole=");
|
|
K.append(this.guildRole);
|
|
K.append(", targetId=");
|
|
K.append(getTargetId());
|
|
K.append(", myPermissionsWithRoleNeutral=");
|
|
K.append(this.myPermissionsWithRoleNeutral);
|
|
K.append(", myPermissionsWithRoleDenied=");
|
|
K.append(this.myPermissionsWithRoleDenied);
|
|
K.append(", meHasRole=");
|
|
K.append(this.meHasRole);
|
|
K.append(", isEveryoneRole=");
|
|
return a.F(K, this.isEveryoneRole, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChannelSettingsEditPermissionsModel.kt */
|
|
public static final class ModelForUser extends WidgetChannelSettingsEditPermissionsModel {
|
|
private final Channel channel;
|
|
private final boolean isMe;
|
|
private final long myPermissionsForChannel;
|
|
private final User user;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public ModelForUser(Channel channel, long j, boolean z2, User user) {
|
|
super(channel, user.getId(), 0, null);
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(user, "user");
|
|
this.channel = channel;
|
|
this.myPermissionsForChannel = j;
|
|
this.isMe = z2;
|
|
this.user = user;
|
|
}
|
|
|
|
public static /* synthetic */ ModelForUser copy$default(ModelForUser modelForUser, Channel channel, long j, boolean z2, User user, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
channel = modelForUser.getChannel();
|
|
}
|
|
if ((i & 2) != 0) {
|
|
j = modelForUser.myPermissionsForChannel;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z2 = modelForUser.isMe;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
user = modelForUser.user;
|
|
}
|
|
return modelForUser.copy(channel, j, z2, user);
|
|
}
|
|
|
|
public final Channel component1() {
|
|
return getChannel();
|
|
}
|
|
|
|
public final long component2() {
|
|
return this.myPermissionsForChannel;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.isMe;
|
|
}
|
|
|
|
public final User component4() {
|
|
return this.user;
|
|
}
|
|
|
|
public final ModelForUser copy(Channel channel, long j, boolean z2, User user) {
|
|
m.checkNotNullParameter(channel, "channel");
|
|
m.checkNotNullParameter(user, "user");
|
|
return new ModelForUser(channel, j, z2, user);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ModelForUser)) {
|
|
return false;
|
|
}
|
|
ModelForUser modelForUser = (ModelForUser) obj;
|
|
return m.areEqual(getChannel(), modelForUser.getChannel()) && this.myPermissionsForChannel == modelForUser.myPermissionsForChannel && this.isMe == modelForUser.isMe && m.areEqual(this.user, modelForUser.user);
|
|
}
|
|
|
|
@Override // com.discord.widgets.channels.permissions.WidgetChannelSettingsEditPermissionsModel
|
|
public Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public final long getMyPermissionsForChannel() {
|
|
return this.myPermissionsForChannel;
|
|
}
|
|
|
|
public final User getUser() {
|
|
return this.user;
|
|
}
|
|
|
|
public int hashCode() {
|
|
Channel channel = getChannel();
|
|
int i = 0;
|
|
int a = (b.a(this.myPermissionsForChannel) + ((channel != null ? channel.hashCode() : 0) * 31)) * 31;
|
|
boolean z2 = this.isMe;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (a + i2) * 31;
|
|
User user = this.user;
|
|
if (user != null) {
|
|
i = user.hashCode();
|
|
}
|
|
return i5 + i;
|
|
}
|
|
|
|
public final boolean isMe() {
|
|
return this.isMe;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ModelForUser(channel=");
|
|
K.append(getChannel());
|
|
K.append(", myPermissionsForChannel=");
|
|
K.append(this.myPermissionsForChannel);
|
|
K.append(", isMe=");
|
|
K.append(this.isMe);
|
|
K.append(", user=");
|
|
K.append(this.user);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
private WidgetChannelSettingsEditPermissionsModel(Channel channel, long j, int i) {
|
|
this.channel = channel;
|
|
this.targetId = j;
|
|
this.type = i;
|
|
}
|
|
|
|
public /* synthetic */ WidgetChannelSettingsEditPermissionsModel(Channel channel, long j, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(channel, j, i);
|
|
}
|
|
|
|
public Channel getChannel() {
|
|
return this.channel;
|
|
}
|
|
|
|
public long getTargetId() {
|
|
return this.targetId;
|
|
}
|
|
|
|
public final int getType() {
|
|
return this.type;
|
|
}
|
|
}
|