import queues from "../lib/queues.js";
import { API } from "../lib/api.js";
import logging from "../lib/logging.js";

const log = logging.create(import.meta.url);

export const get = async (req, res) => {
  const api = new API(req, res);
  api.reply(200, { discord_sent: api.req.user.discord_sent });
}

get.authenticated = true;

export const post = async (req, res) => {
  const api = new API(req, res);

  log.debug(`Discord request received from user ${ req.user.id }`);
  const discord_q = queues.create("discord/send_invite");

  discord_q.add({user_id: api.req.user.id});

  api.reply(200, { message: "OK" });
}

post.authenticated = true;
