feat: plugins v1.5
This commit is contained in:
@@ -11,7 +11,8 @@ import {
|
||||
ReactionEntity,
|
||||
BanEntity,
|
||||
AttachmentEntity,
|
||||
MetaEntity
|
||||
MetaEntity,
|
||||
PluginDataEntity
|
||||
} from '../../../entities';
|
||||
|
||||
export async function handleClearAllData(dataSource: DataSource): Promise<void> {
|
||||
@@ -27,4 +28,5 @@ export async function handleClearAllData(dataSource: DataSource): Promise<void>
|
||||
await dataSource.getRepository(BanEntity).clear();
|
||||
await dataSource.getRepository(AttachmentEntity).clear();
|
||||
await dataSource.getRepository(MetaEntity).clear();
|
||||
await dataSource.getRepository(PluginDataEntity).clear();
|
||||
}
|
||||
|
||||
14
electron/cqrs/commands/handlers/deletePluginData.ts
Normal file
14
electron/cqrs/commands/handlers/deletePluginData.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { PluginDataEntity } from '../../../entities';
|
||||
import { DeletePluginDataCommand } from '../../types';
|
||||
|
||||
export async function handleDeletePluginData(command: DeletePluginDataCommand, dataSource: DataSource): Promise<void> {
|
||||
const { payload } = command;
|
||||
|
||||
await dataSource.getRepository(PluginDataEntity).delete({
|
||||
key: payload.key,
|
||||
pluginId: payload.pluginId,
|
||||
scope: payload.scope,
|
||||
serverId: payload.serverId ?? ''
|
||||
});
|
||||
}
|
||||
10
electron/cqrs/commands/handlers/saveMeta.ts
Normal file
10
electron/cqrs/commands/handlers/saveMeta.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { MetaEntity } from '../../../entities';
|
||||
import { SaveMetaCommand } from '../../types';
|
||||
|
||||
export async function handleSaveMeta(command: SaveMetaCommand, dataSource: DataSource): Promise<void> {
|
||||
await dataSource.getRepository(MetaEntity).save({
|
||||
key: command.payload.key,
|
||||
value: command.payload.value
|
||||
});
|
||||
}
|
||||
16
electron/cqrs/commands/handlers/savePluginData.ts
Normal file
16
electron/cqrs/commands/handlers/savePluginData.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { PluginDataEntity } from '../../../entities';
|
||||
import { SavePluginDataCommand } from '../../types';
|
||||
|
||||
export async function handleSavePluginData(command: SavePluginDataCommand, dataSource: DataSource): Promise<void> {
|
||||
const { payload } = command;
|
||||
|
||||
await dataSource.getRepository(PluginDataEntity).save({
|
||||
key: payload.key,
|
||||
pluginId: payload.pluginId,
|
||||
scope: payload.scope,
|
||||
serverId: payload.serverId ?? '',
|
||||
updatedAt: Date.now(),
|
||||
valueJson: JSON.stringify(payload.value ?? null)
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user