Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export default {
"*.{j,t}s": [() => "npm run build:src:tsgo", "eslint --concurrency 4" /* sweet spot it seems */, "prettier --write"],
"src/schemas/{*,**/*}.ts": [() => "npm run build:src:tsgo", () => "node scripts/schema.js", () => "node scripts/openapi.js", () => "git add assets/schemas.json assets/openapi.json"],
"src/schemas/{*,**/*}.ts": [
() => "npm run build:src:tsgo",
() => "node scripts/schema.js",
() => "node scripts/openapi.js",
() => "git add assets/schemas.json assets/openapi.json",
],
};
129 changes: 124 additions & 5 deletions assets/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10710,7 +10710,7 @@
"reactions": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Reaction"
"$ref": "#/components/schemas/StoredReaction"
}
},
"nonce": {
Expand Down Expand Up @@ -11472,12 +11472,15 @@
}
}
},
"Reaction": {
"StoredReaction": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"count_details": {
"$ref": "#/components/schemas/ReactionCountDetails"
},
"emoji": {
"$ref": "#/components/schemas/PartialEmoji"
},
Expand All @@ -11486,6 +11489,18 @@
"items": {
"type": "string"
}
},
"burst_user_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"burst_colors": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
Expand All @@ -11494,6 +11509,21 @@
"user_ids"
]
},
"ReactionCountDetails": {
"type": "object",
"properties": {
"normal": {
"type": "integer"
},
"burst": {
"type": "integer"
}
},
"required": [
"burst",
"normal"
]
},
"PartialEmoji": {
"anyOf": [
{
Expand Down Expand Up @@ -25451,6 +25481,15 @@
"type": "string"
},
"description": "emoji"
},
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"type": "number"
},
"description": "The type of reaction to return users for."
}
],
"tags": [
Expand Down Expand Up @@ -25600,7 +25639,87 @@
]
}
},
"/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/{burst}/{user_id}": {
"/channels/{channel_id}/messages/{message_id}/reactions/{emoji}/{type}/{user_id}": {
"put": {
"x-right-required": "SELF_ADD_REACTIONS",
"x-permission-required": "READ_MESSAGE_HISTORY",
"security": [
{
"bearer": []
}
],
"responses": {
"204": {
"description": "No description available"
},
"400": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/APIErrorResponse"
}
}
}
},
"403": {
"description": "No description available"
},
"404": {
"description": "No description available"
}
},
"parameters": [
{
"name": "channel_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "channel_id"
},
{
"name": "message_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "message_id"
},
{
"name": "emoji",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "emoji"
},
{
"name": "type",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "type"
},
{
"name": "user_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "user_id"
}
],
"tags": [
"channels"
]
},
"delete": {
"security": [
{
Expand Down Expand Up @@ -25657,13 +25776,13 @@
"description": "emoji"
},
{
"name": "burst",
"name": "type",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "burst"
"description": "type"
},
{
"name": "user_id",
Expand Down
36 changes: 34 additions & 2 deletions assets/schemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -11389,7 +11389,7 @@
"reactions": {
"type": "array",
"items": {
"$ref": "#/definitions/Reaction"
"$ref": "#/definitions/StoredReaction"
}
},
"nonce": {
Expand Down Expand Up @@ -12176,12 +12176,15 @@
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"Reaction": {
"StoredReaction": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"count_details": {
"$ref": "#/definitions/ReactionCountDetails"
},
"emoji": {
"$ref": "#/definitions/PartialEmoji"
},
Expand All @@ -12190,6 +12193,18 @@
"items": {
"type": "string"
}
},
"burst_user_ids": {
"type": "array",
"items": {
"type": "string"
}
},
"burst_colors": {
"type": "array",
"items": {
"type": "string"
}
}
},
"additionalProperties": false,
Expand All @@ -12200,6 +12215,23 @@
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"ReactionCountDetails": {
"type": "object",
"properties": {
"normal": {
"type": "integer"
},
"burst": {
"type": "integer"
}
},
"additionalProperties": false,
"required": [
"burst",
"normal"
],
"$schema": "http://json-schema.org/draft-07/schema#"
},
"PartialEmoji": {
"anyOf": [
{
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default defineConfig([
// "sort-imports": ["error", {}],
"default-case": "error",
"default-case-last": "error",
"yoda": "error",
yoda: "error",
// unsure what the defaults are here, but we want them to error
"for-direction": "error",
"constructor-super": "error",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
import { Request, Response, Router } from "express";
import { HTTPError } from "lambert-server";
import multer from "multer";
import { handleMessage, postHandleMessage, route } from "@spacebar/api";
import { handleMessage, postHandleMessage, route, toPublicReactions } from "@spacebar/api";
import { MessageCreateAttachment, MessageCreateCloudAttachment, MessageCreateSchema, MessageEditSchema, ChannelType } from "@spacebar/schemas";

const router = Router({ mergeParams: true });
Expand Down Expand Up @@ -122,6 +122,7 @@ router.patch(
author: new_message.author?.toPublicUser(),
attachments: new_message.attachments,
embeds: new_message.embeds,
reactions: toPublicReactions(new_message.reactions, req.user_id),
mentions: new_message.embeds,
mention_roles: new_message.mention_roles,
mention_everyone: new_message.mention_everyone,
Expand Down Expand Up @@ -273,7 +274,10 @@ router.get(

if (message.author_id !== req.user_id) permissions.hasThrow("READ_MESSAGE_HISTORY");

return res.json(message);
const publicMessage = message.toJSON();
publicMessage.reactions = toPublicReactions(message.reactions, req.user_id);

return res.json(publicMessage);
},
);

Expand Down
Loading
Loading