import { d as defineEventHandler, r as readValidatedBody, l as APUser, c as createError, m as unfollowActor } from '../../../nitro/nitro.mjs';
import { z } from 'zod';
import 'luxon';
import '@sequelize/core';
import 'html-to-text';
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';

const schema = z.object({
  ap_id: z.string()
});
const trust_delete = defineEventHandler(async (event) => {
  const body = await readValidatedBody(event, schema.parse);
  const ap_actor = await APUser.findByPk(body.ap_id);
  if (!ap_actor || !ap_actor.trusted) {
    throw createError({ status: 404, message: "This ap user does not exists or not trusted" });
  }
  if (ap_actor.following) {
    await unfollowActor(ap_actor).catch(() => {
    });
  }
  await ap_actor.update({ trusted: false });
});

export { trust_delete as default };
