import { doModifyAvatarIntro } from "@/app/www/logic/avatar";
import logIP from "@/app/www/media/logIP";
import validateMillis from "@/app/www/media/validateMillis";
import validateTotem from "@/app/www/media/validateTotem";

export const PUT = logIP(
  validateMillis(
    validateTotem(async (req) => {
      const avatarID = req.headers.get("avatarID") as string;

      return new Response(undefined, {
        status: (await doModifyAvatarIntro(avatarID, await req.text()))
          ? 204
          : 403,
      });
    }),
  ),
);
