fix: 修复创建文本频道时无法立即监听会话的bug

pull/49/head
moonrailgun 3 years ago
parent 15a4571a08
commit f2bea54aa3

@ -52,8 +52,16 @@ export class GroupPanel {
@prop()
parentId?: string; // 父节点id
/**
* :
* 0
* 1
* 2
*
* Reference: https://discord.com/developers/docs/resources/channel#channel-object-channel-types
*/
@prop()
type: number; // 面板类型: Reference: https://discord.com/developers/docs/resources/channel#channel-object-channel-types
type: number;
@prop()
provider?: string; // 面板提供者,为插件的标识,仅面板类型为插件时有效

@ -8,6 +8,15 @@ import {
export function call(ctx: TcContext) {
return {
/**
* socketio
*/
async joinSocketIORoom(roomIds: string[], userId?: string) {
await ctx.call('gateway.joinRoom', {
roomIds,
userId,
});
},
/**
*
* groupId
@ -72,7 +81,7 @@ export function call(ctx: TcContext) {
/**
*
*/
async getGroupInfo(groupId: string): Promise<GroupStruct> {
async getGroupInfo(groupId: string): Promise<GroupStruct | null> {
return await ctx.call('group.getGroupInfo', {
groupId,
});

@ -70,10 +70,7 @@ class ConverseService extends TcService {
const roomId = String(converse._id);
await Promise.all(
participantList.map((memberId) =>
ctx.call('gateway.joinRoom', {
roomIds: [roomId],
userId: memberId,
})
call(ctx).joinSocketIORoom([roomId], memberId)
)
);
@ -144,10 +141,7 @@ class ConverseService extends TcService {
await Promise.all(
memberIds.map((uid) =>
ctx.call('gateway.joinRoom', {
roomIds: [String(converseId)],
userId: uid,
})
call(ctx).joinSocketIORoom([String(converseId)], uid)
)
);
@ -233,9 +227,11 @@ class ConverseService extends TcService {
panelIds: string[];
}>('group.getJoinedGroupAndPanelIds');
await ctx.call('gateway.joinRoom', {
roomIds: [...dmConverseIds, ...groupIds, ...panelIds],
});
await call(ctx).joinSocketIORoom([
...dmConverseIds,
...groupIds,
...panelIds,
]);
return {
dmConverseIds,

@ -225,10 +225,10 @@ class GroupService extends TcService {
const textPanelIds = this.getGroupTextPanelIds(group);
await ctx.call('gateway.joinRoom', {
roomIds: [String(group._id), ...textPanelIds],
userId,
});
await call(ctx).joinSocketIORoom(
[String(group._id), ...textPanelIds],
userId
);
return this.transformDocuments(ctx, {}, group);
}
@ -411,10 +411,11 @@ class GroupService extends TcService {
this.unicastNotify(ctx, userId, 'add', group);
const textPanelIds = this.getGroupTextPanelIds(group);
await ctx.call('gateway.joinRoom', {
roomIds: [String(group._id), ...textPanelIds],
userId,
});
await call(ctx).joinSocketIORoom(
[String(group._id), ...textPanelIds],
userId
);
return group;
}
@ -591,6 +592,8 @@ class GroupService extends TcService {
throw new NoPermissionError(t('没有操作权限'));
}
const panelId = String(new Types.ObjectId());
const group = await this.adapter.model
.findOneAndUpdate(
{
@ -599,7 +602,7 @@ class GroupService extends TcService {
{
$push: {
panels: {
id: String(new Types.ObjectId()),
id: panelId,
name,
type,
parentId,
@ -615,6 +618,17 @@ class GroupService extends TcService {
)
.exec();
if (type === 0) {
/**
*
*
*/
const groupInfo = await call(ctx).getGroupInfo(groupId);
(groupInfo?.members ?? []).map((m) =>
call(ctx).joinSocketIORoom([panelId], m.userId)
);
}
this.notifyGroupInfoUpdate(ctx, group);
}

Loading…
Cancel
Save