2018-02-27 13:46:56 +01:00
|
|
|
import { isTestInstance } from '../../helpers/core-utils'
|
2018-01-11 09:35:50 +01:00
|
|
|
import { logger } from '../../helpers/logger'
|
|
|
|
import { ActorFollowModel } from '../../models/activitypub/actor-follow'
|
|
|
|
import { AbstractScheduler } from './abstract-scheduler'
|
|
|
|
|
|
|
|
export class BadActorFollowScheduler extends AbstractScheduler {
|
|
|
|
|
|
|
|
private static instance: AbstractScheduler
|
|
|
|
|
|
|
|
private constructor () {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
|
|
|
async execute () {
|
2018-02-27 13:46:56 +01:00
|
|
|
if (!isTestInstance()) logger.info('Removing bad actor follows (scheduler).')
|
2018-02-27 11:08:59 +01:00
|
|
|
|
2018-01-11 09:35:50 +01:00
|
|
|
try {
|
|
|
|
await ActorFollowModel.removeBadActorFollows()
|
|
|
|
} catch (err) {
|
|
|
|
logger.error('Error in bad actor follows scheduler.', err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static get Instance () {
|
|
|
|
return this.instance || (this.instance = new this())
|
|
|
|
}
|
|
|
|
}
|