aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/activitypub/actor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/activitypub/actor.ts')
-rw-r--r--server/models/activitypub/actor.ts44
1 files changed, 22 insertions, 22 deletions
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index a2fee0012..3b98e8841 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -1,5 +1,6 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import { extname } from 'path' 2import { extname } from 'path'
3import { literal, Op, Transaction } from 'sequelize'
3import { 4import {
4 AllowNull, 5 AllowNull,
5 BelongsTo, 6 BelongsTo,
@@ -16,6 +17,7 @@ import {
16 Table, 17 Table,
17 UpdatedAt 18 UpdatedAt
18} from 'sequelize-typescript' 19} from 'sequelize-typescript'
20import { ModelCache } from '@server/models/model-cache'
19import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub' 21import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub'
20import { Avatar } from '../../../shared/models/avatars/avatar.model' 22import { Avatar } from '../../../shared/models/avatars/avatar.model'
21import { activityPubContextify } from '../../helpers/activitypub' 23import { activityPubContextify } from '../../helpers/activitypub'
@@ -28,13 +30,6 @@ import {
28} from '../../helpers/custom-validators/activitypub/actor' 30} from '../../helpers/custom-validators/activitypub/actor'
29import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 31import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
30import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants' 32import { ACTIVITY_PUB, ACTIVITY_PUB_ACTOR_TYPES, CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants'
31import { AccountModel } from '../account/account'
32import { AvatarModel } from '../avatar/avatar'
33import { ServerModel } from '../server/server'
34import { isOutdated, throwIfNotValid } from '../utils'
35import { VideoChannelModel } from '../video/video-channel'
36import { ActorFollowModel } from './actor-follow'
37import { VideoModel } from '../video/video'
38import { 33import {
39 MActor, 34 MActor,
40 MActorAccountChannelId, 35 MActorAccountChannelId,
@@ -43,12 +38,17 @@ import {
43 MActorFull, 38 MActorFull,
44 MActorHost, 39 MActorHost,
45 MActorServer, 40 MActorServer,
46 MActorSummaryFormattable, MActorUrl, 41 MActorSummaryFormattable,
42 MActorUrl,
47 MActorWithInboxes 43 MActorWithInboxes
48} from '../../types/models' 44} from '../../types/models'
49import * as Bluebird from 'bluebird' 45import { AccountModel } from '../account/account'
50import { Op, Transaction, literal } from 'sequelize' 46import { AvatarModel } from '../avatar/avatar'
51import { ModelCache } from '@server/models/model-cache' 47import { ServerModel } from '../server/server'
48import { isOutdated, throwIfNotValid } from '../utils'
49import { VideoModel } from '../video/video'
50import { VideoChannelModel } from '../video/video-channel'
51import { ActorFollowModel } from './actor-follow'
52 52
53enum ScopeNames { 53enum ScopeNames {
54 FULL = 'FULL' 54 FULL = 'FULL'
@@ -146,7 +146,7 @@ export const unusedActorAttributesForAPI = [
146 } 146 }
147 ] 147 ]
148}) 148})
149export class ActorModel extends Model<ActorModel> { 149export class ActorModel extends Model {
150 150
151 @AllowNull(false) 151 @AllowNull(false)
152 @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES))) 152 @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES)))
@@ -276,15 +276,15 @@ export class ActorModel extends Model<ActorModel> {
276 }) 276 })
277 VideoChannel: VideoChannelModel 277 VideoChannel: VideoChannelModel
278 278
279 static load (id: number): Bluebird<MActor> { 279 static load (id: number): Promise<MActor> {
280 return ActorModel.unscoped().findByPk(id) 280 return ActorModel.unscoped().findByPk(id)
281 } 281 }
282 282
283 static loadFull (id: number): Bluebird<MActorFull> { 283 static loadFull (id: number): Promise<MActorFull> {
284 return ActorModel.scope(ScopeNames.FULL).findByPk(id) 284 return ActorModel.scope(ScopeNames.FULL).findByPk(id)
285 } 285 }
286 286
287 static loadFromAccountByVideoId (videoId: number, transaction: Transaction): Bluebird<MActor> { 287 static loadFromAccountByVideoId (videoId: number, transaction: Transaction): Promise<MActor> {
288 const query = { 288 const query = {
289 include: [ 289 include: [
290 { 290 {
@@ -328,7 +328,7 @@ export class ActorModel extends Model<ActorModel> {
328 .then(a => !!a) 328 .then(a => !!a)
329 } 329 }
330 330
331 static listByFollowersUrls (followersUrls: string[], transaction?: Transaction): Bluebird<MActorFull[]> { 331 static listByFollowersUrls (followersUrls: string[], transaction?: Transaction): Promise<MActorFull[]> {
332 const query = { 332 const query = {
333 where: { 333 where: {
334 followersUrl: { 334 followersUrl: {
@@ -341,7 +341,7 @@ export class ActorModel extends Model<ActorModel> {
341 return ActorModel.scope(ScopeNames.FULL).findAll(query) 341 return ActorModel.scope(ScopeNames.FULL).findAll(query)
342 } 342 }
343 343
344 static loadLocalByName (preferredUsername: string, transaction?: Transaction): Bluebird<MActorFull> { 344 static loadLocalByName (preferredUsername: string, transaction?: Transaction): Promise<MActorFull> {
345 const fun = () => { 345 const fun = () => {
346 const query = { 346 const query = {
347 where: { 347 where: {
@@ -364,7 +364,7 @@ export class ActorModel extends Model<ActorModel> {
364 }) 364 })
365 } 365 }
366 366
367 static loadLocalUrlByName (preferredUsername: string, transaction?: Transaction): Bluebird<MActorUrl> { 367 static loadLocalUrlByName (preferredUsername: string, transaction?: Transaction): Promise<MActorUrl> {
368 const fun = () => { 368 const fun = () => {
369 const query = { 369 const query = {
370 attributes: [ 'url' ], 370 attributes: [ 'url' ],
@@ -388,7 +388,7 @@ export class ActorModel extends Model<ActorModel> {
388 }) 388 })
389 } 389 }
390 390
391 static loadByNameAndHost (preferredUsername: string, host: string): Bluebird<MActorFull> { 391 static loadByNameAndHost (preferredUsername: string, host: string): Promise<MActorFull> {
392 const query = { 392 const query = {
393 where: { 393 where: {
394 preferredUsername 394 preferredUsername
@@ -407,7 +407,7 @@ export class ActorModel extends Model<ActorModel> {
407 return ActorModel.scope(ScopeNames.FULL).findOne(query) 407 return ActorModel.scope(ScopeNames.FULL).findOne(query)
408 } 408 }
409 409
410 static loadByUrl (url: string, transaction?: Transaction): Bluebird<MActorAccountChannelId> { 410 static loadByUrl (url: string, transaction?: Transaction): Promise<MActorAccountChannelId> {
411 const query = { 411 const query = {
412 where: { 412 where: {
413 url 413 url
@@ -430,7 +430,7 @@ export class ActorModel extends Model<ActorModel> {
430 return ActorModel.unscoped().findOne(query) 430 return ActorModel.unscoped().findOne(query)
431 } 431 }
432 432
433 static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Transaction): Bluebird<MActorFull> { 433 static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Transaction): Promise<MActorFull> {
434 const query = { 434 const query = {
435 where: { 435 where: {
436 url 436 url
@@ -461,7 +461,7 @@ export class ActorModel extends Model<ActorModel> {
461 }, { where, transaction }) 461 }, { where, transaction })
462 } 462 }
463 463
464 static loadAccountActorByVideoId (videoId: number): Bluebird<MActor> { 464 static loadAccountActorByVideoId (videoId: number): Promise<MActor> {
465 const query = { 465 const query = {
466 include: [ 466 include: [
467 { 467 {