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
* '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);
}

View File

@ -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);