import { deleteOldMailBlocked, getMailBlockedPaginated } from "../../db/mail";

/**
 * GET /api/mail/results
 * Gibt die letzten blockierten Gambling-Mails zurück (paginiert).
 */
export default defineEventHandler(async (event) => {
  const user = await requireUser(event);

  const query = getQuery(event);
  const page = Math.max(1, parseInt((query.page as string) || "1"));

  await deleteOldMailBlocked(user.id);

  return getMailBlockedPaginated(user.id, page);
});
