diff --git a/server/src/cache.js b/server/src/cache.js index 9bcf644b..1704f8e4 100644 --- a/server/src/cache.js +++ b/server/src/cache.js @@ -162,13 +162,16 @@ async function removeAttachmentTimestamps(data) { let { ending, filename } = getAutoFilename(attachment); attachment._autoFilename = filename; attachment.fileExtension = ending; - attachments.set(attachment.id, attachment); + attachments.set(attachment.id, {...attachment}); - attachment.url = generateAttachmentURL(attachment.url, attachment); + // we don't want the URLs to appear in requests anymore + // the data server just uses the attachment IDs + + attachment.url = null; // generateAttachmentURL(attachment.url, attachment); for (let size in attachment.thumbnails) { size = attachment.thumbnails[size]; - size.url = generateAttachmentURL(size.url, attachment); + size.url = null; // generateAttachmentURL(size.url, attachment); } }); } diff --git a/server/src/images.js b/server/src/images.js index ade58447..86fd6120 100644 --- a/server/src/images.js +++ b/server/src/images.js @@ -51,7 +51,13 @@ async function downloadImage(url, filename, size) { file.on("finish", () => file.close(resolve)); }).on("error", err => { console.error(`[image] file error for ${filename} ${err.code} ${err.message}`); - fs.unlink(pathName); + fs.unlink(pathName, function(err) { + if (err) { + console.error(`[image] file error for ${filename} unlink FAILED`, err); + } else { + console.error(`[image] file error for ${filename} unlinked`); + } + }); reject(err); }); })); diff --git a/server/src/meta.js b/server/src/meta.js index 220416a4..4825f728 100644 --- a/server/src/meta.js +++ b/server/src/meta.js @@ -12,11 +12,12 @@ function getFileEnding(url) { } const dataServer = process.env.NODE_ENV === "development" ? "http://localhost:8901" : "https://data.slmn.gg"; -function getResizedImage(airtableURL, size = "s-500") { - // just using orig for now - return `${dataServer}/image.${getFileEnding(airtableURL) || "png"}?size=orig&url=${encodeURIComponent(airtableURL.replace("?", "&"))}`; + +function getImageURL(attachment, size = "orig") { + return `${dataServer}/image.${attachment.fileExtension}?id=${attachment.id}&size=${size}`; } + function aImg(airtableImage, size) { // console.log(airtableImage); if (!airtableImage || !airtableImage.length) return null; @@ -25,7 +26,7 @@ function aImg(airtableImage, size) { width: i.width, height: i.height, type: i.type, - url: getResizedImage(i.url, size) + url: getImageURL(i.url, size) }; } function themeSquare(id, size = 500) { diff --git a/website/src/components/broadcast/MapSegment.vue b/website/src/components/broadcast/MapSegment.vue index be852334..c72ebb0b 100644 --- a/website/src/components/broadcast/MapSegment.vue +++ b/website/src/components/broadcast/MapSegment.vue @@ -36,7 +36,7 @@