Skip to content

Commit

Permalink
Merge pull request #5 from Adamant-im/dev-system-chat-type
Browse files Browse the repository at this point in the history
Adding Signal/Rich chat types
  • Loading branch information
zyuhel authored Jun 9, 2018
2 parents 5c5a184 + 419b32a commit 7abb065
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion logic/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
8 changes: 6 additions & 2 deletions modules/chats.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -118,9 +118,13 @@ __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 ("c_type" = 3)');
}
where.push('"t_type" = '+ transactionTypes.CHAT_MESSAGE);

if (filter.senderId) {
Expand Down
6 changes: 5 additions & 1 deletion modules/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7abb065

Please sign in to comment.