mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 16:25:13 +00:00
enhance(server): make identicon same between local and remote
Resolve #10200
This commit is contained in:
parent
ba2630c615
commit
b9a3b2c165
2 changed files with 8 additions and 7 deletions
|
@ -15,6 +15,7 @@ You should also include the user name that made the change.
|
||||||
### Improvements
|
### Improvements
|
||||||
- クリップ、チャンネルページに共有ボタンを追加
|
- クリップ、チャンネルページに共有ボタンを追加
|
||||||
- ドライブの「URLからアップロード」で、content-dispositionのfilenameがあればそれをファイル名に
|
- ドライブの「URLからアップロード」で、content-dispositionのfilenameがあればそれをファイル名に
|
||||||
|
- Identiconがローカルとリモートで同じになるように
|
||||||
- サーバーのパフォーマンスを改善
|
- サーバーのパフォーマンスを改善
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
|
@ -278,27 +278,27 @@ export class UserEntityService implements OnModuleInit {
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getAvatarUrl(user: User): Promise<string> {
|
public async getAvatarUrl(user: User): Promise<string> {
|
||||||
if (user.avatar) {
|
if (user.avatar) {
|
||||||
return this.driveFileEntityService.getPublicUrl(user.avatar, 'avatar') ?? this.getIdenticonUrl(user.id);
|
return this.driveFileEntityService.getPublicUrl(user.avatar, 'avatar') ?? this.getIdenticonUrl(user);
|
||||||
} else if (user.avatarId) {
|
} else if (user.avatarId) {
|
||||||
const avatar = await this.driveFilesRepository.findOneByOrFail({ id: user.avatarId });
|
const avatar = await this.driveFilesRepository.findOneByOrFail({ id: user.avatarId });
|
||||||
return this.driveFileEntityService.getPublicUrl(avatar, 'avatar') ?? this.getIdenticonUrl(user.id);
|
return this.driveFileEntityService.getPublicUrl(avatar, 'avatar') ?? this.getIdenticonUrl(user);
|
||||||
} else {
|
} else {
|
||||||
return this.getIdenticonUrl(user.id);
|
return this.getIdenticonUrl(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public getAvatarUrlSync(user: User): string {
|
public getAvatarUrlSync(user: User): string {
|
||||||
if (user.avatar) {
|
if (user.avatar) {
|
||||||
return this.driveFileEntityService.getPublicUrl(user.avatar, 'avatar') ?? this.getIdenticonUrl(user.id);
|
return this.driveFileEntityService.getPublicUrl(user.avatar, 'avatar') ?? this.getIdenticonUrl(user);
|
||||||
} else {
|
} else {
|
||||||
return this.getIdenticonUrl(user.id);
|
return this.getIdenticonUrl(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public getIdenticonUrl(userId: User['id']): string {
|
public getIdenticonUrl(user: User): string {
|
||||||
return `${this.config.url}/identicon/${userId}`;
|
return `${this.config.url}/identicon/${user.usernameLower}@${user.host ?? this.config.host}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async pack<ExpectsMe extends boolean | null = null, D extends boolean = false>(
|
public async pack<ExpectsMe extends boolean | null = null, D extends boolean = false>(
|
||||||
|
|
Loading…
Reference in a new issue