Update with UUIDs

merge-requests/17/head
Hiroyuki 2021-02-05 23:09:09 -04:00
parent e084efc369
commit 64b59bdd35
No known key found for this signature in database
GPG Key ID: C15AC26538975A24
3 changed files with 10 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import { TextChannel } from 'eris';
import { v4 as genUUID } from 'uuid';
import { RichEmbed, Route, Server } from '../../../class';
export default class Root extends Route {
@ -28,14 +29,14 @@ export default class Root extends Route {
}
if (!req.body.subject) {
return res.status(401).json({
return res.status(400).json({
code: this.constants.codes.CLIENT_ERROR,
message: this.constants.messages.CLIENT_ERROR,
});
}
if (!req.body.body) {
return res.status(401).json({
return res.status(400).json({
code: this.constants.codes.CLIENT_ERROR,
message: this.constants.messages.CLIENT_ERROR,
});
@ -46,6 +47,7 @@ export default class Root extends Route {
subject: req.body.subject,
body: req.body.body,
at: new Date(),
oID: genUUID(),
});
const staffInformation = await this.server.client.db.Staff.findOne({ userID: director.userID });
@ -57,7 +59,7 @@ export default class Root extends Route {
embed.setColor('#dd3acd');
embed.addField('Subject', req.body.subject);
embed.addField('Body', req.body.body);
embed.addField('ID', executiveOrder._id);
embed.addField('ID', executiveOrder.oID);
embed.setTimestamp(new Date());
const channel = <TextChannel>this.server.client.getChannel('807444198969835550');
@ -65,7 +67,7 @@ export default class Root extends Route {
return res.status(200).json({
code: this.constants.codes.SUCCESS,
message: `Created new Executive Order with ID ${executiveOrder._id} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`,
message: `Created new Executive Order with ID ${executiveOrder.oID} by the ${staffDiscord.username}#${staffDiscord.discriminator}, ${staffInformation.pn.join(', ')}.`,
});
});
}

View File

@ -1,8 +1,10 @@
import locsh from './loc.sh/main';
import crins from './cr.ins/main';
import commlibraryofcodeorg from './comm.libraryofcode.org/main';
import boardins from './board.ins/main';
export default {
'board.ins': boardins,
'loc.sh': locsh,
'cr.ins': crins,
'comm.libraryofcode.org': commlibraryofcodeorg,

View File

@ -5,6 +5,7 @@ export interface ExecutiveOrderInterface extends Document {
subject: string;
body: string;
at: Date;
oID: string;
}
const ExecutiveOrder = new Schema({
@ -12,6 +13,7 @@ const ExecutiveOrder = new Schema({
subject: { type: String, required: true },
body: { type: String, required: true },
at: { type: Date, required: true },
oID: { type: String, required: true, unique: true }
});
export default model<ExecutiveOrderInterface>('ExecutiveOrders', ExecutiveOrder);