Added site-wide emote support.

This commit is contained in:
rainbow napkin 2024-12-20 01:42:48 -05:00
parent 41d0302ded
commit 97717b525c
11 changed files with 122 additions and 22 deletions

View file

@ -19,6 +19,7 @@ const {mongoose} = require('mongoose');
//Local Imports
const defaultEmote = require("../../defaultEmotes.json");
const server = require('../server');
const typeEnum = ["image", "video"];
@ -39,6 +40,19 @@ const emoteSchema = new mongoose.Schema({
}
});
//pre-save function
emoteSchema.post('save', async function (next){
//broadcast updated emotes
server.channelManager.broadcastSiteEmotes();
});
//post-delete function (document not query)
emoteSchema.post('deleteOne', {document: true}, async function (next){
//broadcast updated emotes
server.channelManager.broadcastSiteEmotes();
});
//statics
emoteSchema.statics.loadDefaults = async function(){
//Make sure registerEmote function is happy
const _this = this;