diff --git a/src/service/public-key.js b/src/service/public-key.js index bb1115b..87abfc5 100644 --- a/src/service/public-key.js +++ b/src/service/public-key.js @@ -83,8 +83,7 @@ class PublicKey { } /** - * Delete all keys where no user id has been verified after x days or where the - * 'uploaded' attribute is yet not available (to support legacy key documents). + * Delete all keys where no user id has been verified after x days. * @yield {undefined} */ async _purgeOldUnverified() { @@ -94,10 +93,7 @@ class PublicKey { // remove unverified keys older than x days (or no 'uploaded' attribute) const query = { 'userIds.verified': {$ne: true}, - $or: [ - {uploaded: {$exists: false}}, - {uploaded: {$lt: xDaysAgo}} - ] + uploaded: {$lt: xDaysAgo} }; return this._mongo.remove(query, DB_TYPE); } diff --git a/test/integration/public-key-test.js b/test/integration/public-key-test.js index 3df4c07..176dc5a 100644 --- a/test/integration/public-key-test.js +++ b/test/integration/public-key-test.js @@ -144,16 +144,8 @@ describe('Public Key Integration Tests', function() { expect(r.deletedCount).to.equal(1); }); - it('should remove an unverified key with no uploaded attribute', async () => { - delete key.uploaded; - await publicKey._persisKey(key); - const r = await publicKey._purgeOldUnverified(); - expect(r.deletedCount).to.equal(1); - }); - it('should not remove a verified key with no uploaded attribute', async () => { key.userIds[0].verified = true; - delete key.uploaded; await publicKey._persisKey(key); const r = await publicKey._purgeOldUnverified(); expect(r.deletedCount).to.equal(0);