Add forum thread/comment reporting

This commit is contained in:
Alejandro 2019-05-30 21:05:25 +03:00
parent 775ec86974
commit 25d8ffba96
11 changed files with 191 additions and 20 deletions

View File

@ -10,4 +10,9 @@ ALTER TABLE `users_settings`
ADD COLUMN `ui_flags` int(11) NOT NULL DEFAULT 1 AFTER `forums_post_count`;
ALTER TABLE `users_settings`
ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`;
ADD COLUMN `has_gotten_default_saved_searches` tinyint(1) NOT NULL DEFAULT 0 AFTER `ui_flags`;
ALTER TABLE `support_tickets`
ADD COLUMN `group_id` int(11) NOT NULL AFTER `category`,
ADD COLUMN `thread_id` int(11) NOT NULL AFTER `group_id`,
ADD COLUMN `comment_id` int(11) NOT NULL AFTER `thread_id`;

View File

@ -5,12 +5,22 @@ public class ModToolChatLog implements Comparable<ModToolChatLog> {
public final int habboId;
public final String username;
public final String message;
public final boolean highlighted;
public ModToolChatLog(int timestamp, int habboId, String username, String message) {
this.timestamp = timestamp;
this.habboId = habboId;
this.username = username;
this.message = message;
this.highlighted = false;
}
public ModToolChatLog(int timestamp, int habboId, String username, String message, boolean highlighted) {
this.timestamp = timestamp;
this.habboId = habboId;
this.username = username;
this.message = message;
this.highlighted = highlighted;
}
@Override

View File

@ -25,6 +25,9 @@ public class ModToolIssue implements ISerialize {
public volatile String modName = "";
public String message;
public ArrayList<ModToolChatLog> chatLogs = null;
public int groupId = -1;
public int threadId = -1;
public int commentId = -1;
public ModToolIssue(ResultSet set) throws SQLException {
this.id = set.getInt("id");

View File

@ -0,0 +1,21 @@
package com.eu.habbo.habbohotel.modtool;
public enum ModToolIssueChatlogType {
NORMAL(0),
CHAT(1),
IM(2),
FORUM_THREAD(3),
FORUM_COMMENT(4),
SELFIE(5),
PHOTO(6);
private int type;
ModToolIssueChatlogType(int type) {
this.type = type;
}
public int getType() {
return type;
}
}

View File

@ -466,6 +466,8 @@ public class PacketManager {
this.registerHandler(Incoming.ReportBullyEvent, ReportBullyEvent.class);
this.registerHandler(Incoming.ReportEvent, ReportEvent.class);
this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class);
this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class);
this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class);
}
void registerTrading() throws Exception {

View File

@ -290,6 +290,8 @@ public class Incoming {
public static final int SaveWindowSettingsEvent = 3159;
public static final int GetHabboGuildBadgesMessageEvent = 21;
public static final int UpdateUIFlagsEvent = 2313;
public static final int ReportThreadEvent = 534;
public static final int ReportCommentEvent = 1412;
public static final int RequestCraftingRecipesEvent = 1173;
public static final int RequestCraftingRecipesAvailableEvent = 3086;

View File

@ -1,16 +1,16 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.ModToolChatLog;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketType;
import com.eu.habbo.habbohotel.modtool.ScripterManager;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.modtool.*;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueChatlogComposer;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class ModToolRequestIssueChatlogEvent extends MessageHandler {
@Override
@ -19,11 +19,33 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler {
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt());
if (issue != null) {
ArrayList<ModToolChatLog> chatlog;
List<ModToolChatLog> chatlog = new ArrayList<>();
ModToolIssueChatlogType chatlogType = ModToolIssueChatlogType.CHAT;
if (issue.type == ModToolTicketType.IM) {
chatlog = Emulator.getGameEnvironment().getModToolManager().getMessengerChatlog(issue.reportedId, issue.senderId);
chatlogType = ModToolIssueChatlogType.IM;
} else if (issue.type == ModToolTicketType.DISCUSSION) {
if (issue.commentId == -1) {
chatlogType = ModToolIssueChatlogType.FORUM_THREAD;
ForumThread thread = ForumThread.getById(issue.threadId);
if (thread != null) {
chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage())).collect(Collectors.toList());
}
} else {
chatlogType = ModToolIssueChatlogType.FORUM_COMMENT;
ForumThread thread = ForumThread.getById(issue.threadId);
if (thread != null) {
chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage(), c.getCommentId() == issue.commentId)).collect(Collectors.toList());
}
}
} else {
chatlogType = ModToolIssueChatlogType.CHAT;
if (issue.roomId > 0) {
chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId);
} else {
@ -39,7 +61,7 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler {
if (room != null) {
roomName = room.getName();
}
this.client.sendResponse(new ModToolIssueChatlogComposer(issue, chatlog, roomName));
this.client.sendResponse(new ModToolIssueChatlogComposer(issue, chatlog, roomName, chatlogType));
}
} else {
ScripterManager.scripterDetected(this.client, Emulator.getTexts().getValue("scripter.warning.modtools.chatlog").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()));

View File

@ -0,0 +1,43 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.modtool.CfhTopic;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer;
import com.eu.habbo.threading.runnables.InsertModToolIssue;
public class ReportCommentEvent extends MessageHandler {
@Override
public void handle() throws Exception {
int groupId = this.packet.readInt();
int threadId = this.packet.readInt();
int commentId = this.packet.readInt();
int topicId = this.packet.readInt();
String message = this.packet.readString();
CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId);
if (topic == null) return;
ForumThread thread = ForumThread.getById(threadId);
if (thread == null) return;
Habbo opener = Emulator.getGameEnvironment().getHabboManager().getHabbo(thread.getOpenerId());
ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), thread.getOpenerId(), opener == null ? "" : opener.getHabboInfo().getUsername(), 0, message, ModToolTicketType.DISCUSSION);
issue.category = topicId;
issue.groupId = groupId;
issue.threadId = threadId;
issue.commentId = commentId;
new InsertModToolIssue(issue).run();
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message));
Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
}
}

View File

@ -0,0 +1,41 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.modtool.CfhTopic;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer;
import com.eu.habbo.threading.runnables.InsertModToolIssue;
public class ReportThreadEvent extends MessageHandler {
@Override
public void handle() throws Exception {
int groupId = this.packet.readInt();
int threadId = this.packet.readInt();
int topicId = this.packet.readInt();
String message = this.packet.readString();
CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId);
if (topic == null) return;
ForumThread thread = ForumThread.getById(threadId);
if (thread == null) return;
Habbo opener = Emulator.getGameEnvironment().getHabboManager().getHabbo(thread.getOpenerId());
ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), thread.getOpenerId(), opener == null ? "" : opener.getHabboInfo().getUsername(), 0, message, ModToolTicketType.DISCUSSION);
issue.category = topicId;
issue.groupId = groupId;
issue.threadId = threadId;
new InsertModToolIssue(issue).run();
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message));
Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
}
}

View File

@ -1,9 +1,8 @@
package com.eu.habbo.messages.outgoing.modtool;
import com.eu.habbo.habbohotel.modtool.ModToolChatLog;
import com.eu.habbo.habbohotel.modtool.ModToolChatRecordDataContext;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketType;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.*;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
@ -11,19 +10,28 @@ import com.eu.habbo.messages.outgoing.Outgoing;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ModToolIssueChatlogComposer extends MessageComposer {
public static SimpleDateFormat format = new SimpleDateFormat("HH:mm");
private final ModToolIssue issue;
private final ArrayList<ModToolChatLog> chatlog;
private final List<ModToolChatLog> chatlog;
private final String roomName;
private ModToolIssueChatlogType type = ModToolIssueChatlogType.CHAT;
public ModToolIssueChatlogComposer(ModToolIssue issue, ArrayList<ModToolChatLog> chatlog, String roomName) {
public ModToolIssueChatlogComposer(ModToolIssue issue, List<ModToolChatLog> chatlog, String roomName) {
this.issue = issue;
this.chatlog = chatlog;
this.roomName = roomName;
}
public ModToolIssueChatlogComposer(ModToolIssue issue, List<ModToolChatLog> chatlog, String roomName, ModToolIssueChatlogType type) {
this.issue = issue;
this.chatlog = chatlog;
this.roomName = roomName;
this.type = type;
}
@Override
public ServerMessage compose() {
this.response.init(Outgoing.ModToolIssueChatlogComposer);
@ -37,16 +45,26 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
if (this.chatlog.isEmpty())
return null;
//ChatRecordData
//for(ModToolRoomVisit visit : chatlog)
//{
this.response.appendByte(1); //Report Type
this.response.appendByte(this.type.getType()); //Report Type
if (this.issue.type == ModToolTicketType.IM) {
this.response.appendShort(1);
ModToolChatRecordDataContext.MESSAGE_ID.append(this.response);
this.response.appendInt(this.issue.senderId);
} else if (this.issue.type == ModToolTicketType.DISCUSSION) {
this.response.appendShort(this.type == ModToolIssueChatlogType.FORUM_COMMENT ? 3 : 2);
ModToolChatRecordDataContext.GROUP_ID.append(this.response);
this.response.appendInt(this.issue.groupId);
ModToolChatRecordDataContext.THREAD_ID.append(this.response);
this.response.appendInt(this.issue.threadId);
if (this.type == ModToolIssueChatlogType.FORUM_COMMENT) {
ModToolChatRecordDataContext.GROUP_ID.append(this.response);
this.response.appendInt(this.issue.commentId);
}
} else {
this.response.appendShort(3); //Context Count
@ -57,7 +75,8 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
this.response.appendInt(this.issue.roomId);
ModToolChatRecordDataContext.GROUP_ID.append(this.response);
this.response.appendInt(12);
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.issue.roomId);
this.response.appendInt(room == null ? 0 : room.getGuildId());
}
this.response.appendShort(this.chatlog.size());
@ -66,7 +85,7 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
this.response.appendInt(chatLog.habboId);
this.response.appendString(chatLog.username);
this.response.appendString(chatLog.message);
this.response.appendBoolean(false);
this.response.appendBoolean(chatLog.highlighted);
}
//}

View File

@ -14,7 +14,7 @@ public class InsertModToolIssue implements Runnable {
@Override
public void run() {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO support_tickets (state, timestamp, score, sender_id, reported_id, room_id, mod_id, issue, category, group_id, thread_id, comment_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, this.issue.state.getState());
statement.setInt(2, this.issue.timestamp);
statement.setInt(3, this.issue.priority);
@ -24,6 +24,9 @@ public class InsertModToolIssue implements Runnable {
statement.setInt(7, this.issue.modId);
statement.setString(8, this.issue.message);
statement.setInt(9, this.issue.category);
statement.setInt(10, this.issue.groupId);
statement.setInt(11, this.issue.threadId);
statement.setInt(12, this.issue.commentId);
statement.execute();
try (ResultSet key = statement.getGeneratedKeys()) {