From 15d4e20d94bb77c2aa4bad77946a86543f6e3c97 Mon Sep 17 00:00:00 2001 From: Holly Date: Tue, 4 Jan 2022 04:43:32 +0000 Subject: [PATCH] support saving away messages --- osu!.sql | 3 ++- server/Packets/SetAwayMessage.js | 4 ++++ server/serverHandler.js | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 server/Packets/SetAwayMessage.js diff --git a/osu!.sql b/osu!.sql index d95a428..1d3200b 100755 --- a/osu!.sql +++ b/osu!.sql @@ -47,7 +47,8 @@ CREATE TABLE `users_info` ( `web_session` varchar(64) NOT NULL, `verification_needed` tinyint(1) NOT NULL DEFAULT '0', `password_change_required` tinyint(1) NOT NULL, - `has_old_password` tinyint(1) NOT NULL DEFAULT '0' + `has_old_password` tinyint(1) NOT NULL DEFAULT '0', + `away_message` varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `users_modes_info` ( diff --git a/server/Packets/SetAwayMessage.js b/server/Packets/SetAwayMessage.js new file mode 100644 index 0000000..be72127 --- /dev/null +++ b/server/Packets/SetAwayMessage.js @@ -0,0 +1,4 @@ +module.exports = function(CurrentUser, Message) { + if (/[^0-9A-Za-z]/.test(Message.message)) return; + global.DatabaseHelper.query(`UPDATE users_info SET away_message = '${Message.message}' WHERE id = ${CurrentUser.id}`); +} \ No newline at end of file diff --git a/server/serverHandler.js b/server/serverHandler.js index c7ca911..f74ae4f 100644 --- a/server/serverHandler.js +++ b/server/serverHandler.js @@ -120,6 +120,7 @@ const ChangeAction = require("./Packets/ChangeAction.js"), Spectator = require("./Spectator.js"), SendPrivateMessage = require("./Packets/SendPrivateMessage.js"), MultiplayerManager = require("./MultiplayerManager.js"), + SetAwayMessage = require("./Packets/SetAwayMessage.js"), ChannelJoin = require("./Packets/ChannelJoin.js"), ChannelPart = require("./Packets/ChannelPart.js"), AddFriend = require("./Packets/AddFriend.js"), @@ -299,6 +300,10 @@ module.exports = async function(req, res) { ChannelPart(PacketUser, CurrentPacket.data); break; + case packetIDs.client_setAwayMessage: + SetAwayMessage(PacketUser, CurrentPacket.data); + break; + case packetIDs.client_friendAdd: AddFriend(PacketUser, CurrentPacket.data); break;