From 4c3d8f9194544c4c746a82920e6fffceb10648ed Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 2 Jul 2021 17:14:53 -0400 Subject: [PATCH 1/3] rm .gitlab-ci.yml --- .gitlab-ci.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 9a4871d..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,23 +0,0 @@ -stages: - - lint - - build - -lint: - stage: lint - script: | - yarn install - yarn lint - only: - - pushes - - merge_requests - - web - -tsc: - stage: build - script: | - yarn install - tsc -p tsconfig.json -noEmit - only: - - pushes - - merge_requests - - web \ No newline at end of file From f41a0525d641958567b30351392dffb7120ad64e Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 2 Jul 2021 17:17:09 -0400 Subject: [PATCH 2/3] fixes --- src/commands/x509_upload.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/x509_upload.ts b/src/commands/x509_upload.ts index 450f020..1988314 100644 --- a/src/commands/x509_upload.ts +++ b/src/commands/x509_upload.ts @@ -25,7 +25,7 @@ export default class X509_Upload extends Command { try { await axios.post('https://certapi.libraryofcode.org/parse', x509); } catch { - this.error(message.channel, 'Unable to parse your x509 certificate.'); + return this.error(message.channel, 'Unable to parse your x509 certificate.'); } finally { await this.client.db.Member.updateOne({ userID: message.author.id }, { x509 }); this.success(message.channel, 'x509 certificate successfully uploaded to your account.'); From 0b3a1808ed8f16fee0e131c913a5bd55abf654e7 Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 2 Jul 2021 19:48:13 -0400 Subject: [PATCH 3/3] add x509 endpoints --- src/api/board.ins/routes/root.ts | 31 +++++++++-------- .../comm.libraryofcode.org/routes/index.ts | 1 + src/api/comm.libraryofcode.org/routes/keys.ts | 33 +++++++++++++++++++ src/api/loc.sh/routes/internal.ts | 2 +- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 src/api/comm.libraryofcode.org/routes/keys.ts diff --git a/src/api/board.ins/routes/root.ts b/src/api/board.ins/routes/root.ts index 675cd71..79377fe 100644 --- a/src/api/board.ins/routes/root.ts +++ b/src/api/board.ins/routes/root.ts @@ -14,7 +14,8 @@ export default class Root extends Route { this.server.client.once('ready', async () => { this.guild = this.server.client.guilds.get(this.server.client.config.guildID) || await this.server.client.getRESTGuild(this.server.client.config.guildID); this.directorRole = '662163685439045632'; - this.directorLogs = this.guild.channels.get('807444198969835550'); + this.brsVotingChannel = this.guild.channels.get('807444198969835550'); + this.brsLogChannel = this.guild.channels.get('858547883853873173'); this.chairman = '278620217221971968'; }); } @@ -23,7 +24,9 @@ export default class Root extends Route { private directorRole: string; - private directorLogs: GuildTextableChannel; + private brsVotingChannel: GuildTextableChannel; + + private brsLogChannel: GuildTextableChannel; private chairman: string; @@ -91,7 +94,7 @@ export default class Root extends Route { break; case 'proc': - title = 'Proclamation'; + title = 'Proposed Proclamation'; color = 0x9b89ff; break; @@ -113,7 +116,7 @@ export default class Root extends Route { BODY: ${payload.body} - + _____________________________________________________________________ LIBRARY OF CODE SP-US | BOARD OF DIRECTORS BOARD REGISTER SYSTEM https://board.ins/ @@ -285,7 +288,8 @@ export default class Root extends Route { body: req.body.body, }, ); - const msg = await this.directorLogs.createMessage({ embed }); + const msg = await this.brsVotingChannel.createMessage({ embed }); + await this.brsLogChannel.createMessage({ embed }); const eo = await this.server.client.db.ExecutiveOrder.create({ issuer: authenticated.director.userID, @@ -331,7 +335,8 @@ export default class Root extends Route { body: req.body.body, }, ); - const msg = await this.directorLogs.createMessage({ embed }); + const msg = await this.brsVotingChannel.createMessage({ embed }); + await this.brsLogChannel.createMessage({ embed }); const motion = await this.server.client.db.Motion.create({ issuer: authenticated.director.userID, @@ -378,7 +383,7 @@ export default class Root extends Route { body: req.body.body, }, ); - const msg = await this.directorLogs.createMessage({ embed }); + const msg = await this.brsVotingChannel.createMessage({ embed }); await msg.addReaction('modSuccess:578750988907970567'); await msg.addReaction('modError:578750737920688128'); await msg.addReaction('🙋'); @@ -657,7 +662,7 @@ export default class Root extends Route { }); if (eo.subject !== req.body.subject || eo.body !== req.body.body) { - const message = await this.directorLogs.getMessage(eo.msg); + const message = await this.brsVotingChannel.getMessage(eo.msg); const embed = this.genEmbed( eo.oID, 'eo', @@ -711,7 +716,7 @@ export default class Root extends Route { }); if (motion.subject !== req.body.subject || motion.body !== req.body.body) { - const message = await this.directorLogs.getMessage(motion.msg); + const message = await this.brsVotingChannel.getMessage(motion.msg); const embed = this.genEmbed( motion.oID, 'motion', @@ -765,7 +770,7 @@ export default class Root extends Route { }); if (proc.subject !== req.body.subject || proc.body !== req.body.body) { - const message = await this.directorLogs.getMessage(proc.msg); + const message = await this.brsVotingChannel.getMessage(proc.msg); const embed = this.genEmbed( proc.oID, 'proc', @@ -819,7 +824,7 @@ export default class Root extends Route { }); if (resolution.subject !== req.body.subject || resolution.body !== req.body.body) { - const message = await this.directorLogs.getMessage(resolution.msg); + const message = await this.brsVotingChannel.getMessage(resolution.msg); const embed = this.genEmbed( resolution.oID, 'res', @@ -1008,7 +1013,7 @@ export default class Root extends Route { }, ); confirmationEmbed.addField('Results', `**Total:** ${total.length}\n**Yea:** ${yea}\n**Nay:** ${nay}\n**Present:** ${present}\n**Absent:** ${absent}`); - await this.directorLogs.createMessage({ embed: confirmationEmbed }); + await this.brsVotingChannel.createMessage({ embed: confirmationEmbed }); const totalDirectors = yea + nay + present + absent; if (yea / totalDirectors >= 0.6) { @@ -1024,7 +1029,7 @@ export default class Root extends Route { body: motion.body, }, ); - const resolutionMessage = await this.directorLogs.createMessage({ embed: resolutionEmbed }); + const resolutionMessage = await this.brsVotingChannel.createMessage({ embed: resolutionEmbed }); const resolutionID = genUUID(); await this.server.client.db.Resolution.create({ diff --git a/src/api/comm.libraryofcode.org/routes/index.ts b/src/api/comm.libraryofcode.org/routes/index.ts index 06de8be..7b226f1 100644 --- a/src/api/comm.libraryofcode.org/routes/index.ts +++ b/src/api/comm.libraryofcode.org/routes/index.ts @@ -1 +1,2 @@ +export { default as keys } from './keys'; export { default as report } from './report'; diff --git a/src/api/comm.libraryofcode.org/routes/keys.ts b/src/api/comm.libraryofcode.org/routes/keys.ts new file mode 100644 index 0000000..aa9748e --- /dev/null +++ b/src/api/comm.libraryofcode.org/routes/keys.ts @@ -0,0 +1,33 @@ +import { Route, Server } from '../../../class'; + +export default class Keys extends Route { + constructor(server: Server) { + super(server); + this.conf = { + path: '/keys', + }; + } + + protected pre() { + this.router.all('*', (_req, res, next) => { + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', '*'); + res.setHeader('Access-Control-Allow-Headers', '*'); + next(); + }); + } + + public bind() { + this.pre(); + + this.router.get('/x509/:userID', async (req, res) => { + const memberDoc = await this.server.client.db.Member.findOne({ userID: req.params.userID }).lean().exec(); + const member = this.mainGuild.members.get(req.params.userID); + if (!member || !memberDoc || !memberDoc?.x509) return res.status(404).json({ code: this.constants.codes.NOT_FOUND, message: this.constants.messages.NOT_FOUND }); + return res.status(200).json({ + code: this.constants.codes.SUCCESS, + message: memberDoc.x509, + }); + }); + } +} diff --git a/src/api/loc.sh/routes/internal.ts b/src/api/loc.sh/routes/internal.ts index be15084..fc02d82 100644 --- a/src/api/loc.sh/routes/internal.ts +++ b/src/api/loc.sh/routes/internal.ts @@ -19,8 +19,8 @@ export default class Internal extends Route { public bind() { this.router.get('/directory', async (req, res) => { + res.setHeader('Access-Control-Allow-Origin', '*'); try { - res.setHeader('Access-Control-Allow-Origin', '*'); if (req.query.id) { let member = this.server.client.guilds.get(this.server.client.config.guildID).members.get(req.query.id.toString()); if (!member) member = await this.server.client.getRESTGuildMember(this.server.client.config.guildID, req.query.id.toString());