This is a parody of leetcode.com for designers. It's being developed live on Twitch.tv/zedashaw to demonstrate how to make a parody of a website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pixelperfectionist/commands/unsubkeys.js

16 lines
547 B

import crypto from "crypto";
import { User, UNSUB_CODE_SIZE } from "../lib/models.js";
import { knex } from "../lib/ormish.js";
export const description = "Updates users with no unsubkey, which can happen sometimes when manually adding people.";
export const main = async () => {
for(let u of await User.all({unsubscribe: false, unsubkey: ""})) {
const key = crypto.randomBytes(UNSUB_CODE_SIZE).toString("hex");
console.log(u.id, key, "length", key.length);
await User.update({id: u.id}, {unsubkey: key});
}
knex.destroy();
}