aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-02 09:46:48 +0200
committerChocobozzz <me@florianbigard.com>2019-08-02 09:46:48 +0200
commit44b88f180bc9ec692885e7db08757a43b3e2df79 (patch)
tree906cdbf6d229a1e57e07d24568d4f0365587ee31
parent075942b212ff02aebf2f6668322407d40a0b91e5 (diff)
downloadPeerTube-44b88f180bc9ec692885e7db08757a43b3e2df79.tar.gz
PeerTube-44b88f180bc9ec692885e7db08757a43b3e2df79.tar.zst
PeerTube-44b88f180bc9ec692885e7db08757a43b3e2df79.zip
Fix broken follow notification
-rw-r--r--client/src/app/shared/users/user-notification.model.ts1
-rw-r--r--server/models/account/account.ts2
-rw-r--r--server/models/activitypub/actor-follow.ts18
3 files changed, 21 insertions, 0 deletions
diff --git a/client/src/app/shared/users/user-notification.model.ts b/client/src/app/shared/users/user-notification.model.ts
index 72fc3e7b4..06eace71c 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 {
148 break 148 break
149 } 149 }
150 } catch (err) { 150 } catch (err) {
151 this.type = null
151 console.error(err) 152 console.error(err)
152 } 153 }
153 } 154 }
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'
30import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize' 30import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
31import { AccountBlocklistModel } from './account-blocklist' 31import { AccountBlocklistModel } from './account-blocklist'
32import { ServerBlocklistModel } from '../server/server-blocklist' 32import { ServerBlocklistModel } from '../server/server-blocklist'
33import { ActorFollowModel } from '../activitypub/actor-follow'
33 34
34export enum ScopeNames { 35export enum ScopeNames {
35 SUMMARY = 'SUMMARY' 36 SUMMARY = 'SUMMARY'
@@ -220,6 +221,7 @@ export class AccountModel extends Model<AccountModel> {
220 instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel 221 instance.Actor = await instance.$get('Actor', { transaction: options.transaction }) as ActorModel
221 } 222 }
222 223
224 await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction)
223 if (instance.isOwned()) { 225 if (instance.isOwned()) {
224 return sendDeleteActor(instance.Actor, options.transaction) 226 return sendDeleteActor(instance.Actor, options.transaction)
225 } 227 }
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<ActorFollowModel> {
113 ]) 113 ])
114 } 114 }
115 115
116 static removeFollowsOf (actorId: number, t?: Transaction) {
117 const query = {
118 where: {
119 [Op.or]: [
120 {
121 actorId
122 },
123 {
124 targetActorId: actorId
125 }
126 ]
127 },
128 transaction: t
129 }
130
131 return ActorFollowModel.destroy(query)
132 }
133
116 // Remove actor follows with a score of 0 (too many requests where they were unreachable) 134 // Remove actor follows with a score of 0 (too many requests where they were unreachable)
117 static async removeBadActorFollows () { 135 static async removeBadActorFollows () {
118 const actorFollows = await ActorFollowModel.listBadActorFollows() 136 const actorFollows = await ActorFollowModel.listBadActorFollows()