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.
 
 
 
 
bandolier-website/commands/unsubkeys.js

15 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();
}