support saving away messages

This commit is contained in:
Holly Stubbs 2022-01-04 04:43:32 +00:00
parent 31af1d80bb
commit 15d4e20d94
Signed by: tgpholly
GPG key ID: B8583C4B7D18119E
3 changed files with 11 additions and 1 deletions

View file

@ -47,7 +47,8 @@ CREATE TABLE `users_info` (
`web_session` varchar(64) NOT NULL, `web_session` varchar(64) NOT NULL,
`verification_needed` tinyint(1) NOT NULL DEFAULT '0', `verification_needed` tinyint(1) NOT NULL DEFAULT '0',
`password_change_required` tinyint(1) NOT NULL, `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; ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `users_modes_info` ( CREATE TABLE `users_modes_info` (

View file

@ -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}`);
}

View file

@ -120,6 +120,7 @@ const ChangeAction = require("./Packets/ChangeAction.js"),
Spectator = require("./Spectator.js"), Spectator = require("./Spectator.js"),
SendPrivateMessage = require("./Packets/SendPrivateMessage.js"), SendPrivateMessage = require("./Packets/SendPrivateMessage.js"),
MultiplayerManager = require("./MultiplayerManager.js"), MultiplayerManager = require("./MultiplayerManager.js"),
SetAwayMessage = require("./Packets/SetAwayMessage.js"),
ChannelJoin = require("./Packets/ChannelJoin.js"), ChannelJoin = require("./Packets/ChannelJoin.js"),
ChannelPart = require("./Packets/ChannelPart.js"), ChannelPart = require("./Packets/ChannelPart.js"),
AddFriend = require("./Packets/AddFriend.js"), AddFriend = require("./Packets/AddFriend.js"),
@ -299,6 +300,10 @@ module.exports = async function(req, res) {
ChannelPart(PacketUser, CurrentPacket.data); ChannelPart(PacketUser, CurrentPacket.data);
break; break;
case packetIDs.client_setAwayMessage:
SetAwayMessage(PacketUser, CurrentPacket.data);
break;
case packetIDs.client_friendAdd: case packetIDs.client_friendAdd:
AddFriend(PacketUser, CurrentPacket.data); AddFriend(PacketUser, CurrentPacket.data);
break; break;