Skip to content

Commit

Permalink
Merge pull request #1732 from OriginTrail/v6/prerelease/testnet
Browse files Browse the repository at this point in the history
OriginTrail 6.0.0-beta.1.22 Testnet Release
  • Loading branch information
NZT48 authored Feb 4, 2022
2 parents a303e97 + 9f76a73 commit 81ee43c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
3 changes: 3 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 3,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand Down Expand Up @@ -60,6 +61,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 3,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand Down Expand Up @@ -93,6 +95,7 @@
"password": ""
},
"logLevel": "trace",
"replicationFactor" : 3,
"rpcPort": 8900,
"network": {
"port": 9000,
Expand Down
20 changes: 20 additions & 0 deletions modules/controller/rpc-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,15 @@ class RpcController {
this.app.post('/publish', async (req, res, next) => {
if (!req.files || !req.files.file || !req.body.assets) {
return next({code: 400, message: 'File, assets, and keywords are required fields.'});
} else {
if(!this.isArrayOfStrings(req.body.assets)){
return next({code: 400, message: `Assets must be a non-empty array of strings, all strings must have double quotes.`});
}
if(req.body.keywords && !this.isArrayOfStrings(req.body.keywords)) {
return next({code: 400, message: `Keywords must be a non-empty array of strings, all strings must have double quotes.`});
}
}

const operationId = uuidv1();
try {
this.logger.emit({
Expand Down Expand Up @@ -769,6 +777,18 @@ class RpcController {
}
});
}

isArrayOfStrings(arr) {
try {
const bodyAssets = JSON.parse(arr.toLowerCase());
if (!(Array.isArray(bodyAssets)) | !(bodyAssets.length > 0) | !bodyAssets.every(i => (typeof i === "string")) | bodyAssets[0] === "") {
return false;
}
} catch (e) {
return false;
}
return true;
}
}

module.exports = RpcController;
1 change: 0 additions & 1 deletion modules/service/publish-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class PublishService {
assertion.id = this.validationService.calculateHash(assertion.metadataHash + assertion.metadata.dataHash);
assertion.signature = this.validationService.sign(assertion.id);

keywords.push(assertion.metadata.type);
keywords = [...new Set(keywords.concat(rawAssets))];

const assets = [];
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.0.0-beta.1.21",
"version": "6.0.0-beta.1.22",
"description": "OTNode v6 Beta 1",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -76,7 +76,7 @@
"mysql2": "^2.3.3",
"n3": "^1.12.2",
"nodemon": "^2.0.15",
"ot-telemetry-collector": "^1.0.1",
"ot-telemetry-collector": "^1.0.2",
"p-iteration": "^1.1.8",
"peer-id": "^0.15.3",
"pino": "^7.5.1",
Expand Down

0 comments on commit 81ee43c

Please sign in to comment.