feat: Add emoji and alot of other fixes

This commit is contained in:
2026-06-05 05:40:18 +02:00
parent ca069e2f61
commit 6865147e8f
72 changed files with 3885 additions and 413 deletions

View File

@@ -11,6 +11,7 @@ import {
ReactionEntity,
BanEntity,
AttachmentEntity,
CustomEmojiEntity,
MetaEntity,
PluginDataEntity
} from '../../../entities';
@@ -27,6 +28,7 @@ export async function handleClearAllData(dataSource: DataSource): Promise<void>
await dataSource.getRepository(ReactionEntity).clear();
await dataSource.getRepository(BanEntity).clear();
await dataSource.getRepository(AttachmentEntity).clear();
await dataSource.getRepository(CustomEmojiEntity).clear();
await dataSource.getRepository(MetaEntity).clear();
await dataSource.getRepository(PluginDataEntity).clear();
}

View File

@@ -0,0 +1,7 @@
import { DataSource } from 'typeorm';
import { CustomEmojiEntity } from '../../../entities';
import { DeleteCustomEmojiCommand } from '../../types';
export async function handleDeleteCustomEmoji(command: DeleteCustomEmojiCommand, dataSource: DataSource): Promise<void> {
await dataSource.getRepository(CustomEmojiEntity).delete({ id: command.payload.emojiId });
}

View File

@@ -0,0 +1,19 @@
import { DataSource } from 'typeorm';
import { CustomEmojiEntity } from '../../../entities';
import { SaveCustomEmojiCommand } from '../../types';
export async function handleSaveCustomEmoji(command: SaveCustomEmojiCommand, dataSource: DataSource): Promise<void> {
const { emoji } = command.payload;
await dataSource.getRepository(CustomEmojiEntity).save({
id: emoji.id,
name: emoji.name,
creatorUserId: emoji.creatorUserId,
dataUrl: emoji.dataUrl,
hash: emoji.hash,
mime: emoji.mime,
size: emoji.size,
createdAt: emoji.createdAt,
updatedAt: emoji.updatedAt
});
}

View File

@@ -19,6 +19,8 @@ import {
RemoveBanCommand,
SaveAttachmentCommand,
DeleteAttachmentsForMessageCommand,
SaveCustomEmojiCommand,
DeleteCustomEmojiCommand,
SavePluginDataCommand,
DeletePluginDataCommand,
SaveMetaCommand
@@ -39,6 +41,8 @@ import { handleSaveBan } from './handlers/saveBan';
import { handleRemoveBan } from './handlers/removeBan';
import { handleSaveAttachment } from './handlers/saveAttachment';
import { handleDeleteAttachmentsForMessage } from './handlers/deleteAttachmentsForMessage';
import { handleSaveCustomEmoji } from './handlers/saveCustomEmoji';
import { handleDeleteCustomEmoji } from './handlers/deleteCustomEmoji';
import { handleSavePluginData } from './handlers/savePluginData';
import { handleDeletePluginData } from './handlers/deletePluginData';
import { handleSaveMeta } from './handlers/saveMeta';
@@ -61,6 +65,8 @@ export const buildCommandHandlers = (dataSource: DataSource): Record<CommandType
[CommandType.RemoveBan]: (cmd) => handleRemoveBan(cmd as RemoveBanCommand, dataSource),
[CommandType.SaveAttachment]: (cmd) => handleSaveAttachment(cmd as SaveAttachmentCommand, dataSource),
[CommandType.DeleteAttachmentsForMessage]: (cmd) => handleDeleteAttachmentsForMessage(cmd as DeleteAttachmentsForMessageCommand, dataSource),
[CommandType.SaveCustomEmoji]: (cmd) => handleSaveCustomEmoji(cmd as SaveCustomEmojiCommand, dataSource),
[CommandType.DeleteCustomEmoji]: (cmd) => handleDeleteCustomEmoji(cmd as DeleteCustomEmojiCommand, dataSource),
[CommandType.SavePluginData]: (cmd) => handleSavePluginData(cmd as SavePluginDataCommand, dataSource),
[CommandType.DeletePluginData]: (cmd) => handleDeletePluginData(cmd as DeletePluginDataCommand, dataSource),
[CommandType.SaveMeta]: (cmd) => handleSaveMeta(cmd as SaveMetaCommand, dataSource),