Started work on personal emotes.
This commit is contained in:
parent
db5fac83ab
commit
a4a1f6a65b
16 changed files with 248 additions and 18 deletions
|
|
@ -56,7 +56,8 @@ module.exports = class{
|
|||
//await this.sendClientMetadata(userDB, socket);
|
||||
await userObj.sendClientMetadata();
|
||||
await userObj.sendSiteEmotes();
|
||||
await userObj.sendChanEmotes();
|
||||
await userObj.sendChanEmotes(chanDB);
|
||||
await userObj.sendPersonalEmotes(userDB);
|
||||
|
||||
//Send out the userlist
|
||||
this.broadcastUserList(socket.chan);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
//local imports
|
||||
const commandPreprocessor = require('./commandPreprocessor');
|
||||
const loggerUtils = require('../../utils/loggerUtils');
|
||||
const linkUtils = require('../../utils/linkUtils');
|
||||
const emoteValidator = require('../../validators/emoteValidator');
|
||||
const {userModel} = require('../../schemas/userSchema');
|
||||
|
||||
module.exports = class{
|
||||
|
|
@ -29,6 +31,7 @@ module.exports = class{
|
|||
socket.on("chatMessage", (data) => {this.handleChat(socket, data)});
|
||||
socket.on("setFlair", (data) => {this.setFlair(socket, data)});
|
||||
socket.on("setHighLevel", (data) => {this.setHighLevel(socket, data)});
|
||||
socket.on("addPersonalEmote", (data) => {this.addPersonalEmote(socket, data)});
|
||||
}
|
||||
|
||||
handleChat(socket, data){
|
||||
|
|
@ -79,6 +82,36 @@ module.exports = class{
|
|||
}
|
||||
}
|
||||
|
||||
async addPersonalEmote(socket, data){
|
||||
//Sanatize and Validate input
|
||||
const name = emoteValidator.manualName(data.name);
|
||||
const link = emoteValidator.manualLink(data.link);
|
||||
|
||||
//If we received good input
|
||||
if(link && name){
|
||||
//Generate marked link object
|
||||
var emote = await linkUtils.markLink(link);
|
||||
|
||||
//If the link we have is an image or video
|
||||
if(emote.type == 'image' || emote.type == 'video'){
|
||||
//Get user document from DB
|
||||
const userDB = await userModel.findOne({user: socket.user.user})
|
||||
|
||||
//if we have a user in the DB
|
||||
if(userDB != null){
|
||||
//Convert marked link into emote object with 1 ez step for only $19.95
|
||||
emote.name = name;
|
||||
|
||||
//add emote to user document emotes list
|
||||
userDB.emotes.push(emote);
|
||||
|
||||
//Save user doc
|
||||
await userDB.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
relayUserChat(socket, msg, type, links){
|
||||
const user = this.server.getSocketInfo(socket);
|
||||
this.relayChat(user.user, user.flair, user.highLevel, msg, type, socket.chan, links)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ module.exports = class commandPreprocessor{
|
|||
|
||||
//split the command
|
||||
this.splitCommand();
|
||||
|
||||
//Process the command
|
||||
await this.processServerCommand();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ const channelModel = require('../../schemas/channel/channelSchema');
|
|||
const permissionModel = require('../../schemas/permissionSchema');
|
||||
const flairModel = require('../../schemas/flairSchema');
|
||||
const emoteModel = require('../../schemas/emoteSchema');
|
||||
const { userModel } = require('../../schemas/userSchema');
|
||||
|
||||
module.exports = class{
|
||||
constructor(userDB, chanRank, channel, socket){
|
||||
|
|
@ -111,6 +112,20 @@ module.exports = class{
|
|||
this.emit('chanEmotes', emoteList);
|
||||
}
|
||||
|
||||
async sendPersonalEmotes(userDB){
|
||||
//if we wherent handed a channel document
|
||||
if(userDB == null){
|
||||
//Pull it based on channel name
|
||||
userDB = await userModel.findOne({user: this.user});
|
||||
}
|
||||
|
||||
//Pull emotes from channel
|
||||
const emoteList = userDB.getEmotes();
|
||||
|
||||
//Send it off to the user
|
||||
this.emit('personalEmotes', emoteList);
|
||||
}
|
||||
|
||||
updateFlair(flair){
|
||||
this.flair = flair;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue