fix: Chat 創建失敗, 並修正了 ChatPrivate 獲取對方的邏輯

This commit is contained in:
CrescentLeaf
2025-09-21 02:17:44 +08:00
parent 71e6d24d6e
commit 6a1084eeca
2 changed files with 10 additions and 6 deletions

View File

@@ -12,10 +12,14 @@ export default class ChatPrivate extends Chat {
}
static createForPrivate(userA: User, userB: User) {
return this.create(this.getChatIdByUsersId(userA.bean.id, userB.bean.id), 'private')
const chat = this.create(this.getChatIdByUsersId(userA.bean.id, userB.bean.id), 'private')
chat.setAttr('user_a_id', userA.bean.id)
chat.setAttr('user_b_id', userB.bean.id)
}
static findByUsersForPrivate(userA: User, userB: User) {
return this.fromChat(this.findById(this.getChatIdByUsersId(userA.bean.id, userB.bean.id)) as Chat)
const chat = this.findById(this.getChatIdByUsersId(userA.bean.id, userB.bean.id))
if (chat)
return this.fromChat(chat as Chat)
}
static findOrCreateForPrivate(userA: User, userB: User) {
let a = this.findByUsersForPrivate(userA, userB)