Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getDMByUserId in data store #264

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/data-store/data-store.js
Expand Up @@ -158,6 +158,15 @@ SlackDataStore.prototype.getDMByName = function getDMByName(name) {
};


/**
* Returns the DM object between the registered user and the user with the supplied id.
* @param id
* @return {Object}
*/
SlackDataStore.prototype.getDMByUserId = function getDMByName(userId) {
};


/**
* Returns the bot object matching the supplied id.
* @param botId
Expand Down
4 changes: 4 additions & 0 deletions lib/data-store/memory-data-store.js
Expand Up @@ -135,6 +135,10 @@ SlackMemoryDataStore.prototype.getDMByName = function getDMByName(name) {
return find(this.dms, ['user', user.id]);
};

/** @inheritdoc */
SlackMemoryDataStore.prototype.getDMByUserId = function getDMByUserId(userId) {
return find(this.dms, ['user', userId]);
};

/** @inheritdoc */
SlackMemoryDataStore.prototype.getBotById = function getBotById(botId) {
Expand Down
9 changes: 9 additions & 0 deletions test/data-store/memory-data-store.js
Expand Up @@ -27,6 +27,15 @@ describe('MemoryDataStore', function () {
});
});

describe('#getDMByUserId', function () {
it('should get a DM with another user when passed the id of that user', function () {
var dataStore = getMemoryDataStore();
var user = dataStore.getUserByName('bob');
var dm = dataStore.getDMByUserId(user.id);
expect(dm.id).to.equal('D0CHZQWNP');
});
});

describe('#getChannelByName()', function () {
it('should get a channel by name', function () {
var dataStore = getMemoryDataStore();
Expand Down