mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-08 06:59:26 +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 }) => {
|
app.on('ws:sendToCurrentApp', ({ message }) => {
|
||||||
this.sendToConnectionsByTag('app', app.name, message);
|
this.sendToConnectionsByTag('app', app.name, message);
|
||||||
});
|
});
|
||||||
@ -196,13 +200,7 @@ export class WSServer extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.on('ws:authorized', ({ clientId, userId }) => {
|
app.on('ws:authorized', ({ clientId, userId }) => {
|
||||||
this.sendToConnectionsByTags(
|
this.sendToClient(clientId, { type: 'authorized' });
|
||||||
[
|
|
||||||
{ tagName: 'userId', tagValue: userId },
|
|
||||||
{ tagName: 'app', tagValue: app.name },
|
|
||||||
],
|
|
||||||
{ 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) {
|
loopThroughConnections(callback: (client: WebSocketClient) => void) {
|
||||||
this.webSocketClients.forEach((client) => {
|
this.webSocketClients.forEach((client) => {
|
||||||
callback(client);
|
callback(client);
|
||||||
|
@ -54,7 +54,7 @@ export class PluginAsyncExportServer extends Plugin {
|
|||||||
const asyncTaskManager = this.app.container.get<AsyncTasksManager>('AsyncTaskManager');
|
const asyncTaskManager = this.app.container.get<AsyncTasksManager>('AsyncTaskManager');
|
||||||
|
|
||||||
this.app.on(`ws:message:request:async-tasks:list`, async (message) => {
|
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)}`);
|
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.logger.info(`Found ${tasks.length} tasks for userId: ${userId}`);
|
||||||
|
|
||||||
this.app.emit('ws:sendToTag', {
|
this.app.emit('ws:sendToClient', {
|
||||||
tagKey: 'userId',
|
clientId,
|
||||||
tagValue: userId,
|
|
||||||
message: {
|
message: {
|
||||||
type: 'async-tasks',
|
type: 'async-tasks',
|
||||||
payload: tasks.map((task) => task.toJSON()),
|
payload: tasks.map((task) => task.toJSON()),
|
||||||
|
@ -153,6 +153,7 @@ export class PluginAuthServer extends Plugin {
|
|||||||
userId: user.id,
|
userId: user.id,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
this.app.auditManager.registerActions([
|
this.app.auditManager.registerActions([
|
||||||
{
|
{
|
||||||
name: 'auth:signIn',
|
name: 'auth:signIn',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user