mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 14:39:25 +08:00
Merge branch 'next' into develop
This commit is contained in:
commit
8928b97534
@ -187,6 +187,10 @@ export class WSServer extends EventEmitter {
|
||||
);
|
||||
});
|
||||
|
||||
app.on('ws:sendToClient', ({ clientId, message }) => {
|
||||
this.sendToClient(clientId, message);
|
||||
});
|
||||
|
||||
app.on('ws:sendToCurrentApp', ({ message }) => {
|
||||
this.sendToConnectionsByTag('app', app.name, message);
|
||||
});
|
||||
@ -196,13 +200,7 @@ export class WSServer extends EventEmitter {
|
||||
});
|
||||
|
||||
app.on('ws:authorized', ({ clientId, userId }) => {
|
||||
this.sendToConnectionsByTags(
|
||||
[
|
||||
{ tagName: 'userId', tagValue: userId },
|
||||
{ tagName: 'app', tagValue: app.name },
|
||||
],
|
||||
{ type: 'authorized' },
|
||||
);
|
||||
this.sendToClient(clientId, { type: 'authorized' });
|
||||
});
|
||||
}
|
||||
|
||||
@ -288,6 +286,13 @@ export class WSServer extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
sendToClient(clientId: string, sendMessage: object) {
|
||||
const client = this.webSocketClients.get(clientId);
|
||||
if (client) {
|
||||
this.sendMessageToConnection(client, sendMessage);
|
||||
}
|
||||
}
|
||||
|
||||
loopThroughConnections(callback: (client: WebSocketClient) => void) {
|
||||
this.webSocketClients.forEach((client) => {
|
||||
callback(client);
|
||||
|
@ -54,7 +54,7 @@ export class PluginAsyncExportServer extends Plugin {
|
||||
const asyncTaskManager = this.app.container.get<AsyncTasksManager>('AsyncTaskManager');
|
||||
|
||||
this.app.on(`ws:message:request:async-tasks:list`, async (message) => {
|
||||
const { tags } = message;
|
||||
const { tags, clientId } = message;
|
||||
|
||||
this.app.logger.info(`Received request for async tasks with tags: ${JSON.stringify(tags)}`);
|
||||
|
||||
@ -68,9 +68,8 @@ export class PluginAsyncExportServer extends Plugin {
|
||||
|
||||
this.app.logger.info(`Found ${tasks.length} tasks for userId: ${userId}`);
|
||||
|
||||
this.app.emit('ws:sendToTag', {
|
||||
tagKey: 'userId',
|
||||
tagValue: userId,
|
||||
this.app.emit('ws:sendToClient', {
|
||||
clientId,
|
||||
message: {
|
||||
type: 'async-tasks',
|
||||
payload: tasks.map((task) => task.toJSON()),
|
||||
|
@ -153,6 +153,7 @@ export class PluginAuthServer extends Plugin {
|
||||
userId: user.id,
|
||||
});
|
||||
});
|
||||
|
||||
this.app.auditManager.registerActions([
|
||||
{
|
||||
name: 'auth:signIn',
|
||||
|
Loading…
x
Reference in New Issue
Block a user