diff options
author | Chocobozzz <me@florianbigard.com> | 2018-09-28 10:07:05 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-09-28 10:07:05 +0200 |
commit | 161b061d4e51eb1e2b2b7e9482d5299489ef7c45 (patch) | |
tree | 5b9524625b7d8dbde765eaf9799d4f272829e449 /server/controllers/api | |
parent | d0b52b5285d0797b30bca6510b7a8f840fab4697 (diff) | |
download | PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.gz PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.zst PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.zip |
Remove duplicated videos on unfollow/delete redundancy
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/server/follows.ts | 5 | ||||
-rw-r--r-- | server/controllers/api/server/redundancy.ts | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/server/controllers/api/server/follows.ts b/server/controllers/api/server/follows.ts index a4eae6b45..d62400e42 100644 --- a/server/controllers/api/server/follows.ts +++ b/server/controllers/api/server/follows.ts | |||
@@ -17,6 +17,7 @@ import { | |||
17 | import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' | 17 | import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' |
18 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | 18 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' |
19 | import { JobQueue } from '../../../lib/job-queue' | 19 | import { JobQueue } from '../../../lib/job-queue' |
20 | import { removeRedundancyOf } from '../../../lib/redundancy' | ||
20 | 21 | ||
21 | const serverFollowsRouter = express.Router() | 22 | const serverFollowsRouter = express.Router() |
22 | serverFollowsRouter.get('/following', | 23 | serverFollowsRouter.get('/following', |
@@ -101,6 +102,10 @@ async function removeFollow (req: express.Request, res: express.Response, next: | |||
101 | server.redundancyAllowed = false | 102 | server.redundancyAllowed = false |
102 | await server.save({ transaction: t }) | 103 | await server.save({ transaction: t }) |
103 | 104 | ||
105 | // Async, could be long | ||
106 | removeRedundancyOf(server.id) | ||
107 | .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, err)) | ||
108 | |||
104 | await follow.destroy({ transaction: t }) | 109 | await follow.destroy({ transaction: t }) |
105 | }) | 110 | }) |
106 | 111 | ||
diff --git a/server/controllers/api/server/redundancy.ts b/server/controllers/api/server/redundancy.ts index 4216b9e35..4140c4991 100644 --- a/server/controllers/api/server/redundancy.ts +++ b/server/controllers/api/server/redundancy.ts | |||
@@ -3,6 +3,8 @@ import { UserRight } from '../../../../shared/models/users' | |||
3 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' | 3 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' |
4 | import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy' | 4 | import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy' |
5 | import { ServerModel } from '../../../models/server/server' | 5 | import { ServerModel } from '../../../models/server/server' |
6 | import { removeRedundancyOf } from '../../../lib/redundancy' | ||
7 | import { logger } from '../../../helpers/logger' | ||
6 | 8 | ||
7 | const serverRedundancyRouter = express.Router() | 9 | const serverRedundancyRouter = express.Router() |
8 | 10 | ||
@@ -28,5 +30,9 @@ async function updateRedundancy (req: express.Request, res: express.Response, ne | |||
28 | 30 | ||
29 | await server.save() | 31 | await server.save() |
30 | 32 | ||
33 | // Async, could be long | ||
34 | removeRedundancyOf(server.id) | ||
35 | .catch(err => logger.error('Cannot remove redundancy of %s.', server.host, err)) | ||
36 | |||
31 | return res.sendStatus(204) | 37 | return res.sendStatus(204) |
32 | } | 38 | } |