From 03107429888e8622f4d671afd410b8d859b1c39f Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 10 Mar 2024 16:56:29 -0600 Subject: [PATCH] add claim_type and handle_id to record --- README.md | 2 ++ server.js | 9 +++++++-- sql/migrations/V1__Create_image_table.sql | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b80e7b..c871849 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ AWS_REGION= INFURA_PROJECT_ID= ``` +If you use a domain with a web redirect, use a permanent redirect (since browsers complained with PR_END_OF_FILE_ERROR about a secure connection when it's temporary). + ## dev ``` diff --git a/server.js b/server.js index ebd3a30..b671df2 100644 --- a/server.js +++ b/server.js @@ -175,12 +175,16 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => { const currentDate = new Date().toISOString(); const localFile = reqFile.path.startsWith(uploadDir + '/') ? reqFile.path.substring(uploadDir.length + 1) : reqFile.path; const finalUrl = `https://${imageServer}/${fileName}`; + const claimType = req.body.claimType; + const handleId = req.body.handleId; await new Promise((resolve, reject) => { db.run( - 'INSERT INTO image (time, did, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?)', + 'INSERT INTO image (time, did, claim_type, handle_id, local_file, size, final_file, url) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', [ currentDate, issuerDid, + claimType, + handleId, localFile, reqFile.size, fileName, @@ -272,6 +276,7 @@ app.delete('/image/:url', async (req, res) => { ); }); if (!thisUserImageFile) { + console.log('No image entry found for user', issuerDid, '& URL', url, 'so returning 404.'); return res.status(404).send(JSON.stringify({ success: false, message: 'No image entry found for user ' + issuerDid + ' & URL ' + url })); } @@ -282,7 +287,7 @@ app.delete('/image/:url', async (req, res) => { [ url, issuerDid ], (dbErr, row) => { if (dbErr) { - console.error(currentDate, 'Error getting image for user from database:', dbErr) + console.error(currentDate, 'Error getting image for other users from database:', dbErr) reject(dbErr); } resolve(row?.did); diff --git a/sql/migrations/V1__Create_image_table.sql b/sql/migrations/V1__Create_image_table.sql index ec8c45b..748d8a6 100644 --- a/sql/migrations/V1__Create_image_table.sql +++ b/sql/migrations/V1__Create_image_table.sql @@ -2,6 +2,8 @@ CREATE TABLE image ( time TEXT NOT NULL, -- ISO 8601 @ UTC, eg 2019-01-01T00:00:00Z did TEXT NOT NULL, + claim_type TEXT, + handle_id TEXT, local_file TEXT NOT NULL, size INTEGER NOT NULL, final_file TEXT NOT NULL,