diff options
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 3e85cc329..529cb35cc 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -15,14 +15,15 @@ import { | |||
15 | Max, | 15 | Max, |
16 | Model, | 16 | Model, |
17 | Table, | 17 | Table, |
18 | UpdatedAt | 18 | UpdatedAt, |
19 | Sequelize | ||
19 | } from 'sequelize-typescript' | 20 | } from 'sequelize-typescript' |
20 | import { FollowState } from '../../../shared/models/actors' | 21 | import { FollowState } from '../../../shared/models/actors' |
21 | import { ActorFollow } from '../../../shared/models/actors/follow.model' | 22 | import { ActorFollow } from '../../../shared/models/actors/follow.model' |
22 | import { logger } from '../../helpers/logger' | 23 | import { logger } from '../../helpers/logger' |
23 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' | 24 | import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' |
24 | import { ServerModel } from '../server/server' | 25 | import { ServerModel } from '../server/server' |
25 | import { createSafeIn, getFollowsSort, getSort } from '../utils' | 26 | import { createSafeIn, getFollowsSort, getSort, searchAttribute } from '../utils' |
26 | import { ActorModel, unusedActorAttributesForAPI } from './actor' | 27 | import { ActorModel, unusedActorAttributesForAPI } from './actor' |
27 | import { VideoChannelModel } from '../video/video-channel' | 28 | import { VideoChannelModel } from '../video/video-channel' |
28 | import { AccountModel } from '../account/account' | 29 | import { AccountModel } from '../account/account' |
@@ -440,16 +441,34 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
440 | }) | 441 | }) |
441 | } | 442 | } |
442 | 443 | ||
443 | static listSubscriptionsForApi (actorId: number, start: number, count: number, sort: string) { | 444 | static listSubscriptionsForApi (options: { |
445 | actorId: number | ||
446 | start: number | ||
447 | count: number | ||
448 | sort: string | ||
449 | search?: string | ||
450 | }) { | ||
451 | const { actorId, start, count, sort } = options | ||
452 | const where = { | ||
453 | actorId: actorId | ||
454 | } | ||
455 | |||
456 | if (options.search) { | ||
457 | Object.assign(where, { | ||
458 | [Op.or]: [ | ||
459 | searchAttribute(options.search, '$ActorFollowing.preferredUsername$'), | ||
460 | searchAttribute(options.search, '$ActorFollowing.VideoChannel.name$') | ||
461 | ] | ||
462 | }) | ||
463 | } | ||
464 | |||
444 | const query = { | 465 | const query = { |
445 | attributes: [], | 466 | attributes: [], |
446 | distinct: true, | 467 | distinct: true, |
447 | offset: start, | 468 | offset: start, |
448 | limit: count, | 469 | limit: count, |
449 | order: getSort(sort), | 470 | order: getSort(sort), |
450 | where: { | 471 | where, |
451 | actorId: actorId | ||
452 | }, | ||
453 | include: [ | 472 | include: [ |
454 | { | 473 | { |
455 | attributes: [ 'id' ], | 474 | attributes: [ 'id' ], |