Skip to content

Commit e22f628

Browse files
committed
delete account listing media without slug
1 parent 797bcb2 commit e22f628

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

  • supabase/functions/delete-account

supabase/functions/delete-account/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,20 @@ serve(async (req) => {
7272
// Fetch all listings for the user to delete their avatars
7373
const { data: listings, error: listingsError } = await supabaseAdmin
7474
.from("listings")
75-
.select("slug, avatar, photos")
75+
.select("id, slug, avatar, photos")
7676
.eq("owner_id", user.id);
7777
if (listingsError) {
7878
console.error("Listings fetch error:", listingsError);
7979
throw listingsError;
8080
}
8181
// Delete media for each listing
8282
for (const listing of listings ?? []) {
83-
if (!listing.slug) {
84-
console.warn("Skipping listing media deletion because slug is missing");
85-
continue;
86-
}
87-
8883
try {
8984
await deleteListingMedia(supabaseAdmin, listing);
9085
} catch (error) {
86+
const listingLabel = listing.slug ?? `id:${listing.id}`;
9187
console.error(
92-
`Error deleting media for listing ${listing.slug}:`,
88+
`Error deleting media for listing ${listingLabel}:`,
9389
error
9490
);
9591
throw error;

0 commit comments

Comments
 (0)