feat: Blurhash integration

Resolve #6559
This commit is contained in:
syuilo
2020-07-19 00:24:07 +09:00
parent 705d40ab37
commit 3f71b14637
22 changed files with 249 additions and 214 deletions

View File

@ -67,6 +67,12 @@ export class DriveFile {
})
public comment: string | null;
@Column('varchar', {
length: 128, nullable: true,
comment: 'The BlurHash string.'
})
public blurhash: string | null;
@Column('jsonb', {
default: {},
comment: 'The any properties of the DriveFile. For example, it includes image width/height.'

View File

@ -106,14 +106,14 @@ export class User {
public bannerUrl: string | null;
@Column('varchar', {
length: 32, nullable: true,
length: 128, nullable: true,
})
public avatarColor: string | null;
public avatarBlurhash: string | null;
@Column('varchar', {
length: 32, nullable: true,
length: 128, nullable: true,
})
public bannerColor: string | null;
public bannerBlurhash: string | null;
@Column('boolean', {
default: false,

View File

@ -115,6 +115,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
md5: file.md5,
size: file.size,
isSensitive: file.isSensitive,
blurhash: file.blurhash,
properties: file.properties,
url: opts.self ? file.url : this.getPublicUrl(file, false, meta),
thumbnailUrl: this.getPublicUrl(file, true, meta),

View File

@ -165,7 +165,8 @@ export class UserRepository extends Repository<User> {
username: user.username,
host: user.host,
avatarUrl: user.avatarUrl ? user.avatarUrl : config.url + '/avatar/' + user.id,
avatarColor: user.avatarColor,
avatarBlurhash: user.avatarBlurhash,
avatarColor: null, // 後方互換性のため
isAdmin: user.isAdmin || falsy,
isModerator: user.isModerator || falsy,
isBot: user.isBot || falsy,
@ -196,7 +197,8 @@ export class UserRepository extends Repository<User> {
createdAt: user.createdAt.toISOString(),
updatedAt: user.updatedAt ? user.updatedAt.toISOString() : null,
bannerUrl: user.bannerUrl,
bannerColor: user.bannerColor,
bannerBlurhash: user.bannerBlurhash,
bannerColor: null, // 後方互換性のため
isLocked: user.isLocked,
isModerator: user.isModerator || falsy,
isSilenced: user.isSilenced || falsy,
@ -331,7 +333,7 @@ export const packedUserSchema = {
format: 'url',
nullable: true as const, optional: false as const,
},
avatarColor: {
avatarBlurhash: {
type: 'any' as const,
nullable: true as const, optional: false as const,
},
@ -340,7 +342,7 @@ export const packedUserSchema = {
format: 'url',
nullable: true as const, optional: true as const,
},
bannerColor: {
bannerBlurhash: {
type: 'any' as const,
nullable: true as const, optional: true as const,
},