Skip to content

Commit

Permalink
delete shoutout images w/ shoutout (#711)
Browse files Browse the repository at this point in the history
Previously, if an IDOL user deleted a shoutout that had an image
attached to it, the image wouldn't get deleted (taking up space in our
storage).

I tested this by submitting shoutouts with images, seeing them get added
to the Firebase, and removed when I deleted the shoutout from IDOL.

---------

Co-authored-by: keverie <[email protected]>
Co-authored-by: Andrew Chen <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent b6a73a1 commit 6573697
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions backend/src/API/shoutoutAPI.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PermissionsManager from '../utils/permissionsManager';
import { NotFoundError, PermissionError } from '../utils/errors';
import ShoutoutsDao from '../dao/ShoutoutsDao';
import { deleteImage } from './imageAPI';

const shoutoutsDao = new ShoutoutsDao();

Expand Down Expand Up @@ -80,5 +81,8 @@ export const deleteShoutout = async (uuid: string, user: IdolMember): Promise<vo
`You are not a lead or admin, so you can't delete a shoutout from a different user!`
);
}
if (shoutout.images && shoutout.images.length > 0) {
await deleteImage(shoutout.images[0]);
}
await shoutoutsDao.deleteShoutout(uuid);
};

0 comments on commit 6573697

Please sign in to comment.