Basic video redundancy implementation
[oweals/peertube.git] / server / lib / redundancy.ts
diff --git a/server/lib/redundancy.ts b/server/lib/redundancy.ts
new file mode 100644 (file)
index 0000000..78221cc
--- /dev/null
@@ -0,0 +1,18 @@
+import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
+import { sendUndoCacheFile } from './activitypub/send'
+import { Transaction } from 'sequelize'
+import { getServerActor } from '../helpers/utils'
+
+async function removeVideoRedundancy (videoRedundancy: VideoRedundancyModel, t?: Transaction) {
+  const serverActor = await getServerActor()
+
+  await sendUndoCacheFile(serverActor, videoRedundancy, t)
+
+  await videoRedundancy.destroy({ transaction: t })
+}
+
+// ---------------------------------------------------------------------------
+
+export {
+  removeVideoRedundancy
+}