Keep desktop modals open on outside click and allow larger group member lists.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -40,6 +40,34 @@ export class ConversationsService {
|
||||
return `${organizationId}|${roomId}|${userId}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* سرویس خارجی چت اغلب در create بیش از ~۶ عضو را رد میکند.
|
||||
* ابتدا با سقف کوچک میسازیم و بقیه را با add_members اضافه میکنیم.
|
||||
*/
|
||||
private async createExternalRoomChunked(
|
||||
host: string,
|
||||
apiKey: string,
|
||||
name: string,
|
||||
type: string,
|
||||
members: string[],
|
||||
): Promise<{ room_id: string }> {
|
||||
const CREATE_CAP = 6;
|
||||
const ADD_CHUNK = 6;
|
||||
const unique = [...new Set(members.filter(Boolean))];
|
||||
const head = unique.slice(0, CREATE_CAP);
|
||||
const rest = unique.slice(CREATE_CAP);
|
||||
const created = await this.chat.createRoom(host, apiKey, {
|
||||
name,
|
||||
type,
|
||||
members: head.length ? head : unique.slice(0, 1),
|
||||
});
|
||||
for (let i = 0; i < rest.length; i += ADD_CHUNK) {
|
||||
const chunk = rest.slice(i, i + ADD_CHUNK);
|
||||
await this.chat.addRoomMembers(host, apiKey, created.room_id, chunk);
|
||||
}
|
||||
return created;
|
||||
}
|
||||
|
||||
private sweepTypingPresence(now = Date.now()) {
|
||||
if (now - this.typingSweepAt < 10_000) return;
|
||||
this.typingSweepAt = now;
|
||||
@@ -483,11 +511,13 @@ export class ConversationsService {
|
||||
...uniqueIds.map((id) => buildChatUserId(organizationId, id)),
|
||||
];
|
||||
const trimmedName = name.trim();
|
||||
const created = await this.chat.createRoom(creds.host, creds.apiKey, {
|
||||
name: trimmedName,
|
||||
type: 'GROUP',
|
||||
const created = await this.createExternalRoomChunked(
|
||||
creds.host,
|
||||
creds.apiKey,
|
||||
trimmedName,
|
||||
'GROUP',
|
||||
members,
|
||||
});
|
||||
);
|
||||
|
||||
const row = await this.prisma.conversationRoom.create({
|
||||
data: {
|
||||
@@ -548,11 +578,13 @@ export class ConversationsService {
|
||||
];
|
||||
const trimmedName = name.trim();
|
||||
// سرویس خارجی معمولاً CHANNEL ندارد؛ بهصورت GROUP ساخته و در CRM بهعنوان کانال یکطرفه نگه داشته میشود
|
||||
const created = await this.chat.createRoom(creds.host, creds.apiKey, {
|
||||
name: trimmedName,
|
||||
type: 'GROUP',
|
||||
const created = await this.createExternalRoomChunked(
|
||||
creds.host,
|
||||
creds.apiKey,
|
||||
trimmedName,
|
||||
'GROUP',
|
||||
members,
|
||||
});
|
||||
);
|
||||
|
||||
const row = await this.prisma.conversationRoom.create({
|
||||
data: {
|
||||
|
||||
Reference in New Issue
Block a user