fix: improve plugins functionality with server management
This commit is contained in:
@@ -1,12 +1,19 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
import { getCurrentUserScope } from '../../current-user-scope';
|
||||
import { PluginDataEntity } from '../../../entities';
|
||||
import { SavePluginDataCommand } from '../../types';
|
||||
|
||||
export async function handleSavePluginData(command: SavePluginDataCommand, dataSource: DataSource): Promise<void> {
|
||||
const { payload } = command;
|
||||
const ownerUserId = await getCurrentUserScope(dataSource);
|
||||
|
||||
if (!ownerUserId) {
|
||||
return;
|
||||
}
|
||||
|
||||
await dataSource.getRepository(PluginDataEntity).save({
|
||||
key: payload.key,
|
||||
ownerUserId,
|
||||
pluginId: payload.pluginId,
|
||||
scope: payload.scope,
|
||||
serverId: payload.serverId ?? '',
|
||||
|
||||
Reference in New Issue
Block a user