]>
Commit | Line | Data |
---|---|---|
c48e82b5 C |
1 | import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' |
2 | import { sendUndoCacheFile } from './activitypub/send' | |
3 | import { Transaction } from 'sequelize' | |
4 | import { getServerActor } from '../helpers/utils' | |
5 | ||
6 | async function removeVideoRedundancy (videoRedundancy: VideoRedundancyModel, t?: Transaction) { | |
7 | const serverActor = await getServerActor() | |
8 | ||
e5565833 C |
9 | // Local cache, send undo to remote instances |
10 | if (videoRedundancy.actorId === serverActor.id) await sendUndoCacheFile(serverActor, videoRedundancy, t) | |
c48e82b5 C |
11 | |
12 | await videoRedundancy.destroy({ transaction: t }) | |
13 | } | |
14 | ||
161b061d C |
15 | async function removeRedundancyOf (serverId: number) { |
16 | const videosRedundancy = await VideoRedundancyModel.listLocalOfServer(serverId) | |
17 | ||
18 | for (const redundancy of videosRedundancy) { | |
19 | await removeVideoRedundancy(redundancy) | |
20 | } | |
21 | } | |
22 | ||
c48e82b5 C |
23 | // --------------------------------------------------------------------------- |
24 | ||
25 | export { | |
161b061d | 26 | removeRedundancyOf, |
c48e82b5 C |
27 | removeVideoRedundancy |
28 | } |