Remove legacy support since all documents now have an uploaded flag.

This commit is contained in:
Tankred Hase 2017-08-22 15:26:15 +08:00
parent 2af8310070
commit fe55578268
2 changed files with 2 additions and 14 deletions

View File

@ -83,8 +83,7 @@ class PublicKey {
} }
/** /**
* Delete all keys where no user id has been verified after x days or where the * Delete all keys where no user id has been verified after x days.
* 'uploaded' attribute is yet not available (to support legacy key documents).
* @yield {undefined} * @yield {undefined}
*/ */
async _purgeOldUnverified() { async _purgeOldUnverified() {
@ -94,10 +93,7 @@ class PublicKey {
// remove unverified keys older than x days (or no 'uploaded' attribute) // remove unverified keys older than x days (or no 'uploaded' attribute)
const query = { const query = {
'userIds.verified': {$ne: true}, 'userIds.verified': {$ne: true},
$or: [ uploaded: {$lt: xDaysAgo}
{uploaded: {$exists: false}},
{uploaded: {$lt: xDaysAgo}}
]
}; };
return this._mongo.remove(query, DB_TYPE); return this._mongo.remove(query, DB_TYPE);
} }

View File

@ -144,16 +144,8 @@ describe('Public Key Integration Tests', function() {
expect(r.deletedCount).to.equal(1); 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 () => { it('should not remove a verified key with no uploaded attribute', async () => {
key.userIds[0].verified = true; key.userIds[0].verified = true;
delete key.uploaded;
await publicKey._persisKey(key); await publicKey._persisKey(key);
const r = await publicKey._purgeOldUnverified(); const r = await publicKey._purgeOldUnverified();
expect(r.deletedCount).to.equal(0); expect(r.deletedCount).to.equal(0);