From 2c01951791cfa85dc0836b71ef49ae57670ae6c2 Mon Sep 17 00:00:00 2001 From: xuncha <1658671838@qq.com> Date: Sat, 25 Apr 2026 14:17:32 +0800 Subject: [PATCH] =?UTF-8?q?chatlab=E4=BC=9A=E8=AF=9D=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/services/httpService.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/electron/services/httpService.ts b/electron/services/httpService.ts index 5715486..a2b5c72 100644 --- a/electron/services/httpService.ts +++ b/electron/services/httpService.ts @@ -26,7 +26,7 @@ interface ChatLabHeader { interface ChatLabMeta { name: string platform: string - type: 'group' | 'private' + type: ApiSessionType groupId?: string groupAvatar?: string ownerId?: string @@ -68,6 +68,7 @@ interface ApiMediaOptions { } type MediaKind = 'image' | 'voice' | 'video' | 'emoji' +type ApiSessionType = 'group' | 'private' | 'channel' | 'other' interface ApiExportedMedia { kind: MediaKind @@ -781,6 +782,17 @@ class HttpService { } } + private getApiSessionType(username: string): ApiSessionType { + const normalized = String(username || '').trim() + const lowered = normalized.toLowerCase() + if (!normalized) return 'other' + if (lowered.endsWith('@chatroom')) return 'group' + if (lowered.startsWith('gh_')) return 'channel' + if (lowered.includes('@openim')) return 'channel' + if (lowered.startsWith('weixin') && lowered !== 'weixin') return 'channel' + return 'private' + } + private async handleMessages(url: URL, res: http.ServerResponse): Promise { const talker = (url.searchParams.get('talker') || '').trim() const limit = this.parseIntParam(url.searchParams.get('limit'), 100, 1, 10000) @@ -910,7 +922,7 @@ class HttpService { id: s.username, name: s.displayName || s.username, platform: 'wechat', - type: s.username.endsWith('@chatroom') ? 'group' : 'private', + type: this.getApiSessionType(s.username), messageCount: s.messageCountHint || undefined, lastMessageAt: s.lastTimestamp })) @@ -925,6 +937,7 @@ class HttpService { username: s.username, displayName: s.displayName, type: s.type, + sessionType: this.getApiSessionType(s.username), lastTimestamp: s.lastTimestamp, unreadCount: s.unreadCount })) @@ -1882,7 +1895,7 @@ class HttpService { meta: { name: talkerName, platform: 'wechat', - type: isGroup ? 'group' : 'private', + type: this.getApiSessionType(talkerId), groupId: isGroup ? talkerId : undefined, groupAvatar: isGroup ? sessionAvatarInfo?.avatarUrl : undefined, ownerId: myWxid || undefined