summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-02 18:06:00 +0100
committerRory& <root@rory.gay>2025-12-02 18:06:00 +0100
commit5075837d555bc8f215d1eaacbc1b4efb6ee705e8 (patch)
treefd5006bddeeb497dfb29c309a4b776e6d0e439e3 /src/api
parentFix schema import (diff)
downloadserver-ts-5075837d555bc8f215d1eaacbc1b4efb6ee705e8.tar.xz
Support deleting ACKs for type==channel
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/channels/#channel_id/messages/index.ts29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/api/routes/channels/#channel_id/messages/index.ts b/src/api/routes/channels/#channel_id/messages/index.ts

index d399e53a..8790241d 100644 --- a/src/api/routes/channels/#channel_id/messages/index.ts +++ b/src/api/routes/channels/#channel_id/messages/index.ts
@@ -18,7 +18,6 @@ import { handleMessage, postHandleMessage, route } from "@spacebar/api"; import { - ApiError, Attachment, AutomodRule, AutomodTriggerTypes, @@ -39,9 +38,9 @@ import { Relationship, Rights, Snowflake, + stringGlobToRegexp, uploadFile, User, - stringGlobToRegexp, } from "@spacebar/util"; import { Request, Response, Router } from "express"; import { HTTPError } from "lambert-server"; @@ -49,6 +48,7 @@ import multer from "multer"; import { FindManyOptions, FindOperator, LessThan, MoreThan, MoreThanOrEqual } from "typeorm"; import { URL } from "url"; import { + AcknowledgeDeleteSchema, AutomodCustomWordsRule, AutomodRuleActionType, AutomodRuleEventType, @@ -57,6 +57,7 @@ import { MessageCreateCloudAttachment, MessageCreateSchema, Reaction, + ReadStateType, RelationshipType, } from "@spacebar/schemas"; @@ -532,4 +533,28 @@ router.post( }, ); +router.delete( + "/ack", + route({ + requestBody: "AcknowledgeDeleteSchema", + responses: { + 204: {}, + }, + }), + async (req: Request, res: Response) => { + const { channel_id } = req.params; // not really a channel id if read_state_type != CHANNEL + const body = req.body as AcknowledgeDeleteSchema; + if (body.version != 2) return res.status(204).send(); + // TODO: handle other read state types + if (body.read_state_type != ReadStateType.CHANNEL) return res.status(204).send(); + + const readState = await ReadState.findOne({where: {channel_id}}); + if (readState) { + await readState.remove(); + } + + res.status(204).send(); + }, +); + export default router;