import * as Bluebird from 'bluebird'
-import { values, difference } from 'lodash'
+import { difference, values } from 'lodash'
import {
AfterCreate,
AfterDestroy,
import { getServerActor } from '../../helpers/utils'
import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants'
import { ServerModel } from '../server/server'
-import { createSafeIn, getSort, getFollowsSort } from '../utils'
+import { createSafeIn, getFollowsSort, getSort } from '../utils'
import { ActorModel, unusedActorAttributesForAPI } from './actor'
import { VideoChannelModel } from '../video/video-channel'
import { AccountModel } from '../account/account'
MActorFollowSubscriptions
} from '@server/typings/models'
import { ActivityPubActorType } from '@shared/models'
-import { afterCommitIfTransaction } from '@server/helpers/database-utils'
@Table({
tableName: 'actorFollow',
return ActorFollowModel.findOne(query)
.then(result => {
- if (result && result.ActorFollowing.VideoChannel) {
+ if (result?.ActorFollowing.VideoChannel) {
result.ActorFollowing.VideoChannel.Actor = result.ActorFollowing
}
.map(t => {
if (t.host) {
return {
- [ Op.and ]: [
+ [Op.and]: [
{
- '$preferredUsername$': t.name
+ $preferredUsername$: t.name
},
{
- '$host$': t.host
+ $host$: t.host
}
]
}
}
return {
- [ Op.and ]: [
+ [Op.and]: [
{
- '$preferredUsername$': t.name
+ $preferredUsername$: t.name
},
{
- '$serverId$': null
+ $serverId$: null
}
]
}
const query = {
attributes: [],
where: {
- [ Op.and ]: [
+ [Op.and]: [
{
- [ Op.or ]: whereTab
+ [Op.or]: whereTab
},
{
actorId
}
static listFollowingForApi (options: {
- id: number,
- start: number,
- count: number,
- sort: string,
- state?: FollowState,
- actorType?: ActivityPubActorType,
+ id: number
+ start: number
+ count: number
+ sort: string
+ state?: FollowState
+ actorType?: ActivityPubActorType
search?: string
}) {
const { id, start, count, sort, search, state, actorType } = options
if (search) {
Object.assign(followingServerWhere, {
host: {
- [ Op.iLike ]: '%' + search + '%'
+ [Op.iLike]: '%' + search + '%'
}
})
}
}
static listFollowersForApi (options: {
- actorId: number,
- start: number,
- count: number,
- sort: string,
- state?: FollowState,
- actorType?: ActivityPubActorType,
+ actorId: number
+ start: number
+ count: number
+ sort: string
+ state?: FollowState
+ actorType?: ActivityPubActorType
search?: string
}) {
const { actorId, start, count, sort, search, state, actorType } = options
if (search) {
Object.assign(followerServerWhere, {
host: {
- [ Op.iLike ]: '%' + search + '%'
+ [Op.iLike]: '%' + search + '%'
}
})
}
const tasks: Bluebird<any>[] = []
- for (let selection of selections) {
+ for (const selection of selections) {
let query = 'SELECT ' + selection + ' FROM "actor" ' +
'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +