- Introduced a new page for managing appunti in the admin area. - Created AppuntiProvider to manage appunti state and API interactions. - Added schemas for appunti and appunti groups. - Implemented CRUD operations for appunti and appunti groups in the API. - Removed potenziali related files and services as part of the refactor. - Updated the public schema to include appunti and appunti groups. - Improved error handling in the appunti service. Co-authored-by: Copilot <copilot@github.com>
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { z } from "zod/v4";
|
|
import { chatsChatid } from "~/schemas/public/Chats";
|
|
import { MessagesSchema, messagesMessageid } from "~/schemas/public/Messages";
|
|
import { usersId } from "~/schemas/public/Users";
|
|
|
|
z.config(z.locales.it());
|
|
export const MessageDataSchema = MessagesSchema.omit({
|
|
time: true,
|
|
}).extend({
|
|
time: z.string(),
|
|
sender_nome: z.string(),
|
|
sender_isAdmin: z.boolean(),
|
|
color_str: z.string(),
|
|
has_attachments: z.boolean(),
|
|
reply_source: MessagesSchema.pick({
|
|
messageid: true,
|
|
message: true,
|
|
sender: true,
|
|
})
|
|
.extend({
|
|
nome: z.string(),
|
|
color_str: z.string(),
|
|
})
|
|
.nullable(),
|
|
});
|
|
|
|
export const TypingDataSchema = z.array(
|
|
z.object({
|
|
userId: usersId,
|
|
username: z.string(),
|
|
}),
|
|
);
|
|
|
|
export const SidebarUpdateSchema = z.object({
|
|
chatId: chatsChatid,
|
|
lastMessage: z.string(),
|
|
senderName: z.string(),
|
|
});
|
|
|
|
export const MessageUpdateEventSchema = z.discriminatedUnion("eventType", [
|
|
z.object({
|
|
eventType: z.literal("edit"),
|
|
data: z.object({ messageId: messagesMessageid, message: z.string() }),
|
|
}),
|
|
z.object({
|
|
eventType: z.literal("delete"),
|
|
data: messagesMessageid,
|
|
}),
|
|
z.object({ eventType: z.literal("read_receipt"), data: z.null() }), // all unread messages in this chat are now read
|
|
]);
|
|
|
|
|