Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Fix #1279 #1301

Merged
merged 2 commits into from
Apr 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 4 additions & 26 deletions lib/Facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var Botkit = require(__dirname + '/CoreBot.js');
var request = require('request');
var crypto = require('crypto');
var bodyParser = require('body-parser');
var clone = require('clone');

function Facebookbot(configuration) {

Expand Down Expand Up @@ -56,36 +57,13 @@ function Facebookbot(configuration) {
}

if (message.quick_replies) {

// sanitize the length of the title to maximum of 20 chars
var titleLimit = function(title) {
if (title.length > 20) {
var newTitle = title.substring(0, 16) + '...';
return newTitle;
} else {
return title;
}
};

platform_message.message.quick_replies = message.quick_replies.map(function(item) {
var quick_reply = {};
if (item.content_type === 'text' || !item.content_type) {
quick_reply = {
content_type: 'text',
title: titleLimit(item.title),
payload: item.payload,
image_url: item.image_url,
};
} else if (item.content_type === 'location') {
quick_reply = {
content_type: 'location'
};
} else {
// Future quick replies types
}
var quick_reply = clone(item);
if (!item.content_type) quick_reply.content_type = 'text';
return quick_reply;
});
}

} else {
platform_message.sender_action = message.sender_action;
}
Expand Down