Add replies and emoji reactions to chat messages
Every message has a row under it to reply or react. Replying quotes the message above the composer, and the sent message stores reply_to_message_id (a plain id, not a foreign key, so deleting the quoted message only drops the quote). send-message accepts a quote from any session of the same conversation, so a rollover or a thread that moved on still sends; the conversation drops a picked quote when its session changes. The bot reads the quote as "[Replying to ...]" before the user's turn, file-only replies included, and relayed messages carry it too. Reactions are a fixed set (BotMessageReactions) in bot_message_reactions, one per message, emoji and user or bot. Users toggle their own through api/admin/bots/react-message, and every bot gets react_to_message for the session it answers (the user's latest message by default). Both push the fresh list as server:bot-reaction, with mine worked out for the session's user. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { z } from "zod";
|
||||
import { AppData } from "@/src/data/app-data";
|
||||
import { BotHues, type BotHue } from "@/src/dict/bot-dict";
|
||||
import {
|
||||
BotHues,
|
||||
BotMessageReactions,
|
||||
type BotHue,
|
||||
type BotMessageReactionEmoji,
|
||||
} from "@/src/dict/bot-dict";
|
||||
|
||||
/**
|
||||
* The workspace a conversation is in; left out (or null) for a bot's own
|
||||
@@ -16,10 +21,29 @@ export const SendBotMessageRequestSchema = z.object({
|
||||
.array(z.coerce.number().int().positive())
|
||||
.max(AppData.BotAttachmentMaxFiles, `Attach up to ${AppData.BotAttachmentMaxFiles} files`)
|
||||
.default([]),
|
||||
/**
|
||||
* The message this one replies to, quoted above it.
|
||||
*/
|
||||
reply_to_message_id: z.coerce.number().int().positive().nullish(),
|
||||
}).refine((body) => body.text || body.media_ids.length, "Write a message or attach a file first");
|
||||
|
||||
export type SendBotMessageRequest = z.infer<typeof SendBotMessageRequestSchema>;
|
||||
|
||||
/**
|
||||
* Toggling one of the fixed reactions on a message.
|
||||
*/
|
||||
export const ReactToBotMessageRequestSchema = z.object({
|
||||
message_id: z.coerce.number().int().positive("Pick a message"),
|
||||
emoji: z.enum(
|
||||
BotMessageReactions.map((reaction) => reaction.value) as [
|
||||
BotMessageReactionEmoji,
|
||||
...BotMessageReactionEmoji[],
|
||||
],
|
||||
),
|
||||
});
|
||||
|
||||
export type ReactToBotMessageRequest = z.infer<typeof ReactToBotMessageRequestSchema>;
|
||||
|
||||
export const BotIdRequestSchema = z.object({
|
||||
bot_id: z.coerce.number().int().positive("Pick a bot"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user