From 5e4d0d0516fa797cd5d52faf9451afe635cc135a Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Tue, 17 Oct 2023 01:03:01 +0300 Subject: [PATCH 01/10] feat: able to unset website field --- test/suites/update.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/suites/update.js b/test/suites/update.js index 56a71604..1a178801 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -373,6 +373,26 @@ describe('update suite', function suite() { }); }); + describe('update website', function updateWebsite() { + it('able to unset website passing an empty string', async function test() { + const { uploadId } = this.response; + meta.website = ''; + + await this.send({ + uploadId, + username, + meta, + }, 45000); + + const fileInfo = await getInfo.call(this, { + filename: uploadId, + username, + }); + + assert.strictEqual(fileInfo.file.website, '', 'Website should be empty'); + }); + }) + describe('playerSettings', function playerSettingsSuite() { it('able to change rotation mode', async function test() { const { uploadId } = this.response; From df5d0f4ff3442d87a845b175f3114437cd8ffe91 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Tue, 17 Oct 2023 04:34:51 +0300 Subject: [PATCH 02/10] feat: fully remove website field --- src/actions/update.js | 6 ++++++ test/suites/update.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/actions/update.js b/src/actions/update.js index 61856b3e..07ee4a48 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -39,6 +39,7 @@ const { FILES_NAME_FIELD, FILES_NAME_NORMALIZED_FIELD, FILES_CATEGORIES_FIELD, + FILES_WEBSITE_FIELD, } = require('../constant'); const { call } = Function.prototype; @@ -201,6 +202,11 @@ async function updateMeta(lock, ctx, params) { } } + if (meta[FILES_WEBSITE_FIELD] === '') { + delete meta[FILES_WEBSITE_FIELD]; + pipeline.hdel(key, FILES_WEBSITE_FIELD); + } + // make sure it's not an empty object if (hasProperties(meta)) { // to index using this property with redis-search diff --git a/test/suites/update.js b/test/suites/update.js index 1a178801..086a1096 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -389,7 +389,7 @@ describe('update suite', function suite() { username, }); - assert.strictEqual(fileInfo.file.website, '', 'Website should be empty'); + assert.strictEqual(fileInfo.file.website, undefined, 'Website should be unseted'); }); }) From 47f6b50c30fd664cb2761fbd81ac17286310fc80 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Tue, 17 Oct 2023 04:46:54 +0300 Subject: [PATCH 03/10] feat: remove website field if existing early --- schemas/common.json | 12 ++++++++++-- src/actions/update.js | 14 +++++++++----- test/suites/update.js | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index dc3b5508..0e13dbf1 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -818,8 +818,16 @@ "type": "boolean" }, "website": { - "type": "string", - "format": "http-url" + "oneOf": [ + { + "type": "string", + "format": "http-url" + }, + { + "type": "string", + "const": "" + } + ] }, "tags": { "$ref": "common#/definitions/tags" diff --git a/src/actions/update.js b/src/actions/update.js index 07ee4a48..23275264 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -152,6 +152,15 @@ async function updateMeta(lock, ctx, params) { delete meta[FILES_ALIAS_FIELD]; // <-- this field is empty at this point } + if (meta[FILES_WEBSITE_FIELD] === '') { + delete meta[FILES_WEBSITE_FIELD]; + + // remove field if existing early + if (data[FILES_WEBSITE_FIELD]) { + pipeline.hdel(key, FILES_WEBSITE_FIELD); + } + } + if (hasOwnProperty.call(meta, FILES_TAGS_FIELD) && data[FILES_TAGS_FIELD]) { // @todo migrate all tags in files data to lowercase and then remove this tag.toLowerCase() for (const tag of data[FILES_TAGS_FIELD].values()) { @@ -202,11 +211,6 @@ async function updateMeta(lock, ctx, params) { } } - if (meta[FILES_WEBSITE_FIELD] === '') { - delete meta[FILES_WEBSITE_FIELD]; - pipeline.hdel(key, FILES_WEBSITE_FIELD); - } - // make sure it's not an empty object if (hasProperties(meta)) { // to index using this property with redis-search diff --git a/test/suites/update.js b/test/suites/update.js index 086a1096..557b0448 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -391,7 +391,7 @@ describe('update suite', function suite() { assert.strictEqual(fileInfo.file.website, undefined, 'Website should be unseted'); }); - }) + }); describe('playerSettings', function playerSettingsSuite() { it('able to change rotation mode', async function test() { From 18c78776ca3d4c3b506d18f1658c7804bbc46f32 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 03:55:53 +0300 Subject: [PATCH 04/10] feat: add service $remove field for remove meta data --- schemas/common.json | 32 +++++++----------- src/actions/update.js | 26 +++++++++------ src/utils/check-data.js | 23 +++++++++++++ test/suites/update.js | 73 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 117 insertions(+), 37 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index 0e13dbf1..43292d31 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -818,16 +818,8 @@ "type": "boolean" }, "website": { - "oneOf": [ - { - "type": "string", - "format": "http-url" - }, - { - "type": "string", - "const": "" - } - ] + "type": "string", + "format": "http-url" }, "tags": { "$ref": "common#/definitions/tags" @@ -845,16 +837,8 @@ "$ref": "common#/definitions/fitToSquare" }, "backgroundImage": { - "oneOf": [ - { - "type": "string", - "format": "uri" - }, - { - "type": "string", - "const": "" - } - ] + "type": "string", + "format": "uri" }, "type": { "type": "string", @@ -1079,6 +1063,14 @@ }, "categories": { "$ref": "common#/definitions/categories" + }, + "$remove": { + "type": "array", + "items": { + "type": "string", + "minLength": 1 + }, + "minItems": 1 } } }, diff --git a/src/actions/update.js b/src/actions/update.js index 23275264..cf08fedb 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -1,6 +1,7 @@ const { ActionTransport } = require('@microfleet/plugin-router'); const Promise = require('bluebird'); const { HttpStatusError } = require('common-errors'); +const { unset } = require('lodash'); const handlePipeline = require('../utils/pipeline-error'); const fetchData = require('../utils/fetch-data'); const isProcessed = require('../utils/is-processed'); @@ -9,7 +10,7 @@ const hasAccess = require('../utils/has-access'); const isAliasTaken = require('../utils/is-alias-taken'); const stringify = require('../utils/stringify'); const isValidBackgroundOrigin = require('../utils/is-valid-background-origin'); -const { assertUpdatable } = require('../utils/check-data'); +const { assertUpdatable, assertRemovable } = require('../utils/check-data'); const { bustCache } = require('../utils/bust-cache'); const { updateReferences, verifyReferences, isReferenceChanged, getReferenceData } = require('../utils/reference'); const { normalizeForSearch } = require('../utils/normalize-name'); @@ -39,7 +40,6 @@ const { FILES_NAME_FIELD, FILES_NAME_NORMALIZED_FIELD, FILES_CATEGORIES_FIELD, - FILES_WEBSITE_FIELD, } = require('../constant'); const { call } = Function.prototype; @@ -82,6 +82,18 @@ function preProcessMetadata(data) { return data; } +/** + * Process metadata remove operation + * @param {Object} pipeline + * @param {Object} meta + */ +function handleRemoveFromMeta(pipeline, key, meta) { + const { $remove } = meta; + + pipeline.hdel(key, $remove); + unset(meta, $remove); +} + async function updateMeta(lock, ctx, params) { const { uploadId, username, directOnly, immutable, includeReferences } = params; const { redis } = ctx; @@ -101,6 +113,7 @@ async function updateMeta(lock, ctx, params) { .then(hasAccess(username)) .then(isAliasTaken(alias)) .then(assertUpdatable(meta)); + .then(assertRemovable(meta.$remove)); // ensure we still hold the lock await lock.extend(); @@ -152,14 +165,7 @@ async function updateMeta(lock, ctx, params) { delete meta[FILES_ALIAS_FIELD]; // <-- this field is empty at this point } - if (meta[FILES_WEBSITE_FIELD] === '') { - delete meta[FILES_WEBSITE_FIELD]; - - // remove field if existing early - if (data[FILES_WEBSITE_FIELD]) { - pipeline.hdel(key, FILES_WEBSITE_FIELD); - } - } + handleRemoveFromMeta(pipeline, key, meta.$remove); if (hasOwnProperty.call(meta, FILES_TAGS_FIELD) && data[FILES_TAGS_FIELD]) { // @todo migrate all tags in files data to lowercase and then remove this tag.toLowerCase() diff --git a/src/utils/check-data.js b/src/utils/check-data.js index 84de0ab9..067cd2ee 100644 --- a/src/utils/check-data.js +++ b/src/utils/check-data.js @@ -25,12 +25,22 @@ function assertImmutable(data) { const updatableFields = []; +const nonRemoveableFields = [ + ...updatableFields, +]; + function fieldUpdatePossible(metaToUpdate) { const nonUpdatableFields = Object.entries(metaToUpdate).filter(([key]) => !updatableFields.includes(key)); return nonUpdatableFields.length === 0; } +function fieldRemovePossible(metaToRemove = []) { + const nonRemovableFields = metaToRemove.filter((key) => !nonRemoveableFields.includes(key)); + + return nonRemovableFields.length === 0; +} + function assertClonable(metaToUpdate) { return function isClonePossibleCheck(data) { if (!isImmutable(data) || !fieldUpdatePossible(metaToUpdate)) { @@ -51,6 +61,18 @@ function assertUpdatable(metaToUpdate = {}, isRemoveOp = false) { }; } +function assertRemovable(metaToRemove = []) { + return function isRemovePossibleCheck(data) { + assertImmutable(data); + + if (!fieldRemovePossible(metaToRemove)) { + throw new HttpStatusError(400, 'meta fields can not be removed'); + } + + return data; + }; +} + function hasOrIsReference(data) { return data[FILES_HAS_REFERENCES_FIELD] === '1' || data[FILES_IS_REFERENCED_FIELD] === '1'; } @@ -72,4 +94,5 @@ module.exports = { assertUpdatable, assertClonable, assertNotReferenced, + assertRemovable, }; diff --git a/test/suites/update.js b/test/suites/update.js index 557b0448..2fdb69fb 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -371,12 +371,39 @@ describe('update suite', function suite() { assert.strictEqual(fileInfo.file.description, 'foo', 'Description should be trimmed'); }); + + it('remove description', async function test() { + const { uploadId } = this.response; + + await this.send({ + uploadId, + username, + meta: { + $remove: ['description'], + }, + }, 45000); + + const fileInfo = await getInfo.call(this, { + filename: uploadId, + username, + }); + + assert.strictEqual(fileInfo.file.description, undefined, 'Description should be not exists'); + }); }); describe('update website', function updateWebsite() { - it('able to unset website passing an empty string', async function test() { + it('failed to update wrong url', async function test() { + meta.website = 'wrong-url'; + + await assert.rejects(this.send({ uploadId: this.response.uploadId, username, meta }, 45000), { + statusCode: 400, + }); + }); + + it('able to update website any website', async function test() { const { uploadId } = this.response; - meta.website = ''; + meta.website = faker.image.imageUrl(); await this.send({ uploadId, @@ -389,7 +416,26 @@ describe('update suite', function suite() { username, }); - assert.strictEqual(fileInfo.file.website, undefined, 'Website should be unseted'); + assert.strictEqual(fileInfo.file.website, meta.website, 'Website should be equal with update data'); + }); + + it('able to unset website passing an empty string', async function test() { + const { uploadId } = this.response; + + await this.send({ + uploadId, + username, + meta: { + $remove: ['website'], + }, + }, 45000); + + const fileInfo = await getInfo.call(this, { + filename: uploadId, + username, + }); + + assert.strictEqual(fileInfo.file.website, undefined, 'Website must not exists'); }); }); @@ -550,10 +596,23 @@ describe('update suite', function suite() { }); }); - it('able to unset backgroundImage passing an empty string', function test() { + it('failed to unset backgroundImage passing an empty string', async function test() { meta.backgroundImage = ''; - return this - .send({ uploadId: this.response.uploadId, username, meta }, 45000) + + await assert.rejects(this.send({ uploadId: this.response.uploadId, username, meta }, 45000), { + statusCode: 400, + }); + }); + + it('remove backgroundImage', async function test() { + await this + .send({ + uploadId: this.response.uploadId, + username, + meta: { + $remove: ['backgroundImage'], + }, + }, 45000) .then(async (result) => { assert.equal(result, true); @@ -562,7 +621,7 @@ describe('update suite', function suite() { username, }); - assert.equal(verifyResult.file.backgroundImage, meta.backgroundImage); + assert.equal(verifyResult.file.backgroundImage, undefined, 'backgroundImage should be not exists'); }); }); From 1d208cf4a9a6565ae315e1945f1f9c8e2bb58781 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 04:01:28 +0300 Subject: [PATCH 05/10] fix: immutable condition --- src/utils/check-data.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/check-data.js b/src/utils/check-data.js index 067cd2ee..1e0764b5 100644 --- a/src/utils/check-data.js +++ b/src/utils/check-data.js @@ -63,7 +63,9 @@ function assertUpdatable(metaToUpdate = {}, isRemoveOp = false) { function assertRemovable(metaToRemove = []) { return function isRemovePossibleCheck(data) { - assertImmutable(data); + if (isImmutable(data)) { + throw new HttpStatusError(400, 'should not be immutable object'); + } if (!fieldRemovePossible(metaToRemove)) { throw new HttpStatusError(400, 'meta fields can not be removed'); From 70305c9438d6610f69dc8f41eace35ca00906633 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 04:11:10 +0300 Subject: [PATCH 06/10] feat: remove fields only if existing early --- src/actions/update.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/actions/update.js b/src/actions/update.js index cf08fedb..6328c940 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -1,7 +1,7 @@ const { ActionTransport } = require('@microfleet/plugin-router'); const Promise = require('bluebird'); const { HttpStatusError } = require('common-errors'); -const { unset } = require('lodash'); +const { unset, pick } = require('lodash'); const handlePipeline = require('../utils/pipeline-error'); const fetchData = require('../utils/fetch-data'); const isProcessed = require('../utils/is-processed'); @@ -87,11 +87,15 @@ function preProcessMetadata(data) { * @param {Object} pipeline * @param {Object} meta */ -function handleRemoveFromMeta(pipeline, key, meta) { +function handleRemoveFromMeta(pipeline, key, meta, data) { const { $remove } = meta; - pipeline.hdel(key, $remove); - unset(meta, $remove); + if ($remove && $remove.length > 0) { + unset(meta, $remove); + + const removeExists = pick(data, $remove); + pipeline.hdel(key, removeExists); + } } async function updateMeta(lock, ctx, params) { @@ -165,7 +169,7 @@ async function updateMeta(lock, ctx, params) { delete meta[FILES_ALIAS_FIELD]; // <-- this field is empty at this point } - handleRemoveFromMeta(pipeline, key, meta.$remove); + handleRemoveFromMeta(pipeline, key, meta, data); if (hasOwnProperty.call(meta, FILES_TAGS_FIELD) && data[FILES_TAGS_FIELD]) { // @todo migrate all tags in files data to lowercase and then remove this tag.toLowerCase() From 03bf1b27c91f204519814895a634473262a3d766 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 04:28:50 +0300 Subject: [PATCH 07/10] feat: remove useless check removable --- src/actions/update.js | 6 +++--- src/utils/check-data.js | 26 +------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/actions/update.js b/src/actions/update.js index 6328c940..6ec65273 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -10,7 +10,7 @@ const hasAccess = require('../utils/has-access'); const isAliasTaken = require('../utils/is-alias-taken'); const stringify = require('../utils/stringify'); const isValidBackgroundOrigin = require('../utils/is-valid-background-origin'); -const { assertUpdatable, assertRemovable } = require('../utils/check-data'); +const { assertUpdatable, assertReferenceOnAccessChange } = require('../utils/check-data'); const { bustCache } = require('../utils/bust-cache'); const { updateReferences, verifyReferences, isReferenceChanged, getReferenceData } = require('../utils/reference'); const { normalizeForSearch } = require('../utils/normalize-name'); @@ -116,8 +116,8 @@ async function updateMeta(lock, ctx, params) { .then(isUnlisted) .then(hasAccess(username)) .then(isAliasTaken(alias)) - .then(assertUpdatable(meta)); - .then(assertRemovable(meta.$remove)); + .then(assertUpdatable(meta)) + .then(assertReferenceOnAccessChange(meta, params)); // ensure we still hold the lock await lock.extend(); diff --git a/src/utils/check-data.js b/src/utils/check-data.js index 1e0764b5..2470f61e 100644 --- a/src/utils/check-data.js +++ b/src/utils/check-data.js @@ -25,22 +25,12 @@ function assertImmutable(data) { const updatableFields = []; -const nonRemoveableFields = [ - ...updatableFields, -]; - function fieldUpdatePossible(metaToUpdate) { const nonUpdatableFields = Object.entries(metaToUpdate).filter(([key]) => !updatableFields.includes(key)); return nonUpdatableFields.length === 0; } -function fieldRemovePossible(metaToRemove = []) { - const nonRemovableFields = metaToRemove.filter((key) => !nonRemoveableFields.includes(key)); - - return nonRemovableFields.length === 0; -} - function assertClonable(metaToUpdate) { return function isClonePossibleCheck(data) { if (!isImmutable(data) || !fieldUpdatePossible(metaToUpdate)) { @@ -61,20 +51,6 @@ function assertUpdatable(metaToUpdate = {}, isRemoveOp = false) { }; } -function assertRemovable(metaToRemove = []) { - return function isRemovePossibleCheck(data) { - if (isImmutable(data)) { - throw new HttpStatusError(400, 'should not be immutable object'); - } - - if (!fieldRemovePossible(metaToRemove)) { - throw new HttpStatusError(400, 'meta fields can not be removed'); - } - - return data; - }; -} - function hasOrIsReference(data) { return data[FILES_HAS_REFERENCES_FIELD] === '1' || data[FILES_IS_REFERENCED_FIELD] === '1'; } @@ -96,5 +72,5 @@ module.exports = { assertUpdatable, assertClonable, assertNotReferenced, - assertRemovable, + assertReferenceOnAccessChange, }; From 0968a391970de1f9263d861542e078eed48918db Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 05:14:32 +0300 Subject: [PATCH 08/10] fix: remove exists data & background image test --- src/actions/update.js | 13 +++++++++---- test/suites/update.js | 9 ++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/actions/update.js b/src/actions/update.js index 6ec65273..4a184aad 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -1,7 +1,7 @@ const { ActionTransport } = require('@microfleet/plugin-router'); const Promise = require('bluebird'); const { HttpStatusError } = require('common-errors'); -const { unset, pick } = require('lodash'); +const { pick, keys } = require('lodash'); const handlePipeline = require('../utils/pipeline-error'); const fetchData = require('../utils/fetch-data'); const isProcessed = require('../utils/is-processed'); @@ -91,10 +91,15 @@ function handleRemoveFromMeta(pipeline, key, meta, data) { const { $remove } = meta; if ($remove && $remove.length > 0) { - unset(meta, $remove); + const existsData = pick(data, $remove); + const esistsKeys = keys(existsData); - const removeExists = pick(data, $remove); - pipeline.hdel(key, removeExists); + pipeline.hdel(key, esistsKeys); + + $remove.forEach((removeKey) => { + delete meta[removeKey]; + }) + delete meta.$remove; } } diff --git a/test/suites/update.js b/test/suites/update.js index 2fdb69fb..c3432b35 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -379,6 +379,7 @@ describe('update suite', function suite() { uploadId, username, meta: { + description: 'some-new-description', $remove: ['description'], }, }, 45000); @@ -638,7 +639,13 @@ describe('update suite', function suite() { let modelWithReference; before('upload-file', async function uploadFile() { - meta.backgroundImage = ''; + await initAndUpload(backgroundData, false).call(this) + .then(downloadFile.bind(this)) + .then(({ urls }) => { + [meta.backgroundImage] = urls; + return null; + }); + const uploaded = await initAndUpload({ ...modelData, message: { From e3394c163cc0680ebcfe683cab3150e974da35b0 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 05:22:35 +0300 Subject: [PATCH 09/10] fix: shallow by lodash --- src/actions/update.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/actions/update.js b/src/actions/update.js index 4a184aad..60bdc8c2 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -1,7 +1,7 @@ const { ActionTransport } = require('@microfleet/plugin-router'); const Promise = require('bluebird'); const { HttpStatusError } = require('common-errors'); -const { pick, keys } = require('lodash'); +const ld = require('lodash'); const handlePipeline = require('../utils/pipeline-error'); const fetchData = require('../utils/fetch-data'); const isProcessed = require('../utils/is-processed'); @@ -91,14 +91,14 @@ function handleRemoveFromMeta(pipeline, key, meta, data) { const { $remove } = meta; if ($remove && $remove.length > 0) { - const existsData = pick(data, $remove); - const esistsKeys = keys(existsData); + const existsData = ld.pick(data, $remove); + const esistsKeys = ld.keys(existsData); pipeline.hdel(key, esistsKeys); $remove.forEach((removeKey) => { delete meta[removeKey]; - }) + }); delete meta.$remove; } } From 5c901209ad1b3c3240111a18badbd781754bb3f4 Mon Sep 17 00:00:00 2001 From: Victor Latyshev Date: Mon, 25 Dec 2023 05:39:40 +0300 Subject: [PATCH 10/10] fix: revert backgroundImage schema --- schemas/common.json | 12 ++++++++++-- src/actions/update.js | 5 ++--- src/utils/check-data.js | 1 - test/suites/update.js | 8 -------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/schemas/common.json b/schemas/common.json index 43292d31..98c8c09e 100644 --- a/schemas/common.json +++ b/schemas/common.json @@ -837,8 +837,16 @@ "$ref": "common#/definitions/fitToSquare" }, "backgroundImage": { - "type": "string", - "format": "uri" + "oneOf": [ + { + "type": "string", + "format": "uri" + }, + { + "type": "string", + "const": "" + } + ] }, "type": { "type": "string", diff --git a/src/actions/update.js b/src/actions/update.js index 60bdc8c2..8ae7d47e 100644 --- a/src/actions/update.js +++ b/src/actions/update.js @@ -10,7 +10,7 @@ const hasAccess = require('../utils/has-access'); const isAliasTaken = require('../utils/is-alias-taken'); const stringify = require('../utils/stringify'); const isValidBackgroundOrigin = require('../utils/is-valid-background-origin'); -const { assertUpdatable, assertReferenceOnAccessChange } = require('../utils/check-data'); +const { assertUpdatable } = require('../utils/check-data'); const { bustCache } = require('../utils/bust-cache'); const { updateReferences, verifyReferences, isReferenceChanged, getReferenceData } = require('../utils/reference'); const { normalizeForSearch } = require('../utils/normalize-name'); @@ -121,8 +121,7 @@ async function updateMeta(lock, ctx, params) { .then(isUnlisted) .then(hasAccess(username)) .then(isAliasTaken(alias)) - .then(assertUpdatable(meta)) - .then(assertReferenceOnAccessChange(meta, params)); + .then(assertUpdatable(meta)); // ensure we still hold the lock await lock.extend(); diff --git a/src/utils/check-data.js b/src/utils/check-data.js index 2470f61e..84de0ab9 100644 --- a/src/utils/check-data.js +++ b/src/utils/check-data.js @@ -72,5 +72,4 @@ module.exports = { assertUpdatable, assertClonable, assertNotReferenced, - assertReferenceOnAccessChange, }; diff --git a/test/suites/update.js b/test/suites/update.js index c3432b35..8e138576 100644 --- a/test/suites/update.js +++ b/test/suites/update.js @@ -597,14 +597,6 @@ describe('update suite', function suite() { }); }); - it('failed to unset backgroundImage passing an empty string', async function test() { - meta.backgroundImage = ''; - - await assert.rejects(this.send({ uploadId: this.response.uploadId, username, meta }, 45000), { - statusCode: 400, - }); - }); - it('remove backgroundImage', async function test() { await this .send({