From 2ff3069d23aa688cea5a3bd204236f2f2f64c201 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Apr 2019 01:52:25 +0900 Subject: トランザクションを使うようにしたり MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/entities/user-keypair.ts | 8 ++++++++ src/models/entities/user-profile.ts | 14 ++++++++++++++ src/models/entities/user-publickey.ts | 8 ++++++++ src/models/entities/user.ts | 8 ++++++++ src/models/repositories/user.ts | 2 +- 5 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src/models') diff --git a/src/models/entities/user-keypair.ts b/src/models/entities/user-keypair.ts index 808985f473..603321d758 100644 --- a/src/models/entities/user-keypair.ts +++ b/src/models/entities/user-keypair.ts @@ -22,4 +22,12 @@ export class UserKeypair { length: 4096, }) public privateKey: string; + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } diff --git a/src/models/entities/user-profile.ts b/src/models/entities/user-profile.ts index 421d17c59e..a2d7b8d2c2 100644 --- a/src/models/entities/user-profile.ts +++ b/src/models/entities/user-profile.ts @@ -39,6 +39,12 @@ export class UserProfile { value: string; }[]; + @Column('varchar', { + length: 512, nullable: true, + comment: 'Remote URL of the user.' + }) + public url: string | null; + @Column('varchar', { length: 128, nullable: true, comment: 'The email address of the User.' @@ -192,4 +198,12 @@ export class UserProfile { }) public userHost: string | null; //#endregion + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } diff --git a/src/models/entities/user-publickey.ts b/src/models/entities/user-publickey.ts index 26b694407d..21edc3e9e2 100644 --- a/src/models/entities/user-publickey.ts +++ b/src/models/entities/user-publickey.ts @@ -23,4 +23,12 @@ export class UserPublickey { length: 4096, }) public keyPem: string; + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } diff --git a/src/models/entities/user.ts b/src/models/entities/user.ts index ebf07ff3ff..e40c32a76f 100644 --- a/src/models/entities/user.ts +++ b/src/models/entities/user.ts @@ -205,6 +205,14 @@ export class User { comment: 'The native access token of the User. It will be null if the origin of the user is local.' }) public token: string | null; + + constructor(data: Partial) { + if (data == null) return; + + for (const [k, v] of Object.entries(data)) { + (this as any)[k] = v; + } + } } export interface ILocalUser extends User { diff --git a/src/models/repositories/user.ts b/src/models/repositories/user.ts index ac18b18996..d7f2c3d040 100644 --- a/src/models/repositories/user.ts +++ b/src/models/repositories/user.ts @@ -87,7 +87,6 @@ export class UserRepository extends Repository { name: user.name, username: user.username, host: user.host, - uri: user.uri, avatarUrl: user.avatarUrl, bannerUrl: user.bannerUrl, avatarColor: user.avatarColor, @@ -118,6 +117,7 @@ export class UserRepository extends Repository { } : {}), ...(opts.detail ? { + url: profile.url, createdAt: user.createdAt, updatedAt: user.updatedAt, description: profile.description, -- cgit v1.2.3-freya