diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f30d3c4c..8c6e6b089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### v3.1.1 (2016-05-19) + + * Removes the DM facet + * Updates the aliasing approach for IM / DM to correctly alias DM to the IM Facet + ### v3.1.0 (2016-05-01) * Updates the [`lib/clients/web/facets/index.js`](/lib/clients/web/facets/index.js) to reference the new facets added in the 3.0.0 update, thanks @ekmartin diff --git a/lib/clients/web/client.js b/lib/clients/web/client.js index 4a1301833..d877bd9dd 100644 --- a/lib/clients/web/client.js +++ b/lib/clients/web/client.js @@ -40,8 +40,9 @@ WebAPIClient.prototype._createFacets = function _createFacets() { this[newFacet.name] = newFacet; }, this); - // Alias the DM facet, so that it matches the docs - this.im = this.dm; + // Add a dm alias for the im and mpim facets + this.dm = this.im; + this.mpdm = this.mpim; }; diff --git a/lib/clients/web/facets/dm.js b/lib/clients/web/facets/dm.js deleted file mode 100644 index ad8d422b9..000000000 --- a/lib/clients/web/facets/dm.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * API Facet to make calls to methods in the im namespace. - * - * This provides functions to call: - * - close: {@link https://api.slack.com/methods/im.close|im.close} - * - history: {@link https://api.slack.com/methods/im.history|im.history} - * - list: {@link https://api.slack.com/methods/im.list|im.list} - * - mark: {@link https://api.slack.com/methods/im.mark|im.mark} - * - open: {@link https://api.slack.com/methods/im.open|im.open} - * - */ - -function DmFacet(makeAPICall) { - this.name = 'dm'; - this.makeAPICall = makeAPICall; -} - - -/** - * Close a direct message channel. - * @see {@link https://api.slack.com/methods/im.close|im.close} - * - * @param {?} channel Direct message channel to close. - * @param {function} optCb Optional callback, if not using promises. - */ -DmFacet.prototype.close = function close(channel, optCb) { - var args = { - channel: channel - }; - - return this.makeAPICall('im.close', args, optCb); -}; - -/** - * Fetches history of messages and events from direct message channel. - * @see {@link https://api.slack.com/methods/im.history|im.history} - * - * @param {?} channel Direct message channel to fetch history for. - * @param {Object=} opts - * @param {?} opts.latest End of time range of messages to include in results. - * @param {?} opts.oldest Start of time range of messages to include in results. - * @param {?} opts.inclusive Include messages with latest or oldest timestamp in results. - * @param {?} opts.count Number of messages to return, between 1 and 1000. - * @param {function} optCb Optional callback, if not using promises. - */ -DmFacet.prototype.history = function history(channel, opts, optCb) { - var args = { - channel: channel, - opts: opts - }; - - return this.makeAPICall('im.history', args, optCb); -}; - -/** - * Lists direct message channels for the calling user. - * @see {@link https://api.slack.com/methods/im.list|im.list} - * @param {function} optCb Optional callback, if not using promises. - */ -DmFacet.prototype.list = function list(optCb) { - var args = {}; - - return this.makeAPICall('im.list', args, optCb); -}; - -/** - * Sets the read cursor in a direct message channel. - * @see {@link https://api.slack.com/methods/im.mark|im.mark} - * - * @param {?} channel Direct message channel to set reading cursor in. - * @param {?} ts Timestamp of the most recently seen message. - * @param {function} optCb Optional callback, if not using promises. - */ -DmFacet.prototype.mark = function mark(channel, ts, optCb) { - var args = { - channel: channel, - ts: ts - }; - - return this.makeAPICall('im.mark', args, optCb); -}; - -/** - * Opens a direct message channel. - * @see {@link https://api.slack.com/methods/im.open|im.open} - * - * @param {?} user User to open a direct message channel with. - * @param {function} optCb Optional callback, if not using promises. - */ -DmFacet.prototype.open = function open(user, optCb) { - var args = { - user: user - }; - - return this.makeAPICall('im.open', args, optCb); -}; - - -module.exports = DmFacet; diff --git a/lib/clients/web/facets/index.js b/lib/clients/web/facets/index.js index 0eb23771a..d155e3b48 100644 --- a/lib/clients/web/facets/index.js +++ b/lib/clients/web/facets/index.js @@ -3,12 +3,12 @@ module.exports = { AuthFacet: require('./auth.js'), ChannelsFacet: require('./channels.js'), ChatFacet: require('./chat.js'), - DmFacet: require('./dm.js'), DndFacet: require('./dnd.js'), EmojiFacet: require('./emoji.js'), FilesFacet: require('./files.js'), FilesCommentsFacet: require('./files.comments.js'), GroupsFacet: require('./groups.js'), + ImFacet: require('./im'), MpimFacet: require('./mpim.js'), OauthFacet: require('./oauth.js'), PinsFacet: require('./pins.js'), diff --git a/package.json b/package.json index d953d4497..7f587d6fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@slack/client", - "version": "3.1.0", + "version": "3.1.1", "description": "A library for creating a Slack client", "main": "./index", "scripts": { diff --git a/test/clients/web/client.js b/test/clients/web/client.js index a11da5870..cd0112592 100644 --- a/test/clients/web/client.js +++ b/test/clients/web/client.js @@ -30,8 +30,8 @@ describe('Web API Client', function () { facets.forEach(function (Facet) { var name = new Facet().name; // The 'im' facet is aliased to dm: - if (name === 'im') { - expect(client[name].name).to.equal('dm'); + if (name === 'dm') { + expect(client[name].name).to.equal('im'); } else { expect(client[name].name).to.equal(name); }