Added Endpoints and AJAX Helper Functions for emote management, as well as imporvements to link embedding.
This commit is contained in:
parent
b9283607d6
commit
255e6e0d7f
7 changed files with 63 additions and 27 deletions
|
|
@ -48,21 +48,28 @@ module.exports.post = async function(req, res){
|
|||
//if we have one
|
||||
if(emoteDB != null){
|
||||
//Throw a shit fit
|
||||
return errorHandler(res, `Emote '[${name}]' already exists!`);
|
||||
return errorHandler(res, `Emote [${name}] already exists!`);
|
||||
}
|
||||
|
||||
const linkObj = linkUtils.markLink(link);
|
||||
//Initialize the emote object from linkUtils
|
||||
var emoteObj = await linkUtils.markLink(link);
|
||||
|
||||
console.log(linkObj);
|
||||
//If we didn't get a valid image/video file
|
||||
if(emoteObj.type != 'image' && emoteObj.type != 'video'){
|
||||
//AAAAAAAAAAAAAAAAAA
|
||||
return errorHandler(res, 'URL either does not lead to a valid image/video file, or leads to one that is larger than 4MB');
|
||||
}
|
||||
|
||||
/*
|
||||
//Add the toke
|
||||
await tokeCommandModel.create({command});
|
||||
|
||||
//Add the name to the emoteObj
|
||||
emoteObj.name = name;
|
||||
|
||||
//Create the emote document
|
||||
await emoteModel.create(emoteObj);
|
||||
|
||||
//Return the updated command list
|
||||
res.status(200);
|
||||
return res.send(await tokeCommandModel.getCommandStrings());
|
||||
*/
|
||||
return res.send(await emoteModel.getEmotes());
|
||||
}else{
|
||||
//otherwise scream
|
||||
res.status(400);
|
||||
|
|
@ -80,20 +87,22 @@ module.exports.delete = async function(req, res){
|
|||
|
||||
//if they're empty
|
||||
if(validResult.isEmpty()){
|
||||
/*
|
||||
const {command} = matchedData(req);
|
||||
const tokeDB = await tokeCommandModel.findOne({command});
|
||||
//Pull name from sanatized/validated input
|
||||
const {name} = matchedData(req);
|
||||
//query for existing emote
|
||||
const emoteDB = await emoteModel.findOne({name});
|
||||
|
||||
if(tokeDB == null){
|
||||
return errorHandler(res, `Cannot delete non-existant toke command '!${command}'!`);
|
||||
//if we don't have one
|
||||
if(emoteDB == null){
|
||||
//Throw a shit fit
|
||||
return errorHandler(res, `Cannot delete non-existant emote: [${name}]!`);
|
||||
}
|
||||
|
||||
await tokeDB.deleteOne();
|
||||
await emoteDB.deleteOne();
|
||||
|
||||
//Return the updated command list
|
||||
res.status(200);
|
||||
return res.send(await tokeCommandModel.getCommandStrings());
|
||||
*/
|
||||
return res.send(await emoteModel.getEmotes());
|
||||
}else{
|
||||
//otherwise scream
|
||||
res.status(400);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue