Skip to content

Commit 41a347c

Browse files
committed
Merge branch 'remove_unconfimed_email_user_accounts' into architecture-refactor
Merge architecture <- remove_unconfirmed_email_user_accounts With this merge, I can deal with potential merge conflicts locally, and avoid having them on the upstream repo. Hope that is clear. Massiles.
2 parents 883fbc9 + 4790271 commit 41a347c

File tree

4 files changed

+154
-22
lines changed

4 files changed

+154
-22
lines changed

package-lock.json

+137-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"express": "^4.17.1",
2929
"jsdoc": "^3.6.10",
3030
"jsonwebtoken": "^8.5.1",
31+
"node-schedule": "^2.1.0",
3132
"nodemailer": "^6.7.2",
3233
"pg": "^8.7.1",
3334
"sequelize": "^6.3.5",

src/background_jobs/unconfirmed_emails.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,23 @@ module.exports.remove_unconfirmed_email_users = async () => {
2424
{
2525
confirmed_email: false,
2626
},
27-
attributes: ['id'],
27+
attributes: ['id', 'createdAt'],
2828
raw: true,
2929
},
3030
)
31-
31+
3232
if (found_users != undefined && found_users.length) {
3333

34-
// at this stage found_users will look like [{id:1}, {id:2}]
35-
// we want to turn it into an ids array which will look like [1,2]
34+
// at this stage found_users will look like [ { id: 1, createdAt: '2022-03-26 22:23:43.002 +00:00' } ]
35+
// we want to turn it into an ids array which will look like [1], if the createdAt refers to a date before a month ago
3636
const ids = [];
3737
found_users.forEach((element) => {
38-
ids.push(element.id)
38+
if (Date.parse(element.createdAt) < (Date.now() - 30 * 24 * 60 * 60 * 1000)) {
39+
ids.push(element.id);
40+
}
3941
})
4042

4143

42-
4344
//remove all the data that belongs to a user with an unconfirmed email address
4445
await Promise.allSettled([
4546
Events.findAll(

0 commit comments

Comments
 (0)