chore: 补充所需要的方法

This commit is contained in:
CrescentLeaf
2025-11-01 01:13:17 +08:00
parent 8b3b32422f
commit 661cebdb24
2 changed files with 8 additions and 2 deletions

View File

@@ -231,7 +231,10 @@ export default class Chat {
if (this.bean.type == 'group') return this.bean.avatar_file_hash
if (this.bean.type == 'private') return this.getAnotherUserForPrivate(userMySelf as User)?.getAvatarFileHash()
}
setAvatarFileHash(hash: string) {
this.setAttr("avatar_file_hash", hash)
}
async setAvatar(avatar: Buffer) {
this.setAttr("avatar_file_hash", (await FileManager.uploadFile(`avatar_chat_${this.bean.count}`, avatar)).getHash())
this.setAvatarFileHash((await FileManager.uploadFile(`avatar_chat_${this.bean.count}`, avatar)).getHash())
}
}

View File

@@ -167,7 +167,10 @@ export default class User {
getAvatarFileHash() {
return this.bean.avatar_file_hash
}
setAvatarFileHash(hash: string) {
this.setAttr("avatar_file_hash", hash)
}
async setAvatar(avatar: Buffer) {
this.setAttr("avatar_file_hash", (await FileManager.uploadFile(`avatar_user_${this.bean.count}`, avatar)).getHash())
this.setAvatarFileHash((await FileManager.uploadFile(`avatar_user_${this.bean.count}`, avatar)).getHash())
}
}