fix: 添加了新的字段代替 chat id

* 谁又能想到 chat id 的可变性和依赖性恰恰埋下了祸患呢
This commit is contained in:
CrescentLeaf
2025-10-24 22:21:28 +08:00
parent afd9193dea
commit 2d78e39ca1
9 changed files with 49 additions and 38 deletions

View File

@@ -8,11 +8,12 @@ export default class ChatPrivate extends Chat {
}
static getChatIdByUsersId(userIdA: string, userIdB: string) {
return [userIdA, userIdB].sort().join('------')
return 'priv_' + [userIdA, userIdB].sort().join('__').replaceAll('-', '_')
}
static createForPrivate(userA: User, userB: User) {
const chat = this.create(this.getChatIdByUsersId(userA.bean.id, userB.bean.id), 'private')
const chat = this.create(undefined, 'private')
chat.setAttr('id', this.getChatIdByUsersId(userA.bean.id, userB.bean.id))
chat.addMembers([
userA.bean.id,
userB.bean.id