Fix broken follow notification
authorChocobozzz <me@florianbigard.com>
Fri, 2 Aug 2019 07:46:48 +0000 (09:46 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 2 Aug 2019 07:46:48 +0000 (09:46 +0200)
client/src/app/shared/users/user-notification.model.ts
server/models/account/account.ts
server/models/activitypub/actor-follow.ts

index 72fc3e7b4b968633f4028b11ac3bd693801a92b9..06eace71c94d7ba94dc3e3a3ff788edf91d6a7fc 100644 (file)
@@ -148,6 +148,7 @@ export class UserNotification implements UserNotificationServer {
           break
       }
     } catch (err) {
+      this.type = null
       console.error(err)
     }
   }
index 28014946f34b23df7dcee7694fe28a55feb0a525..4dc4123018a5fc2dc6713df5afe447fa2786b9ff 100644 (file)
@@ -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)
     }
index b0461b98110f1740eb85a2d11bae9aab4128c494..3039b90c7909ed628be431992501175ef0cb8753 100644 (file)
@@ -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()