From 4b2064bb284af38bbcb809d0ddf1fed91bb2db50 Mon Sep 17 00:00:00 2001 From: Zyuhel Date: Tue, 29 May 2018 17:40:25 +0300 Subject: [PATCH 1/4] Adding System Chat Messages with type 3 --- logic/chat.js | 2 +- modules/chats.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/logic/chat.js b/logic/chat.js index 07b65f72..ed274ca1 100644 --- a/logic/chat.js +++ b/logic/chat.js @@ -114,7 +114,7 @@ Chat.prototype.verify = function (trs, sender, cb) { } - if (trs.asset.chat.type > 1 || trs.asset.chat.type < 0) { + if (trs.asset.chat.type > 3 || trs.asset.chat.type < 0) { return setImmediate(cb, 'Invalid message type'); } diff --git a/modules/chats.js b/modules/chats.js index cd4cdf6a..1441aa2a 100644 --- a/modules/chats.js +++ b/modules/chats.js @@ -106,7 +106,7 @@ __private.getByIds = function (ids, cb) { }; /** - * Gets records from `dapps` table based on filter + * Gets records from `chats` table based on filter * @private * @implements {library.db.query} * @param {Object} filter - Could contains type, name, category, link, limit, @@ -121,6 +121,10 @@ __private.list = function (filter, cb) { where.push('"type" = ${type}'); params.type = filter.type; } + else { + // message type=3 is reserved for system messages, and shouldn't be retrieved without a filter + where.push('NOT ("type" = 3)'); + } where.push('"t_type" = '+ transactionTypes.CHAT_MESSAGE); if (filter.senderId) { From d4a2cf8c0a6a1ddfae3fe8073303bd8be07dbc38 Mon Sep 17 00:00:00 2001 From: zyuhel Date: Fri, 8 Jun 2018 19:37:24 +0300 Subject: [PATCH 2/4] Fixing chat message type filter --- modules/chats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/chats.js b/modules/chats.js index 1441aa2a..cf5e0f1b 100644 --- a/modules/chats.js +++ b/modules/chats.js @@ -118,12 +118,12 @@ __private.list = function (filter, cb) { var params = {}, where = []; if (filter.type >= 0) { - where.push('"type" = ${type}'); + where.push('"c_type" = ${type}'); params.type = filter.type; } else { // message type=3 is reserved for system messages, and shouldn't be retrieved without a filter - where.push('NOT ("type" = 3)'); + where.push('NOT ("c_type" = 3)'); } where.push('"t_type" = '+ transactionTypes.CHAT_MESSAGE); From 5639fef9127b95fc95409a60b40e5d91e1d68a07 Mon Sep 17 00:00:00 2001 From: zyuhel Date: Sat, 9 Jun 2018 12:55:05 +0300 Subject: [PATCH 3/4] Fixing KVS filter --- modules/states.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/states.js b/modules/states.js index a033bcc0..117006ac 100644 --- a/modules/states.js +++ b/modules/states.js @@ -118,9 +118,13 @@ __private.list = function (filter, cb) { var params = {}, where = []; if (filter.type >= 0) { - where.push('"type" = ${type}'); + where.push('"st_type" = ${type}'); params.type = filter.type; } + if (filter.key) { + where.push('"st_stored_key" = ${key}'); + params.key = filter.key; + } where.push('"t_type" = '+ transactionTypes.STATE); if (filter.senderId) { From 419b32a994b335ebccb8092b8cf925c4fa7bd730 Mon Sep 17 00:00:00 2001 From: zyuhel Date: Sat, 9 Jun 2018 13:01:41 +0300 Subject: [PATCH 4/4] updating version number to 0.3.0 Because of incompatibility with new message types --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 582c3173..bd42ecc4 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,8 @@ { "port": 36666, "address": "0.0.0.0", - "version": "0.2.1", - "minVersion": ">=0.2.1", + "version": "0.3.0", + "minVersion": ">=0.3.0", "fileLogLevel": "info", "logFileName": "logs/adamant.log", "consoleLogLevel": "none",