return ActorFollowModel.findAll(query)
}
- static listFollowingForApi (id: number, start: number, count: number, sort: string) {
+ static listFollowingForApi (id: number, start: number, count: number, sort: string, search?: string) {
const query = {
distinct: true,
offset: start,
model: ActorModel,
as: 'ActorFollowing',
required: true,
- include: [ ServerModel ]
+ include: [
+ {
+ model: ServerModel,
+ required: true,
+ where: search ? {
+ host: {
+ [Sequelize.Op.iLike]: '%' + search + '%'
+ }
+ } : undefined
+ }
+ ]
}
]
}
})
}
+ static listFollowersForApi (id: number, start: number, count: number, sort: string, search?: string) {
+ const query = {
+ distinct: true,
+ offset: start,
+ limit: count,
+ order: getSort(sort),
+ include: [
+ {
+ model: ActorModel,
+ required: true,
+ as: 'ActorFollower',
+ include: [
+ {
+ model: ServerModel,
+ required: true,
+ where: search ? {
+ host: {
+ [ Sequelize.Op.iLike ]: '%' + search + '%'
+ }
+ } : undefined
+ }
+ ]
+ },
+ {
+ model: ActorModel,
+ as: 'ActorFollowing',
+ required: true,
+ where: {
+ id
+ }
+ }
+ ]
+ }
+
+ return ActorFollowModel.findAndCountAll(query)
+ .then(({ rows, count }) => {
+ return {
+ data: rows,
+ total: count
+ }
+ })
+ }
+
static listSubscriptionsForApi (id: number, start: number, count: number, sort: string) {
const query = {
attributes: [],
})
}
- static listFollowersForApi (id: number, start: number, count: number, sort: string) {
- const query = {
- distinct: true,
- offset: start,
- limit: count,
- order: getSort(sort),
- include: [
- {
- model: ActorModel,
- required: true,
- as: 'ActorFollower',
- include: [ ServerModel ]
- },
- {
- model: ActorModel,
- as: 'ActorFollowing',
- required: true,
- where: {
- id
- }
- }
- ]
- }
-
- return ActorFollowModel.findAndCountAll(query)
- .then(({ rows, count }) => {
- return {
- data: rows,
- total: count
- }
- })
- }
-
static listAcceptedFollowerUrlsForApi (actorIds: number[], t: Sequelize.Transaction, start?: number, count?: number) {
return ActorFollowModel.createListAcceptedFollowForApiQuery('followers', actorIds, t, start, count)
}