mirror of https://github.com/Chocobozzz/PeerTube
Fix process follow
parent
bfcaa9c194
commit
50cc1ee48a
|
@ -40,7 +40,7 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ
|
||||||
if (!targetActor) throw new Error('Unknown actor')
|
if (!targetActor) throw new Error('Unknown actor')
|
||||||
if (targetActor.isOwned() === false) throw new Error('This is not a local actor.')
|
if (targetActor.isOwned() === false) throw new Error('This is not a local actor.')
|
||||||
|
|
||||||
if (rejectIfInstanceFollowDisabled(byActor, activityId, targetActor)) return { actorFollow: undefined }
|
if (await rejectIfInstanceFollowDisabled(byActor, activityId, targetActor)) return { actorFollow: undefined }
|
||||||
if (await rejectIfMuted(byActor, activityId, targetActor)) return { actorFollow: undefined }
|
if (await rejectIfMuted(byActor, activityId, targetActor)) return { actorFollow: undefined }
|
||||||
|
|
||||||
const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({
|
const [ actorFollow, created ] = await ActorFollowModel.findOrCreateCustom({
|
||||||
|
@ -79,7 +79,7 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ
|
||||||
const follower = await ActorModel.loadFull(byActor.id)
|
const follower = await ActorModel.loadFull(byActor.id)
|
||||||
const actorFollowFull = Object.assign(actorFollow, { ActorFollowing: targetActor, ActorFollower: follower })
|
const actorFollowFull = Object.assign(actorFollow, { ActorFollowing: targetActor, ActorFollower: follower })
|
||||||
|
|
||||||
if (isFollowingInstance(targetActor)) {
|
if (await isFollowingInstance(targetActor)) {
|
||||||
Notifier.Instance.notifyOfNewInstanceFollow(actorFollowFull)
|
Notifier.Instance.notifyOfNewInstanceFollow(actorFollowFull)
|
||||||
} else {
|
} else {
|
||||||
Notifier.Instance.notifyOfNewUserFollow(actorFollowFull)
|
Notifier.Instance.notifyOfNewUserFollow(actorFollowFull)
|
||||||
|
@ -89,8 +89,8 @@ async function processFollow (byActor: MActorSignature, activityId: string, targ
|
||||||
logger.info('Actor %s is followed by actor %s.', targetActorURL, byActor.url)
|
logger.info('Actor %s is followed by actor %s.', targetActorURL, byActor.url)
|
||||||
}
|
}
|
||||||
|
|
||||||
function rejectIfInstanceFollowDisabled (byActor: MActorSignature, activityId: string, targetActor: MActorFull) {
|
async function rejectIfInstanceFollowDisabled (byActor: MActorSignature, activityId: string, targetActor: MActorFull) {
|
||||||
if (isFollowingInstance(targetActor) && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) {
|
if (await isFollowingInstance(targetActor) && CONFIG.FOLLOWERS.INSTANCE.ENABLED === false) {
|
||||||
logger.info('Rejecting %s because instance followers are disabled.', targetActor.url)
|
logger.info('Rejecting %s because instance followers are disabled.', targetActor.url)
|
||||||
|
|
||||||
sendReject(activityId, byActor, targetActor)
|
sendReject(activityId, byActor, targetActor)
|
||||||
|
@ -133,7 +133,7 @@ async function acceptIfNeeded (actorFollow: MActorFollow, targetActor: MActorFul
|
||||||
// Set the follow as accepted if the remote actor follows a channel or account
|
// Set the follow as accepted if the remote actor follows a channel or account
|
||||||
// Or if the instance automatically accepts followers
|
// Or if the instance automatically accepts followers
|
||||||
if (actorFollow.state === 'accepted') return
|
if (actorFollow.state === 'accepted') return
|
||||||
if (!isFollowingInstance(targetActor)) return
|
if (!await isFollowingInstance(targetActor)) return
|
||||||
if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true) return
|
if (CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === true) return
|
||||||
|
|
||||||
actorFollow.state = 'accepted'
|
actorFollow.state = 'accepted'
|
||||||
|
|
|
@ -23,7 +23,7 @@ async function checkNotifications (server: PeerTubeServer, token: string, expect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Test blocklist', function () {
|
describe('Test blocklist notifications', function () {
|
||||||
let servers: PeerTubeServer[]
|
let servers: PeerTubeServer[]
|
||||||
let videoUUID: string
|
let videoUUID: string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue