]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/account.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / server / models / account / account.ts
index dc989417bf2ab4c9aea8020e3127584e645c90d4..396959352c3792b9bae35f80f9e68e475e9f1cf7 100644 (file)
@@ -28,8 +28,9 @@ import {
   MAccountAP,
   MAccountDefault,
   MAccountFormattable,
+  MAccountHost,
   MAccountSummaryFormattable,
-  MChannelActor
+  MChannelHost
 } from '../../types/models'
 import { ActorModel } from '../actor/actor'
 import { ActorFollowModel } from '../actor/actor-follow'
@@ -37,8 +38,8 @@ import { ActorImageModel } from '../actor/actor-image'
 import { ApplicationModel } from '../application/application'
 import { ServerModel } from '../server/server'
 import { ServerBlocklistModel } from '../server/server-blocklist'
-import { UserModel } from '../user/user'
 import { buildSQLAttributes, getSort, throwIfNotValid } from '../shared'
+import { UserModel } from '../user/user'
 import { VideoModel } from '../video/video'
 import { VideoChannelModel } from '../video/video-channel'
 import { VideoCommentModel } from '../video/video-comment'
@@ -296,9 +297,7 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
           {
             model: ActorModel,
             required: true,
-            where: {
-              preferredUsername: name
-            }
+            where: ActorModel.wherePreferredUsername(name)
           }
         ]
       }
@@ -321,9 +320,7 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
         {
           model: ActorModel,
           required: true,
-          where: {
-            preferredUsername: name
-          },
+          where: ActorModel.wherePreferredUsername(name),
           include: [
             {
               model: ServerModel,
@@ -414,10 +411,6 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
       .findAll(query)
   }
 
-  getClientUrl () {
-    return WEBSERVER.URL + '/accounts/' + this.Actor.getIdentifier()
-  }
-
   toFormattedJSON (this: MAccountFormattable): Account {
     return {
       ...this.Actor.toFormattedJSON(),
@@ -447,8 +440,8 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
     }
   }
 
-  toActivityPubObject (this: MAccountAP) {
-    const obj = this.Actor.toActivityPubObject(this.name)
+  async toActivityPubObject (this: MAccountAP) {
+    const obj = await this.Actor.toActivityPubObject(this.name)
 
     return Object.assign(obj, {
       summary: this.description
@@ -467,8 +460,9 @@ export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
     return this.name
   }
 
-  getLocalUrl (this: MAccountActor | MChannelActor) {
-    return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername
+  // Avoid error when running this method on MAccount... | MChannel...
+  getClientUrl (this: MAccountHost | MChannelHost) {
+    return WEBSERVER.URL + '/a/' + this.Actor.getIdentifier()
   }
 
   isBlocked () {