Normal group members can no longer view hidden posts & admins can now hide & unhide posts.

This commit is contained in:
Harmonic 2022-04-12 17:06:00 -07:00
parent eb36d7018c
commit eecb8ba8fa
5 changed files with 31 additions and 26 deletions

View File

@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.guilds.forums;
public enum ForumThreadState { public enum ForumThreadState {
OPEN(0), OPEN(0),
CLOSED(1), CLOSED(1),
HIDDEN_BY_ADMIN(10), HIDDEN_BY_STAFF_MEMBER(10),
HIDDEN_BY_STAFF(20); HIDDEN_BY_GUILD_ADMIN(20);
private int stateId; private int stateId;

View File

@ -37,7 +37,7 @@ public class GuildForumModerateMessageEvent extends MessageHandler {
return; return;
} }
boolean isStaff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); boolean hasStaffPermissions = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q);
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
if (member == null) { if (member == null) {
@ -45,14 +45,14 @@ public class GuildForumModerateMessageEvent extends MessageHandler {
return; return;
} }
boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().type < GuildRank.MEMBER.type); boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN));
if (!isAdmin && !isStaff) { if (!isGuildAdministrator && !hasStaffPermissions) {
this.client.sendResponse(new ConnectionErrorComposer(403)); this.client.sendResponse(new ConnectionErrorComposer(403));
return; return;
} }
if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { if (state == ForumThreadState.HIDDEN_BY_GUILD_ADMIN.getStateId() && !hasStaffPermissions) {
this.client.sendResponse(new ConnectionErrorComposer(403)); this.client.sendResponse(new ConnectionErrorComposer(403));
return; return;
} }

View File

@ -21,6 +21,8 @@ public class GuildForumModerateThreadEvent extends MessageHandler {
int guildId = packet.readInt(); int guildId = packet.readInt();
int threadId = packet.readInt(); int threadId = packet.readInt();
int state = packet.readInt(); int state = packet.readInt();
// STATE 20 - HIDDEN_BY_GUILD_ADMIN = HIDDEN BY GUILD ADMINS/ HOTEL MODERATORS
// STATE 1 = VISIBLE THREAD
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
ForumThread thread = ForumThread.getById(threadId); ForumThread thread = ForumThread.getById(threadId);
@ -30,29 +32,21 @@ public class GuildForumModerateThreadEvent extends MessageHandler {
return; return;
} }
boolean isStaff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q);
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
boolean hasStaffPerms = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); // check for if they have staff perm
boolean isGuildAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN));
if (member == null) { if (member == null) {
this.client.sendResponse(new ConnectionErrorComposer(401)); this.client.sendResponse(new ConnectionErrorComposer(401));
return; return;
} }
if (!isGuildAdmin && !hasStaffPerms) {
boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().type < GuildRank.MEMBER.type);
if (!isAdmin && !isStaff) {
this.client.sendResponse(new ConnectionErrorComposer(403)); this.client.sendResponse(new ConnectionErrorComposer(403));
return; return;
} }
if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { thread.setState(ForumThreadState.fromValue(state)); // sets state as defined in the packet
this.client.sendResponse(new ConnectionErrorComposer(403));
return;
}
thread.setState(ForumThreadState.fromValue(state));
thread.setAdminId(this.client.getHabbo().getHabboInfo().getId());
thread.run(); thread.run();
switch (state) { switch (state) {

View File

@ -2,14 +2,21 @@ package com.eu.habbo.messages.incoming.guilds.forums;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.habbohotel.guilds.GuildMember;
import com.eu.habbo.habbohotel.guilds.GuildRank;
import com.eu.habbo.habbohotel.guilds.GuildState;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumCommentsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumCommentsComposer;
import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer;
import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer;
public class GuildForumThreadsMessagesEvent extends MessageHandler { public class GuildForumThreadsMessagesEvent extends MessageHandler {
@Override @Override
public void handle() throws Exception { public void handle() throws Exception {
@ -18,20 +25,23 @@ public class GuildForumThreadsMessagesEvent extends MessageHandler {
int index = packet.readInt(); // 40 int index = packet.readInt(); // 40
int limit = packet.readInt(); // 20 int limit = packet.readInt(); // 20
Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId);
ForumThread thread = ForumThread.getById(threadId); ForumThread thread = ForumThread.getById(threadId);
boolean hasStaffPermissions = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q);
if (guild == null || thread == null) { if (guild == null || thread == null) {
this.client.sendResponse(new ConnectionErrorComposer(404)); this.client.sendResponse(new ConnectionErrorComposer(404));
return; return;
} }
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId());
boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN));
if ((thread.getState() == ForumThreadState.HIDDEN_BY_ADMIN || thread.getState() == ForumThreadState.HIDDEN_BY_STAFF) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { if (thread.getState().getStateId() != 20 || hasStaffPermissions || isGuildAdministrator) {
this.client.sendResponse(new BubbleAlertComposer("oldforums.error.access_denied"));
} else {
this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index))); this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index)));
}
this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo())); this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo()));
} }
else {
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose());
}
}
} }

View File

@ -20,6 +20,7 @@ public enum BubbleAlertKeys {
FORUMS_MESSAGE_HIDDEN("forums.message.hidden"), FORUMS_MESSAGE_HIDDEN("forums.message.hidden"),
FORUMS_MESSAGE_RESTORED("forums.message.restored"), FORUMS_MESSAGE_RESTORED("forums.message.restored"),
FORUMS_THREAD_HIDDEN("forums.thread.hidden"), FORUMS_THREAD_HIDDEN("forums.thread.hidden"),
FORUMS_ACCESS_DENIED("forums.error.access_denied"),
FORUMS_THREAD_LOCKED("forums.thread.locked"), FORUMS_THREAD_LOCKED("forums.thread.locked"),
FORUMS_THREAD_PINNED("forums.thread.pinned"), FORUMS_THREAD_PINNED("forums.thread.pinned"),
FORUMS_THREAD_RESTORED("forums.thread.restored"), FORUMS_THREAD_RESTORED("forums.thread.restored"),