reorder SendPrivateMessage and add a null check

This commit is contained in:
Holly Stubbs 2021-09-03 21:12:25 +01:00
parent fc374c8932
commit eea27b25f8

View file

@ -3,6 +3,9 @@ const osu = require("osu-packet"),
module.exports = function(CurrentUser, CurrentPacket) { module.exports = function(CurrentUser, CurrentPacket) {
const osuPacketWriter = new osu.Bancho.Writer; const osuPacketWriter = new osu.Bancho.Writer;
const userSentTo = getUserByUsername(CurrentPacket.data.target);
if (userSentTo == null) return;
osuPacketWriter.SendMessage({ osuPacketWriter.SendMessage({
sendingClient: CurrentUser.username, sendingClient: CurrentUser.username,
@ -11,8 +14,6 @@ module.exports = function(CurrentUser, CurrentPacket) {
senderId: CurrentUser.id senderId: CurrentUser.id
}); });
const userSentTo = getUserByUsername(CurrentPacket.data.target);
// Write chat message to stream asociated with chat channel // Write chat message to stream asociated with chat channel
return userSentTo.addActionToQueue(osuPacketWriter.toBuffer); return userSentTo.addActionToQueue(osuPacketWriter.toBuffer);
} }