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.ts20
1 files changed, 13 insertions, 7 deletions
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 9cc53f78a..2312127b4 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -36,6 +36,8 @@ import { isOutdated, throwIfNotValid } from '../utils'
36import { VideoChannelModel } from '../video/video-channel' 36import { VideoChannelModel } from '../video/video-channel'
37import { ActorFollowModel } from './actor-follow' 37import { ActorFollowModel } from './actor-follow'
38import { VideoModel } from '../video/video' 38import { VideoModel } from '../video/video'
39import { MActor, MActorAccountChannelId, MActorFull } from '../../typings/models'
40import * as Bluebird from 'bluebird'
39 41
40enum ScopeNames { 42enum ScopeNames {
41 FULL = 'FULL' 43 FULL = 'FULL'
@@ -252,11 +254,15 @@ export class ActorModel extends Model<ActorModel> {
252 }) 254 })
253 VideoChannel: VideoChannelModel 255 VideoChannel: VideoChannelModel
254 256
255 static load (id: number) { 257 static load (id: number): Bluebird<MActor> {
256 return ActorModel.unscoped().findByPk(id) 258 return ActorModel.unscoped().findByPk(id)
257 } 259 }
258 260
259 static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) { 261 static loadFull (id: number): Bluebird<MActorFull> {
262 return ActorModel.scope(ScopeNames.FULL).findByPk(id)
263 }
264
265 static loadFromAccountByVideoId (videoId: number, transaction: Sequelize.Transaction): Bluebird<MActor> {
260 const query = { 266 const query = {
261 include: [ 267 include: [
262 { 268 {
@@ -300,7 +306,7 @@ export class ActorModel extends Model<ActorModel> {
300 .then(a => !!a) 306 .then(a => !!a)
301 } 307 }
302 308
303 static listByFollowersUrls (followersUrls: string[], transaction?: Sequelize.Transaction) { 309 static listByFollowersUrls (followersUrls: string[], transaction?: Sequelize.Transaction): Bluebird<MActorFull[]> {
304 const query = { 310 const query = {
305 where: { 311 where: {
306 followersUrl: { 312 followersUrl: {
@@ -313,7 +319,7 @@ export class ActorModel extends Model<ActorModel> {
313 return ActorModel.scope(ScopeNames.FULL).findAll(query) 319 return ActorModel.scope(ScopeNames.FULL).findAll(query)
314 } 320 }
315 321
316 static loadLocalByName (preferredUsername: string, transaction?: Sequelize.Transaction) { 322 static loadLocalByName (preferredUsername: string, transaction?: Sequelize.Transaction): Bluebird<MActorFull> {
317 const query = { 323 const query = {
318 where: { 324 where: {
319 preferredUsername, 325 preferredUsername,
@@ -325,7 +331,7 @@ export class ActorModel extends Model<ActorModel> {
325 return ActorModel.scope(ScopeNames.FULL).findOne(query) 331 return ActorModel.scope(ScopeNames.FULL).findOne(query)
326 } 332 }
327 333
328 static loadByNameAndHost (preferredUsername: string, host: string) { 334 static loadByNameAndHost (preferredUsername: string, host: string): Bluebird<MActorFull> {
329 const query = { 335 const query = {
330 where: { 336 where: {
331 preferredUsername 337 preferredUsername
@@ -344,7 +350,7 @@ export class ActorModel extends Model<ActorModel> {
344 return ActorModel.scope(ScopeNames.FULL).findOne(query) 350 return ActorModel.scope(ScopeNames.FULL).findOne(query)
345 } 351 }
346 352
347 static loadByUrl (url: string, transaction?: Sequelize.Transaction) { 353 static loadByUrl (url: string, transaction?: Sequelize.Transaction): Bluebird<MActorAccountChannelId> {
348 const query = { 354 const query = {
349 where: { 355 where: {
350 url 356 url
@@ -367,7 +373,7 @@ export class ActorModel extends Model<ActorModel> {
367 return ActorModel.unscoped().findOne(query) 373 return ActorModel.unscoped().findOne(query)
368 } 374 }
369 375
370 static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Sequelize.Transaction) { 376 static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Sequelize.Transaction): Bluebird<MActorFull> {
371 const query = { 377 const query = {
372 where: { 378 where: {
373 url 379 url