Fixed overzealous welcome wagon

This commit is contained in:
rainbow napkin 2026-10-15 01:30:38 -04:00
parent 42accf52ca
commit ccb468078c
2 changed files with 15 additions and 7 deletions

View file

@ -150,6 +150,8 @@ class activeChannel{
var userObj = this.userList.get(userDB.user); var userObj = this.userList.get(userDB.user);
//get channel rank for current user //get channel rank for current user
const chanRank = await chanDB.getChannelRankByUserDoc(userDB); const chanRank = await chanDB.getChannelRankByUserDoc(userDB);
//Keep track of whether or not user has connected to this channel on another tab/device yet
let first = false;
//If user is already connected //If user is already connected
if(userObj){ if(userObj){
@ -161,6 +163,8 @@ class activeChannel{
await userDB.populate('flair'); await userDB.populate('flair');
//Set user object //Set user object
userObj = new connectedUser(userDB, chanRank, this, socket); userObj = new connectedUser(userDB, chanRank, this, socket);
//Throw first flag
first = true;
} }
//Set user entry in userlist //Set user entry in userlist
@ -175,7 +179,7 @@ class activeChannel{
this.webRTCHandler.defineListeners(socket); this.webRTCHandler.defineListeners(socket);
//Hand off the connection initiation to it's user object //Hand off the connection initiation to it's user object
const activeUser = await userObj.handleConnection(userDB, chanDB, socket) const activeUser = await userObj.handleConnection(userDB, chanDB, socket, first)
//Send out the userlist //Send out the userlist
this.broadcastUserList(socket.chan); this.broadcastUserList(socket.chan);

View file

@ -96,11 +96,12 @@ class connectedUser{
* @param {Mongoose.Document} userDB - User Document Passthrough to save on DB Access * @param {Mongoose.Document} userDB - User Document Passthrough to save on DB Access
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access * @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
* @param {Socket} socket - Requesting Socket * @param {Socket} socket - Requesting Socket
* @param {Boolean} first - thrown true if this is the socket for this user on this channel
* @returns {activeUser} active user object generated by the new connection * @returns {activeUser} active user object generated by the new connection
*/ */
async handleConnection(userDB, chanDB, socket){ async handleConnection(userDB, chanDB, socket, first){
//send metadata to client //send metadata to client
this.sendClientMetadata(); this.sendClientMetadata(undefined, undefined, first);
//Send out emotes //Send out emotes
this.sendSiteEmotes(); this.sendSiteEmotes();
@ -122,7 +123,6 @@ class connectedUser{
await userDB.tattooIPRecord(socket.handshake.address); await userDB.tattooIPRecord(socket.handshake.address);
} }
//Return active user object for use by activeChannel and channelManager objects //Return active user object for use by activeChannel and channelManager objects
return this; return this;
} }
@ -179,8 +179,9 @@ class connectedUser{
* Sends glut of required initial metadata to the client upon a new connection * Sends glut of required initial metadata to the client upon a new connection
* @param {Mongoose.Document} userDB - User Document Passthrough to save on DB Access * @param {Mongoose.Document} userDB - User Document Passthrough to save on DB Access
* @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access * @param {Mongoose.Document} chanDB - Channnel Document Passthrough to save on DB Access
* @param {Boolean} welcome - Whether or not to throw welcome wagon, ensures we dont welcome before the metadata is sent
*/ */
async sendClientMetadata(userDB, chanDB){ async sendClientMetadata(userDB, chanDB, welcome){
//Get flairList from DB and setup flairList array //Get flairList from DB and setup flairList array
const flairListDB = await flairModel.find({}); const flairListDB = await flairModel.find({});
var flairList = []; var flairList = [];
@ -238,8 +239,11 @@ class connectedUser{
//Send off the metadata to our user's clients //Send off the metadata to our user's clients
this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer, streamType: chanDB.settings.streamType}); this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer, streamType: chanDB.settings.streamType});
//Broadcast the welcome wagon //If we where told to welcome the user
this.channel.welcomeWagon(userDB.user); if(welcome){
//Broadcast the welcome wagon
this.channel.welcomeWagon(userDB.user);
}
} }
/** /**