Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix broken follow notification

Chocobozzz44b88f180bc9
diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts
index 72fc3e7b4b..06eace71c9 100644
--- a/client/src/app/shared/users/user-notification.model.ts
+++ b/client/src/app/shared/users/user-notification.model.ts
@@ -148,6 +148,7 @@ export class UserNotification implements UserNotificationServer {
break
}
} catch (err) {
+ this.type = null
console.error(err)
}
}
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 28014946f3..4dc4123018 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<AccountModel> {
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 b0461b9811..3039b90c79 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -113,6 +113,24 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
])
}
+ 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()