Move friends list logic

This commit is contained in:
Ethan Stubbs 2021-02-05 03:14:31 +00:00
parent 0848c0b1e4
commit 02cf151134

View file

@ -91,14 +91,6 @@ module.exports = function(req, res, loginInfo) {
// Permission level 4 is osu!supporter
osuPacketWriter.LoginPermissions(4);
// Construct user's friends list
const userFriends = global.DatabaseHelper.getFromDB(`SELECT friendsWith FROM friends WHERE user = ${NewUser.id}`);
let friendsArray = [];
for (let i = 0; i < userFriends.length; i++) {
friendsArray.push(userFriends[i].friendsWith);
}
// Send user's friends list
osuPacketWriter.FriendsList(friendsArray);
// After sending the user their friends list send them the online users
UserPresenceBundle(NewUser);
@ -130,6 +122,15 @@ module.exports = function(req, res, loginInfo) {
});
}
// Construct user's friends list
const userFriends = global.DatabaseHelper.getFromDB(`SELECT friendsWith FROM friends WHERE user = ${NewUser.id}`);
let friendsArray = [];
for (let i = 0; i < userFriends.length; i++) {
friendsArray.push(userFriends[i].friendsWith);
}
// Send user's friends list
osuPacketWriter.FriendsList(friendsArray);
osuPacketWriter.Announce(`Welcome back ${loginInfo.username}!`);
// Complete login