mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
Publish a label when the user solves a captcha
This commit is contained in:
parent
467a49bd40
commit
952d5e4370
1 changed files with 12 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import { z } from 'zod';
|
||||||
|
|
||||||
import { AppController } from '@/app.ts';
|
import { AppController } from '@/app.ts';
|
||||||
import { Conf } from '@/config.ts';
|
import { Conf } from '@/config.ts';
|
||||||
|
import { createAdminEvent } from '@/utils/api.ts';
|
||||||
|
|
||||||
interface Point {
|
interface Point {
|
||||||
x: number;
|
x: number;
|
||||||
|
|
@ -119,6 +120,7 @@ const pointSchema = z.object({
|
||||||
export const captchaVerifyController: AppController = async (c) => {
|
export const captchaVerifyController: AppController = async (c) => {
|
||||||
const id = c.req.param('id');
|
const id = c.req.param('id');
|
||||||
const result = pointSchema.safeParse(await c.req.json());
|
const result = pointSchema.safeParse(await c.req.json());
|
||||||
|
const pubkey = await c.get('signer')!.getPublicKey();
|
||||||
|
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
return c.json({ error: 'Invalid input' }, { status: 422 });
|
return c.json({ error: 'Invalid input' }, { status: 422 });
|
||||||
|
|
@ -140,6 +142,16 @@ export const captchaVerifyController: AppController = async (c) => {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
captchas.delete(id);
|
captchas.delete(id);
|
||||||
|
|
||||||
|
await createAdminEvent({
|
||||||
|
kind: 1985,
|
||||||
|
tags: [
|
||||||
|
['L', 'pub.ditto.captcha'],
|
||||||
|
['l', 'solved', 'pub.ditto.captcha'],
|
||||||
|
['p', pubkey, Conf.relay],
|
||||||
|
],
|
||||||
|
}, c);
|
||||||
|
|
||||||
return new Response(null, { status: 204 });
|
return new Response(null, { status: 204 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue