aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account.ts6
-rw-r--r--server/models/account/user.ts8
2 files changed, 9 insertions, 5 deletions
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 {
13 Table, 13 Table,
14 UpdatedAt 14 UpdatedAt
15} from 'sequelize-typescript' 15} from 'sequelize-typescript'
16import { Account } from '../../../shared/models/actors'
16import { isUserUsernameValid } from '../../helpers/custom-validators/users' 17import { isUserUsernameValid } from '../../helpers/custom-validators/users'
17import { sendDeleteActor } from '../../lib/activitypub/send' 18import { sendDeleteActor } from '../../lib/activitypub/send'
18import { ActorModel } from '../activitypub/actor' 19import { ActorModel } from '../activitypub/actor'
@@ -165,11 +166,12 @@ export class AccountModel extends Model<AccountModel> {
165 return AccountModel.findOne(query) 166 return AccountModel.findOne(query)
166 } 167 }
167 168
168 toFormattedJSON () { 169 toFormattedJSON (): Account {
169 const actor = this.Actor.toFormattedJSON() 170 const actor = this.Actor.toFormattedJSON()
170 const account = { 171 const account = {
171 id: this.id, 172 id: this.id,
172 name: this.name, 173 name: this.Actor.preferredUsername,
174 displayName: this.name,
173 createdAt: this.createdAt, 175 createdAt: this.createdAt,
174 updatedAt: this.updatedAt 176 updatedAt: this.updatedAt
175 } 177 }
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 {
4 Scopes, Table, UpdatedAt 4 Scopes, Table, UpdatedAt
5} from 'sequelize-typescript' 5} from 'sequelize-typescript'
6import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared' 6import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared'
7import { User } from '../../../shared/models/users'
7import { 8import {
8 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid, 9 isUserAutoPlayVideoValid, isUserDisplayNSFWValid, isUserPasswordValid, isUserRoleValid, isUserUsernameValid,
9 isUserVideoQuotaValid 10 isUserVideoQuotaValid
@@ -210,7 +211,7 @@ export class UserModel extends Model<UserModel> {
210 return comparePassword(password, this.password) 211 return comparePassword(password, this.password)
211 } 212 }
212 213
213 toFormattedJSON () { 214 toFormattedJSON (): User {
214 const json = { 215 const json = {
215 id: this.id, 216 id: this.id,
216 username: this.username, 217 username: this.username,
@@ -221,11 +222,12 @@ export class UserModel extends Model<UserModel> {
221 roleLabel: USER_ROLE_LABELS[ this.role ], 222 roleLabel: USER_ROLE_LABELS[ this.role ],
222 videoQuota: this.videoQuota, 223 videoQuota: this.videoQuota,
223 createdAt: this.createdAt, 224 createdAt: this.createdAt,
224 account: this.Account.toFormattedJSON() 225 account: this.Account.toFormattedJSON(),
226 videoChannels: []
225 } 227 }
226 228
227 if (Array.isArray(this.Account.VideoChannels) === true) { 229 if (Array.isArray(this.Account.VideoChannels) === true) {
228 json['videoChannels'] = this.Account.VideoChannels 230 json.videoChannels = this.Account.VideoChannels
229 .map(c => c.toFormattedJSON()) 231 .map(c => c.toFormattedJSON())
230 .sort((v1, v2) => { 232 .sort((v1, v2) => {
231 if (v1.createdAt < v2.createdAt) return -1 233 if (v1.createdAt < v2.createdAt) return -1