From 0937e1e8760724ab6571e9778553df3950e2a939 Mon Sep 17 00:00:00 2001 From: Bertrand Fan Date: Tue, 12 Dec 2017 16:03:46 -0800 Subject: [PATCH 1/2] Optionally allow a user ID to be passed into users.identity for WTA --- lib/clients/web/facets/users.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/clients/web/facets/users.js b/lib/clients/web/facets/users.js index d667388b1..296c24f9d 100644 --- a/lib/clients/web/facets/users.js +++ b/lib/clients/web/facets/users.js @@ -1,3 +1,5 @@ +var isFunction = require('lodash').isFunction; + /** * API Facet to make calls to methods in the users namespace. * @@ -40,8 +42,21 @@ UsersFacet.prototype.getPresence = function getPresence(user, optCb) { * * @param {function=} optCb Optional callback, if not using promises. */ -UsersFacet.prototype.identity = function identity(optCb) { - return this.makeAPICall('users.identity', null, null, optCb); +UsersFacet.prototype.identity = function identity(user, optCb) { + var cb = null; + var opts = {}; + + cb = optCb; + + if (user) { + if (isFunction(user)) { + cb = user; + } else { + opts.user = user; + } + } + + return this.makeAPICall('users.identity', null, opts, cb); }; From 574d24262f23cb33d91f7309e61e32e610fc0c35 Mon Sep 17 00:00:00 2001 From: Bertrand Fan Date: Tue, 19 Dec 2017 15:37:38 -0800 Subject: [PATCH 2/2] Pass in a set of options so we can expand this method later --- lib/clients/web/facets/users.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/clients/web/facets/users.js b/lib/clients/web/facets/users.js index 296c24f9d..ca3c56f8e 100644 --- a/lib/clients/web/facets/users.js +++ b/lib/clients/web/facets/users.js @@ -40,19 +40,24 @@ UsersFacet.prototype.getPresence = function getPresence(user, optCb) { * Get a user's identity. * @see {@link https://api.slack.com/methods/users.identity|users.identity} * + * @param {Object=} options + * @param {?} opts.user - When calling this method with a workspace token, set this to + * the user ID of the user to retrieve the identity of * @param {function=} optCb Optional callback, if not using promises. */ -UsersFacet.prototype.identity = function identity(user, optCb) { +UsersFacet.prototype.identity = function identity(options, optCb) { var cb = null; var opts = {}; cb = optCb; - if (user) { - if (isFunction(user)) { - cb = user; + if (options) { + if (isFunction(options)) { + cb = options; } else { - opts.user = user; + if (options.user) { + opts.user = options.user; + } } }