Skip to content

Commit

Permalink
adding an error message when fetching satellite image
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibault Camlane committed Jul 14, 2025
1 parent 24ad84c commit f5e100b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 0 additions & 2 deletions backend/src/api/slack/controllers/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ module.exports = {
},
getSharedURL: async (ctx) => {
const { fileId } = ctx.request.body;
const slackToken = process.env.SLACK_BOT_TOKEN;

if (!fileId) {
return ctx.badRequest("File ID is required");
}
Expand Down
3 changes: 2 additions & 1 deletion backend/src/api/slack/services/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ module.exports = {
try {
const result = await slack.conversations.history({
channel: process.env.SLACK_CHANNEL_ID,
limit: 20,
limit: 15,
});
console.log("Fetched images from Slack:", result.messages.length);
cachedImages = result.messages.filter(
(msg) =>
msg.bot_profile?.name === "hypso1bot" &&
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/app/satellites/[satelliteSlug]/satImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default function SatImage({
files: SlackFile[];
}

console.log("Fetched Slack images:", data);
const rightMessage: SlackMessage | undefined = (
data as SlackMessage[]
).find((message: SlackMessage) => {
Expand All @@ -92,7 +93,13 @@ export default function SatImage({
}
return false;
});

if (!rightMessage) {
console.warn("No matching satellite image found.");
setError(
"No matching satellite image found. Try again later when a new image is uploaded.",
);
return;
}
const rightFile: SlackFile | undefined = rightMessage?.files[0];
makeTheImagePublic(rightFile?.id as number).catch((err) => {
console.error("Error making image public:", err);
Expand Down

0 comments on commit f5e100b

Please sign in to comment.