From eea27b25f855994ae3f310fad68e6c1bc99478f3 Mon Sep 17 00:00:00 2001 From: holly Date: Fri, 3 Sep 2021 21:12:25 +0100 Subject: [PATCH] reorder SendPrivateMessage and add a null check --- server/Packets/SendPrivateMessage.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/Packets/SendPrivateMessage.js b/server/Packets/SendPrivateMessage.js index b469eae..a5932f3 100644 --- a/server/Packets/SendPrivateMessage.js +++ b/server/Packets/SendPrivateMessage.js @@ -3,6 +3,9 @@ const osu = require("osu-packet"), module.exports = function(CurrentUser, CurrentPacket) { const osuPacketWriter = new osu.Bancho.Writer; + const userSentTo = getUserByUsername(CurrentPacket.data.target); + + if (userSentTo == null) return; osuPacketWriter.SendMessage({ sendingClient: CurrentUser.username, @@ -11,8 +14,6 @@ module.exports = function(CurrentUser, CurrentPacket) { senderId: CurrentUser.id }); - const userSentTo = getUserByUsername(CurrentPacket.data.target); - // Write chat message to stream asociated with chat channel return userSentTo.addActionToQueue(osuPacketWriter.toBuffer); } \ No newline at end of file