Skip to content

Commit

Permalink
fix: save inbound ModelsPack/StylesPack
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Dec 28, 2017
1 parent 45990a6 commit cbf93aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
22 changes: 14 additions & 8 deletions lib/bot/utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 14 additions & 7 deletions src/bot/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ import types = require('../typeforce-types')

const SIMPLE_MESSAGE = 'tradle.SimpleMessage'

const IGNORED_PAYLOAD_TYPES = [
'tradle.Message',
'tradle.CustomerWaiting',
'tradle.ModelsPack',
'tradle.StylesPack'
]
const IGNORE_PAYLOAD_TYPES = {
inbound: [
'tradle.Message',
'tradle.CustomerWaiting'
],
outbound: [
'tradle.Message',
'tradle.CustomerWaiting',
'tradle.ModelsPack',
'tradle.StylesPack'
]
}

const getMessagePayload = async ({ bot, message }) => {
if (message.object[SIG]) {
Expand Down Expand Up @@ -117,7 +123,8 @@ const normalizeRecipient = to => to.id || to
const savePayloadToDB = async ({ bot, message }) => {
const type = message._payloadType
const { logger } = bot
if (IGNORED_PAYLOAD_TYPES.includes(type)) {
const ignored = message._inbound ? IGNORE_PAYLOAD_TYPES.inbound : IGNORE_PAYLOAD_TYPES.outbound
if (ignored.includes(type)) {
logger.debug(`not saving ${type} to type-differentiated table`)
return false
}
Expand Down

0 comments on commit cbf93aa

Please sign in to comment.