Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

542 B
Raw Blame
import { storage } from "@/lib/storage";
import { R2_URL } from "@dub/utils";
import { Prisma } from "@prisma/client";

export const deleteScreenshots = async (
  screenshots: Prisma.JsonValue | null,
) => {
  const images = screenshots as string[];

  if (!images || images.length === 0) {
    return;
  }

  return await Promise.all(
    images.map(async (image: string) => {
      if (image.startsWith(`${R2_URL}/integration-screenshots`)) {
        return storage.delete({ key: image.replace(`${R2_URL}/`, "") });
      }
    }),
  );
};