import { Base36 } from "../../common/Base36.js"; /** * Email Commands is a message id of following format. * `{emoji|commands}-k{base36(emailID)}-{messageID}` * Command can only be from the following specified commands. */ export default class EmailCommands{ static commands = [ "approve", "publish", "unpublish", "delete", "edit", "decline", "subscribe", "unsubscribe" ]; static encode({ emoji, command = void 0, emailID = void 0, kEmailID36 = Base36.encode(emailID), messageID }) { if (command !== void 0) { if(!this.commands.includes(command)) { throw new Error("Invalid command " + command); } } else { // it has to be valid emoji command = emoji; } return `${command}-k${kEmailID36}-${messageID}`; } }