diff --git a/assets/openapi.json b/assets/openapi.json
index d20ef2fb..5a81a5de 100644
--- a/assets/openapi.json
+++ b/assets/openapi.json
@@ -4923,7 +4923,12 @@
"type": "integer"
},
"flags": {
- "type": "integer"
+ "enum": [
+ 1,
+ 2,
+ 4
+ ],
+ "type": "number"
},
"last_viewed": {
"type": "integer"
@@ -4933,6 +4938,25 @@
}
}
},
+ "AcknowledgeDeleteSchema": {
+ "type": "object",
+ "properties": {
+ "read_state_type": {
+ "enum": [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5
+ ],
+ "type": "number"
+ },
+ "version": {
+ "type": "integer"
+ }
+ }
+ },
"MessageCreateSchema": {
"type": "object",
"properties": {
@@ -12579,6 +12603,9 @@
"name": "interactions"
},
{
+ "name": "invites"
+ },
+ {
"name": "oauth2"
},
{
@@ -16164,6 +16191,163 @@
]
}
},
+ "/invites/{invite_code}": {
+ "get": {
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Invite"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "invite_code",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "invite_code"
+ }
+ ],
+ "tags": [
+ "invites"
+ ]
+ },
+ "post": {
+ "x-right-required": "USE_MASS_INVITES",
+ "security": [
+ {
+ "bearer": []
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Invite"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ },
+ "403": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "invite_code",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "invite_code"
+ }
+ ],
+ "tags": [
+ "invites"
+ ]
+ },
+ "delete": {
+ "security": [
+ {
+ "bearer": []
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/Invite"
+ }
+ }
+ }
+ },
+ "401": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ },
+ "404": {
+ "description": "",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/APIErrorResponse"
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "name": "invite_code",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "invite_code"
+ }
+ ],
+ "tags": [
+ "invites"
+ ]
+ }
+ },
"/interactions/": {
"post": {
"security": [
@@ -21699,6 +21883,44 @@
]
}
},
+ "/channels/{channel_id}/messages/ack": {
+ "delete": {
+ "security": [
+ {
+ "bearer": []
+ }
+ ],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/AcknowledgeDeleteSchema"
+ }
+ }
+ }
+ },
+ "responses": {
+ "204": {
+ "description": "No description available"
+ }
+ },
+ "parameters": [
+ {
+ "name": "channel_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string"
+ },
+ "description": "channel_id"
+ }
+ ],
+ "tags": [
+ "channels"
+ ]
+ }
+ },
"/channels/{channel_id}/messages/bulk-delete/": {
"post": {
"security": [
diff --git a/assets/schemas.json b/assets/schemas.json
index bfe3de68..e092a919 100644
--- a/assets/schemas.json
+++ b/assets/schemas.json
@@ -5243,7 +5243,12 @@
"type": "integer"
},
"flags": {
- "type": "integer"
+ "enum": [
+ 1,
+ 2,
+ 4
+ ],
+ "type": "number"
},
"last_viewed": {
"type": "integer"
@@ -5255,6 +5260,27 @@
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
+ "AcknowledgeDeleteSchema": {
+ "type": "object",
+ "properties": {
+ "read_state_type": {
+ "enum": [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5
+ ],
+ "type": "number"
+ },
+ "version": {
+ "type": "integer"
+ }
+ },
+ "additionalProperties": false,
+ "$schema": "http://json-schema.org/draft-07/schema#"
+ },
"MessageCreateSchema": {
"type": "object",
"properties": {
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;
diff --git a/src/schemas/uncategorised/MessageAcknowledgeSchema.ts b/src/schemas/uncategorised/MessageAcknowledgeSchema.ts
index 3ba71649..891ccc90 100644
--- a/src/schemas/uncategorised/MessageAcknowledgeSchema.ts
+++ b/src/schemas/uncategorised/MessageAcknowledgeSchema.ts
@@ -19,7 +19,27 @@
export interface MessageAcknowledgeSchema {
manual?: boolean;
mention_count?: number;
- flags?: number;
+ flags?: ReadStateFlags;
last_viewed?: number;
token?: string;
}
+
+export interface AcknowledgeDeleteSchema {
+ read_state_type?: ReadStateType;
+ version?: number;
+}
+
+export enum ReadStateType {
+ CHANNEL = 0,
+ GUILD_EVENT = 1,
+ NOTIFICATION_CENTER = 2,
+ GUILD_HOME = 3,
+ GUILD_ONBOARDING_QUESTION = 4,
+ MESSAGE_REQUESTS = 5,
+}
+
+export enum ReadStateFlags {
+ IS_GUILD_CHANNEL = 1 << 0,
+ IS_THREAD = 1 << 1,
+ IS_MENTION_LOW_IMPORTANCE = 1 << 2,
+}
\ No newline at end of file
|