pubkey check

This commit is contained in:
MeowcaTheoRange 2024-09-02 13:20:42 -05:00
parent d834f2aa6f
commit 303a09d18e
2 changed files with 18 additions and 4 deletions

View file

@ -247,7 +247,8 @@ app.post('/mininq/mbox/r', async (req, res) => {
"url": mininq_pub.url
} : {
"name": `${mininq_pub.name} sent:`
}
},
"timestamp": new Date(mininq_pub.time).toISOString()
}
],
"attachments": []
@ -296,7 +297,8 @@ app.post('/mininq/mbox/r', async (req, res) => {
"url": mininq.url
} : {
"name": `${mininq.name} sent:`
}
},
"timestamp": new Date(mininq.time).toISOString()
},
{
"description": body.msg,
@ -415,7 +417,18 @@ app.post('/mininq/send', async (req, res) => {
try {
let publicKeyWorks = await checkPublicKey(body);
if (publicKeyWorks) newObject.url = body.pkeyurl;
if (publicKeyWorks) {
newObject.url = body.pkeyurl;
const isUrlAlreadyMininq = await db
.selectFrom('mininq')
.select('url')
.where('url', '=', newObject.url)
.where('public', '=', 0)
.executeTakeFirst();
if (isUrlAlreadyMininq != null) return res.status(403).send("Pubkey is already in mailbox");
}
} catch (err) {
// do nothing lol
}

View file

@ -11,4 +11,5 @@
<h3>sysadmin reply:</h3>
<p style="white-space: pre-line;"><%= mininq.reply %></p>
</section>
<% } %>
<% } %>
<p style="opacity: 0.5;"><%= new Date(mininq.time).toLocaleString('en-us', { timeZone: "America/Chicago" }) %> Central Time</p>