Skip to content

Commit

Permalink
Get rid of magic number
Browse files Browse the repository at this point in the history
  • Loading branch information
zyuhel committed May 15, 2019
1 parent 3f4c054 commit d851332
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion helpers/transactionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ module.exports = {
IN_TRANSFER: 6,
OUT_TRANSFER: 7,
CHAT_MESSAGE: 8,
STATE: 9
STATE: 9,
CHAT_MESSAGE_TYPES: {
LEGACY_MESSAGE: 0,
ORDINARY_MESSAGE: 1,
RICH_TEXT_MESSAGE: 2,
SIGNAL_MESSAGE: 3
}
};
4 changes: 2 additions & 2 deletions modules/chatrooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ __private.listChats = function (filter, cb) {
} else {
where.push(`("t_type" = ${transactionTypes.CHAT_MESSAGE} OR "t_type" = ${transactionTypes.SEND})`);
}
where.push('(NOT("c_type" = 3) OR c_type IS NULL) ');
where.push(`(NOT("c_type" = ${transactionTypes.CHAT_MESSAGE_TYPES.SIGNAL_MESSAGE}) OR c_type IS NULL) `);
if (filter.senderId) {
where.push('"t_senderId" = ${name}');
params.name = filter.senderId;
Expand Down Expand Up @@ -162,7 +162,7 @@ __private.listMessages = function (filter, cb) {
where.push('"c_type" = ${type}');
params.type = filter.type;
} else {
where.push('(NOT("c_type" = 3) OR c_type IS NULL) ');
where.push(`(NOT("c_type" = ${transactionTypes.CHAT_MESSAGE_TYPES.SIGNAL_MESSAGE}) OR c_type IS NULL)`);
}
if (filter.withoutDirectTransfers) {
where.push('"t_type" = ' + transactionTypes.CHAT_MESSAGE);
Expand Down

0 comments on commit d851332

Please sign in to comment.