]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/account.ts
WIP plugins: update plugin
[github/Chocobozzz/PeerTube.git] / server / models / account / account.ts
index bf2ed0a61efb42e0eec138e0565b78a82e959411..09cada0967abf5ad39c820fbd20ee888717fa9ee 100644 (file)
@@ -3,7 +3,7 @@ import {
   BeforeDestroy,
   BelongsTo,
   Column,
-  CreatedAt,
+  CreatedAt, DataType,
   Default,
   DefaultScope,
   ForeignKey,
@@ -26,28 +26,28 @@ import { VideoCommentModel } from '../video/video-comment'
 import { UserModel } from './user'
 import { AvatarModel } from '../avatar/avatar'
 import { VideoPlaylistModel } from '../video/video-playlist'
-import { WEBSERVER } from '../../initializers/constants'
+import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants'
 import { Op, Transaction, WhereOptions } from 'sequelize'
 
 export enum ScopeNames {
   SUMMARY = 'SUMMARY'
 }
 
-@DefaultScope({
+@DefaultScope(() => ({
   include: [
     {
-      model: () => ActorModel, // Default scope includes avatar and server
+      model: ActorModel, // Default scope includes avatar and server
       required: true
     }
   ]
-})
-@Scopes({
+}))
+@Scopes(() => ({
   [ ScopeNames.SUMMARY ]: (whereActor?: WhereOptions) => {
     return {
       attributes: [ 'id', 'name' ],
       include: [
         {
-          attributes: [ 'id', 'uuid', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
+          attributes: [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ],
           model: ActorModel.unscoped(),
           required: true,
           where: whereActor,
@@ -66,7 +66,7 @@ export enum ScopeNames {
       ]
     }
   }
-})
+}))
 @Table({
   tableName: 'account',
   indexes: [
@@ -91,7 +91,7 @@ export class AccountModel extends Model<AccountModel> {
   @AllowNull(true)
   @Default(null)
   @Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description', true))
-  @Column
+  @Column(DataType.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max))
   description: string
 
   @CreatedAt
@@ -180,22 +180,6 @@ export class AccountModel extends Model<AccountModel> {
     return AccountModel.findByPk(id, { transaction })
   }
 
-  static loadByUUID (uuid: string) {
-    const query = {
-      include: [
-        {
-          model: ActorModel,
-          required: true,
-          where: {
-            uuid
-          }
-        }
-      ]
-    }
-
-    return AccountModel.findOne(query)
-  }
-
   static loadByNameWithHost (nameWithHost: string) {
     const [ accountName, host ] = nameWithHost.split('@')
 
@@ -332,7 +316,6 @@ export class AccountModel extends Model<AccountModel> {
 
     return {
       id: this.id,
-      uuid: actor.uuid,
       name: actor.name,
       displayName: this.getDisplayName(),
       url: actor.url,