From 44b88f180bc9ec692885e7db08757a43b3e2df79 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 2 Aug 2019 09:46:48 +0200 Subject: Fix broken follow notification --- server/models/account/account.ts | 2 ++ server/models/activitypub/actor-follow.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'server/models') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 28014946f..4dc412301 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -30,6 +30,7 @@ import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' import { AccountBlocklistModel } from './account-blocklist' import { ServerBlocklistModel } from '../server/server-blocklist' +import { ActorFollowModel } from '../activitypub/actor-follow' export enum ScopeNames { SUMMARY = 'SUMMARY' @@ -220,6 +221,7 @@ export class AccountModel extends Model { instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel } + await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction) if (instance.isOwned()) { return sendDeleteActor(instance.Actor, options.transaction) } diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index b0461b981..3039b90c7 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -113,6 +113,24 @@ export class ActorFollowModel extends Model { ]) } + static removeFollowsOf (actorId: number, t?: Transaction) { + const query = { + where: { + [Op.or]: [ + { + actorId + }, + { + targetActorId: actorId + } + ] + }, + transaction: t + } + + return ActorFollowModel.destroy(query) + } + // Remove actor follows with a score of 0 (too many requests where they were unreachable) static async removeBadActorFollows () { const actorFollows = await ActorFollowModel.listBadActorFollows() -- cgit v1.2.3