aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/activitypub/actor-follow.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/activitypub/actor-follow.ts')
-rw-r--r--server/models/activitypub/actor-follow.ts25
1 files changed, 18 insertions, 7 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 51b09e09b..8ef770cd4 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -27,7 +27,13 @@ import { createSafeIn, getSort } from '../utils'
27import { ActorModel, unusedActorAttributesForAPI } from './actor' 27import { ActorModel, unusedActorAttributesForAPI } from './actor'
28import { VideoChannelModel } from '../video/video-channel' 28import { VideoChannelModel } from '../video/video-channel'
29import { AccountModel } from '../account/account' 29import { AccountModel } from '../account/account'
30import { IncludeOptions, Op, Transaction, QueryTypes } from 'sequelize' 30import { IncludeOptions, Op, QueryTypes, Transaction } from 'sequelize'
31import {
32 MActorFollowActorsDefault,
33 MActorFollowActorsDefaultSubscription,
34 MActorFollowFollowingHost,
35 MActorFollowSubscriptions
36} from '@server/typings/models'
31 37
32@Table({ 38@Table({
33 tableName: 'actorFollow', 39 tableName: 'actorFollow',
@@ -143,7 +149,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
143 if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) 149 if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved)
144 } 150 }
145 151
146 static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction) { 152 static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction): Bluebird<MActorFollowActorsDefault> {
147 const query = { 153 const query = {
148 where: { 154 where: {
149 actorId, 155 actorId,
@@ -167,7 +173,12 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
167 return ActorFollowModel.findOne(query) 173 return ActorFollowModel.findOne(query)
168 } 174 }
169 175
170 static loadByActorAndTargetNameAndHostForAPI (actorId: number, targetName: string, targetHost: string, t?: Transaction) { 176 static loadByActorAndTargetNameAndHostForAPI (
177 actorId: number,
178 targetName: string,
179 targetHost: string,
180 t?: Transaction
181 ): Bluebird<MActorFollowActorsDefaultSubscription> {
171 const actorFollowingPartInclude: IncludeOptions = { 182 const actorFollowingPartInclude: IncludeOptions = {
172 model: ActorModel, 183 model: ActorModel,
173 required: true, 184 required: true,
@@ -220,7 +231,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
220 }) 231 })
221 } 232 }
222 233
223 static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]) { 234 static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]): Bluebird<MActorFollowFollowingHost[]> {
224 const whereTab = targets 235 const whereTab = targets
225 .map(t => { 236 .map(t => {
226 if (t.host) { 237 if (t.host) {
@@ -314,7 +325,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
314 ] 325 ]
315 } 326 }
316 327
317 return ActorFollowModel.findAndCountAll(query) 328 return ActorFollowModel.findAndCountAll<MActorFollowActorsDefault>(query)
318 .then(({ rows, count }) => { 329 .then(({ rows, count }) => {
319 return { 330 return {
320 data: rows, 331 data: rows,
@@ -357,7 +368,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
357 ] 368 ]
358 } 369 }
359 370
360 return ActorFollowModel.findAndCountAll(query) 371 return ActorFollowModel.findAndCountAll<MActorFollowActorsDefault>(query)
361 .then(({ rows, count }) => { 372 .then(({ rows, count }) => {
362 return { 373 return {
363 data: rows, 374 data: rows,
@@ -414,7 +425,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
414 ] 425 ]
415 } 426 }
416 427
417 return ActorFollowModel.findAndCountAll(query) 428 return ActorFollowModel.findAndCountAll<MActorFollowSubscriptions>(query)
418 .then(({ rows, count }) => { 429 .then(({ rows, count }) => {
419 return { 430 return {
420 data: rows.map(r => r.ActorFollowing.VideoChannel), 431 data: rows.map(r => r.ActorFollowing.VideoChannel),