From 86994430c23ec7befd7dcbb3daf7f9062ca383ed Mon Sep 17 00:00:00 2001 From: Matthew R Date: Fri, 2 Jul 2021 22:34:40 -0400 Subject: [PATCH] add endpoint for pgp /pgp/:userID --- src/api/comm.libraryofcode.org/routes/keys.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/api/comm.libraryofcode.org/routes/keys.ts b/src/api/comm.libraryofcode.org/routes/keys.ts index aa9748e..18f34cd 100644 --- a/src/api/comm.libraryofcode.org/routes/keys.ts +++ b/src/api/comm.libraryofcode.org/routes/keys.ts @@ -29,5 +29,15 @@ export default class Keys extends Route { message: memberDoc.x509, }); }); + + this.router.get('/pgp/: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?.pgp) 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.pgp, + }); + }); } }