diff options
Diffstat (limited to 'server/controllers/api/server/follows.ts')
-rw-r--r-- | server/controllers/api/server/follows.ts | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index 391f8bdca..535d530f7 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -148,10 +148,17 @@ async function removeFollow (req: express.Request, res: express.Response, next: | |||
148 | const follow: AccountFollowInstance = res.locals.follow | 148 | const follow: AccountFollowInstance = res.locals.follow |
149 | 149 | ||
150 | await db.sequelize.transaction(async t => { | 150 | await db.sequelize.transaction(async t => { |
151 | await sendUndoFollow(follow, t) | 151 | if (follow.state === 'accepted') await sendUndoFollow(follow, t) |
152 | |||
152 | await follow.destroy({ transaction: t }) | 153 | await follow.destroy({ transaction: t }) |
153 | }) | 154 | }) |
154 | 155 | ||
156 | // Destroy the account that will destroy video channels, videos and video files too | ||
157 | // This could be long so don't wait this task | ||
158 | const following = follow.AccountFollowing | ||
159 | following.destroy() | ||
160 | .catch(err => logger.error('Cannot destroy account that we do not follow anymore %s.', following.url, err)) | ||
161 | |||
155 | return res.status(204).end() | 162 | return res.status(204).end() |
156 | } | 163 | } |
157 | 164 | ||