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 endpoint to delete reactions on a message by message id. #70

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ zulip.callEndpoint('/messages', 'POST', params);
| `zulip.messages.flags.add()` | POST `/messages/flags` | add a flag to a list of messages. Its params are `flag` which is one of `[read, starred, mentioned, wildcard_mentioned, has_alert_word, historical]` and `messages` which is a list of messageIDs. |
| `zulip.messages.flags.remove()` | POST `/messages/flags` | remove a flag from a list of messages. Its params are `flag` which is one of `[read, starred, mentioned, wildcard_mentioned, has_alert_word, historical]` and `messages` which is a list of messageIDs. |
| `zulip.messages.getById()` | GET `/messages/<msg_id>` | returns a message by its id. |
| `zulip.messages.deleteReactionById()` | DELETE `/messages/<msg_id>/reactions` | deletes reactions on a message by message id |
| `zulip.queues.register()` | POST `/register` | registers a new queue. You can pass it a params object with the types of events you are interested in and whether you want to receive raw text or html (using markdown). |
| `zulip.queues.deregister()` | DELETE `/events` | deletes a previously registered queue. |
| `zulip.reactions.add()` | POST `/reactions` | add a reaction to a message. Accepts a params object with `message_id`, `emoji_name`, `emoji_code` and `reaction_type` (default is `unicode_emoji`). |
Expand Down
7 changes: 7 additions & 0 deletions examples/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,10 @@ zulip(config).then((z) => {
};
z.messages.getById(readParams).then(console.log);
}).catch(err => console.log(err.message));

zulip(config).then((z) => {
const readParams = {
message_id: 1,
};
z.messages.deleteReactionById(readParams).then(console.log);
}).catch(err => console.log(err.message));
4 changes: 4 additions & 0 deletions src/resources/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function messages(config) {
const url = `${config.apiURL}/messages/${params.message_id}`;
return api(url, config, 'GET', params);
},
deleteReactionById: (params) => {
const url = `${config.apiURL}/messages/${params.message_id}/reactions`;
return api(url, config, 'DELETE', params);
},
};
}

Expand Down
22 changes: 22 additions & 0 deletions test/resources/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,26 @@ describe('Messages', () => {
done();
}).catch(done);
});

it('should delete reaction by message id', (done) => {
const params = {
message_id: 1,
};
const validator = (url, options) => {
url.should.contain(`${common.config.apiURL}/messages/1/reactions`);
options.should.not.have.property('body');
options.method.should.be.equal('DELETE');
};
const output = {
msg: '',
result: 'success',
};
const stubs = common.getStubs(validator, output);
messages(common.config).deleteReactionById(params)
.then((data) => {
data.should.have.property('result', 'success');
common.restoreStubs(stubs);
done();
}).catch(done);
});
});