Skip to content

Commit

Permalink
update processing incoming for postback
Browse files Browse the repository at this point in the history
  • Loading branch information
radTuti committed May 3, 2017
1 parent af5a538 commit 1339183
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/incomingMessage/index.js
Expand Up @@ -64,6 +64,16 @@ function ProcessMessage(entry, stickerMap) {
else if (entry.postback) {
message.type = 'postback';
message.payload = entry.postback.payload;
if (entry.postback.referral) {
message.source = entry.postback.referral.source;
message.referral_type = entry.postback.referral.type;
if (entry.postback.referral.ref) {
message.ref = entry.postback.referral.ref;
}
if (entry.postback.referral.ad_id) {
message.ad_id = entry.postback.referral.ad_id;
}
}
}
else if (entry.account_linking) {
message.type = 'account_linking';
Expand Down
5 changes: 4 additions & 1 deletion test/incomingMessage/index.test.js
Expand Up @@ -319,7 +319,7 @@ test('ProcessIncoming - Message Echo', (expect) => {
expect.end();
});

test('ProcessIncoming - Postback', (expect) => {
test.only('ProcessIncoming - Postback', (expect) => {
expect.same(ProcessIncoming({
object: 'page',
entry: [
Expand Down Expand Up @@ -355,6 +355,9 @@ test('ProcessIncoming - Postback', (expect) => {
timestamp: 1458692752478,
type: 'postback',
payload: 'USER_DEFINED_PAYLOAD',
ref: 'USER_DEFINED_REFERRAL_PARAM',
source: 'SHORTLINK',
referral_type: 'OPEN_THREAD',
},
],
}, 'should return corect normalized entries');
Expand Down

0 comments on commit 1339183

Please sign in to comment.