Per-Channel Emotes Implemented.

This commit is contained in:
rainbow napkin 2024-12-21 11:01:00 -05:00
parent 163cecf9f0
commit c3d016e1af
14 changed files with 483 additions and 20 deletions

View file

@ -56,6 +56,7 @@ module.exports = class{
//await this.sendClientMetadata(userDB, socket);
await userObj.sendClientMetadata();
await userObj.sendSiteEmotes();
await userObj.sendChanEmotes();
//Send out the userlist
this.broadcastUserList(socket.chan);
@ -101,4 +102,18 @@ module.exports = class{
this.server.io.in(this.name).emit("userList", userList);
}
async broadcastChanEmotes(chanDB){
//if we wherent handed a channel document
if(chanDB == null){
//Pull it based on channel name
chanDB = await channelModel.findOne({name: this.name});
}
//Get emote list from channel document
const emoteList = chanDB.getEmotes();
//Broadcast that sumbitch
this.server.io.in(this.name).emit('chanEmotes', emoteList);
}
}

View file

@ -15,9 +15,10 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//local imports
const channelModel = require('../../schemas/channel/channelSchema');
const permissionModel = require('../../schemas/permissionSchema');
const flairModel = require('../../schemas/flairSchema');
const emoteModel = require('../../schemas/emoteSchema');
const permissionModel = require('../../schemas/permissionSchema');
module.exports = class{
constructor(userDB, chanRank, channel, socket){
@ -96,6 +97,20 @@ module.exports = class{
this.emit('siteEmotes', emoteList);
}
async sendChanEmotes(chanDB){
//if we wherent handed a channel document
if(chanDB == null){
//Pull it based on channel name
chanDB = await channelModel.findOne({name: this.channel.name});
}
//Pull emotes from channel
const emoteList = chanDB.getEmotes();
//Send it off to the user
this.emit('chanEmotes', emoteList);
}
updateFlair(flair){
this.flair = flair;