Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Force video updatedAt update on update

Chocobozzz5cf027bdc46f
diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts
index a98a3e67c1..07f9690ec0 100644
--- a/server/controllers/api/videos/update.ts
+++ b/server/controllers/api/videos/update.ts
@@ -99,6 +99,11 @@ export async function updateVideo (req: express.Request, res: express.Response)
isNewVideo = await updateVideoPrivacy({ videoInstance, videoInfoToUpdate, hadPrivacyForFederation, transaction: t })
}
+ // Force updatedAt attribute change
+ if (!videoInstance.changed()) {
+ await videoInstance.setAsRefreshed()
+ }
+
const videoInstanceUpdated = await videoInstance.save(sequelizeOptions) as MVideoFullLight
// Thumbnail & preview updates?
diff --git a/server/tests/api/videos/multiple-servers.ts b/server/tests/api/videos/multiple-servers.ts
index 470bee45b6..c6c2790649 100644
--- a/server/tests/api/videos/multiple-servers.ts
+++ b/server/tests/api/videos/multiple-servers.ts
@@ -667,6 +667,26 @@ describe('Test multiple servers', function () {
}
})
+ it('Should only update thumbnail and update updatedAt attribute', async function () {
+ this.timeout(10000)
+
+ const attributes = {
+ thumbnailfile: 'thumbnail.jpg'
+ }
+
+ updatedAtMin = new Date()
+ await servers[2].videos.update({ id: toRemove[0].id, attributes })
+
+ await waitJobs(servers)
+
+ for (const server of servers) {
+ const { data } = await server.videos.list()
+
+ const videoUpdated = data.find(video => video.name === 'my super video updated')
+ expect(new Date(videoUpdated.updatedAt)).to.be.greaterThan(updatedAtMin)
+ }
+ })
+
it('Should remove the videos 3 and 3-2 by asking server 3 and correctly delete files', async function () {
this.timeout(30000)
diff --git a/shared/extra-utils/requests/requests.ts b/shared/extra-utils/requests/requests.ts
index 501e0b374b..b6b9024ed1 100644
--- a/shared/extra-utils/requests/requests.ts
+++ b/shared/extra-utils/requests/requests.ts
@@ -85,6 +85,7 @@ function makeUploadRequest (options: CommonRequestParams & {
Object.keys(options.attaches || {}).forEach(attach => {
const value = options.attaches[attach]
+ if (!value) return
if (Array.isArray(value)) {
req.attach(attach, buildAbsoluteFixturePath(value[0]), value[1])