From c5911fd347c76e8bdc05ea9f3ee9efed4a58c236 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Dec 2017 19:10:13 +0100 Subject: Begin to add avatar to actors --- server/models/account/account.ts | 6 ++++-- server/models/account/user.ts | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 1ee232537..d3503aaa3 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -13,6 +13,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { Account } from '../../../shared/models/actors' import { isUserUsernameValid } from '../../helpers/custom-validators/users' import { sendDeleteActor } from '../../lib/activitypub/send' import { ActorModel } from '../activitypub/actor' @@ -165,11 +166,12 @@ export class AccountModel extends Model { return AccountModel.findOne(query) } - toFormattedJSON () { + toFormattedJSON (): Account { const actor = this.Actor.toFormattedJSON() const account = { id: this.id, - name: this.name, + name: this.Actor.preferredUsername, + displayName: this.name, createdAt: this.createdAt, updatedAt: this.updatedAt } diff --git a/server/models/account/user.ts b/server/models/account/user.ts index d7e09e328..4226bcb35 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -4,6 +4,7 @@ import { Scopes, Table, UpdatedAt } from 'sequelize-typescript' import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' +import { User } from '../../../shared/models/users' import { isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, isUserVideoQuotaValid @@ -210,7 +211,7 @@ export class UserModel extends Model { return comparePassword(password, this.password) } - toFormattedJSON () { + toFormattedJSON (): User { const json = { id: this.id, username: this.username, @@ -221,11 +222,12 @@ export class UserModel extends Model { roleLabel: USER_ROLE_LABELS[ this.role ], videoQuota: this.videoQuota, createdAt: this.createdAt, - account: this.Account.toFormattedJSON() + account: this.Account.toFormattedJSON(), + videoChannels: [] } if (Array.isArray(this.Account.VideoChannels) === true) { - json['videoChannels'] = this.Account.VideoChannels + json.videoChannels = this.Account.VideoChannels .map(c => c.toFormattedJSON()) .sort((v1, v2) => { if (v1.createdAt < v2.createdAt) return -1 -- cgit v1.2.3