From fb4308bc93d0f016e1915d1be762496712d5ff6f Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Thu, 17 May 2018 14:49:00 +0200 Subject: [PATCH 1/2] Add thread owner API --- lib/Facebook.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/Facebook.js b/lib/Facebook.js index d2fa00253..31c42be56 100644 --- a/lib/Facebook.js +++ b/lib/Facebook.js @@ -1195,6 +1195,42 @@ function Facebookbot(configuration) { } } }); + }, + get_thread_owner: function(recipient, cb) { + + var uri = 'https://' + api_host + '/' + api_version + '/me/thread_owner'; + + if (facebook_botkit.config.require_appsecret_proof) { + uri += '&appsecret_proof=' + appsecret_proof; + } + + request.get({ + url: uri, + qs: { + recipient: recipient, + access_token: configuration.access_token + }, + json: true + }, function(err, res, body) { + if (err) { + facebook_botkit.log('Could not get thread owner'); + if (cb) { + cb(err); + } + } else { + if (body.error) { + facebook_botkit.log('ERROR while getting thread owner : ', body.error.message); + if (cb) { + cb(body.error); + } + } else { + facebook_botkit.debug('Successfully getting thread owner', body); + if (cb) { + cb(null, body); + } + } + } + }); } }; var broadcast_api = { From e0e1f23710dedd51f196b38f0ff4807b46a5a5b7 Mon Sep 17 00:00:00 2001 From: Ouadie Lahdioui Date: Thu, 17 May 2018 14:52:44 +0200 Subject: [PATCH 2/2] Improve doc : Add thread owner API section --- docs/readme-facebook.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/readme-facebook.md b/docs/readme-facebook.md index c7998d32e..a7f2932e4 100644 --- a/docs/readme-facebook.md +++ b/docs/readme-facebook.md @@ -649,6 +649,17 @@ controller.api.handover.request_thread_control('', 'String to pa }); ``` +### Get Thread Owner + +Th Thread Owner API returns the app ID of the app the currently has thread control for a Page : + +- To get the app ID of the current thread owner : +```javascript +controller.api.handover.get_thread_owner('', function (result) { + +}); +``` + ## Messaging type