mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Fix error handling in nameRequestController
This commit is contained in:
parent
5fec5deb06
commit
8437da1200
1 changed files with 7 additions and 1 deletions
|
|
@ -84,7 +84,13 @@ export const nameRequestController: AppController = async (c) => {
|
||||||
const pubkey = await signer.getPublicKey();
|
const pubkey = await signer.getPublicKey();
|
||||||
const { conf } = c.var;
|
const { conf } = c.var;
|
||||||
|
|
||||||
const { name, reason } = nameRequestSchema.parse(await c.req.json());
|
const result = nameRequestSchema.safeParse(await c.req.json());
|
||||||
|
|
||||||
|
if (!result.success) {
|
||||||
|
return c.json({ error: 'Invalid username', schema: result.error }, 400);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { name, reason } = result.data;
|
||||||
|
|
||||||
const [existing] = await store.query([{ kinds: [3036], authors: [pubkey], '#r': [name], limit: 1 }]);
|
const [existing] = await store.query([{ kinds: [3036], authors: [pubkey], '#r': [name], limit: 1 }]);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue