add claim_type and handle_id to record
This commit is contained in:
@@ -26,6 +26,8 @@ AWS_REGION=
|
|||||||
INFURA_PROJECT_ID=
|
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
|
## dev
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -175,12 +175,16 @@ app.post('/image', uploadMulter.single('image'), async (req, res) => {
|
|||||||
const currentDate = new Date().toISOString();
|
const currentDate = new Date().toISOString();
|
||||||
const localFile = reqFile.path.startsWith(uploadDir + '/') ? reqFile.path.substring(uploadDir.length + 1) : reqFile.path;
|
const localFile = reqFile.path.startsWith(uploadDir + '/') ? reqFile.path.substring(uploadDir.length + 1) : reqFile.path;
|
||||||
const finalUrl = `https://${imageServer}/${fileName}`;
|
const finalUrl = `https://${imageServer}/${fileName}`;
|
||||||
|
const claimType = req.body.claimType;
|
||||||
|
const handleId = req.body.handleId;
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
db.run(
|
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,
|
currentDate,
|
||||||
issuerDid,
|
issuerDid,
|
||||||
|
claimType,
|
||||||
|
handleId,
|
||||||
localFile,
|
localFile,
|
||||||
reqFile.size,
|
reqFile.size,
|
||||||
fileName,
|
fileName,
|
||||||
@@ -272,6 +276,7 @@ app.delete('/image/:url', async (req, res) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (!thisUserImageFile) {
|
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 }));
|
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 ],
|
[ url, issuerDid ],
|
||||||
(dbErr, row) => {
|
(dbErr, row) => {
|
||||||
if (dbErr) {
|
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);
|
reject(dbErr);
|
||||||
}
|
}
|
||||||
resolve(row?.did);
|
resolve(row?.did);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
CREATE TABLE image (
|
CREATE TABLE image (
|
||||||
time TEXT NOT NULL, -- ISO 8601 @ UTC, eg 2019-01-01T00:00:00Z
|
time TEXT NOT NULL, -- ISO 8601 @ UTC, eg 2019-01-01T00:00:00Z
|
||||||
did TEXT NOT NULL,
|
did TEXT NOT NULL,
|
||||||
|
claim_type TEXT,
|
||||||
|
handle_id TEXT,
|
||||||
local_file TEXT NOT NULL,
|
local_file TEXT NOT NULL,
|
||||||
size INTEGER NOT NULL,
|
size INTEGER NOT NULL,
|
||||||
final_file TEXT NOT NULL,
|
final_file TEXT NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user