import { y as defineEventHandler, b0 as useLogger, aa as getRouterParam, E as Event, d as Place, v as createError, s as canModifyEvent, aN as sendEvent } from '../../../../nitro/nitro.mjs';
import { b as requireUser } from '../../../../_/session.mjs';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
import 'zod';
import 'crypto';
import 'node:fs';
import 'sharp';
import 'path';
import 'node:stream';
import 'jsdom';
import 'dompurify';
import 'mime-types';
import 'fs';
import 'fs/promises';
import 'linkify-html';
import '@peertube/http-signature';
import 'jsonld';
import 'lodash.intersection';
import 'email-templates';
import 'node:http';
import 'node:https';
import 'node:crypto';
import 'node:events';
import 'node:buffer';
import 'node:path';
import 'vue';
import 'vue-router';
import 'dotenv';
import 'url';
import 'bcryptjs';
import 'slugify';
import 'umzug';
import 'consola';
import '@sequelize/core/decorators-legacy';
import 'util';
import 'mitt';
import 'ical.js';
import 'node:url';
import 'fast-xml-parser';
import '../../../../_/getUser.mjs';
import '../../../../_/jwt.mjs';
import 'jose';

const reannounce_put = defineEventHandler(async (evt) => {
  const log = useLogger("Event reannounce");
  const id = getRouterParam(evt, "id");
  const user = await requireUser(evt);
  const event = await Event.findByPk(id, { include: [{ model: Place }] });
  if (!event) {
    log.warn(`Not found ${id}`);
    throw createError({ status: 404 });
  }
  if (!canModifyEvent(event, user)) {
    log.warn(`Someone not allowed is trying to reannounce -> "${event.title}`);
    throw createError({ status: 403 });
  }
  await sendEvent(event, "Announce");
});

export { reannounce_put as default };
