aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-09-28 10:07:05 +0200
committerChocobozzz <me@florianbigard.com>2018-09-28 10:07:05 +0200
commit161b061d4e51eb1e2b2b7e9482d5299489ef7c45 (patch)
tree5b9524625b7d8dbde765eaf9799d4f272829e449 /server/controllers
parentd0b52b5285d0797b30bca6510b7a8f840fab4697 (diff)
downloadPeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.gz
PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.tar.zst
PeerTube-161b061d4e51eb1e2b2b7e9482d5299489ef7c45.zip
Remove duplicated videos on unfollow/delete redundancy
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/server/follows.ts5
-rw-r--r--server/controllers/api/server/redundancy.ts6
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 {
17import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators' 17import { followersSortValidator, followingSortValidator, followValidator } from '../../../middlewares/validators'
18import { ActorFollowModel } from '../../../models/activitypub/actor-follow' 18import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
19import { JobQueue } from '../../../lib/job-queue' 19import { JobQueue } from '../../../lib/job-queue'
20import { removeRedundancyOf } from '../../../lib/redundancy'
20 21
21const serverFollowsRouter = express.Router() 22const serverFollowsRouter = express.Router()
22serverFollowsRouter.get('/following', 23serverFollowsRouter.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'
3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares' 3import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../../middlewares'
4import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy' 4import { updateServerRedundancyValidator } from '../../../middlewares/validators/redundancy'
5import { ServerModel } from '../../../models/server/server' 5import { ServerModel } from '../../../models/server/server'
6import { removeRedundancyOf } from '../../../lib/redundancy'
7import { logger } from '../../../helpers/logger'
6 8
7const serverRedundancyRouter = express.Router() 9const 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}