Move endpoints to use stream_id instead of stream_name in their URLs

- Change `stream_name` into `stream_id` on some API endpoints that use
`stream_name` in their URLs to prevent confusion of `views` selection.

For example:
If the stream name is "foo/members", the URL would be trigger
"^streams/(?P<stream_name>.*)/members$" and it would be confusing because
we intend to use the endpoint with "^streams/(?P<stream_name>.*)$" regex.

All stream-related endpoints now use stream id instead of stream name,
except for a single endpoint that lets you convert stream names to stream ids.

See https://github.com/zulip/zulip/issues/2930#issuecomment-269576231

- Add `get_stream_id()` method to Zulip API client, and change
`get_subscribers()` method to comply with the new stream API
(replace `stream_name` with `stream_id`).

Fixes #2930.
This commit is contained in:
Rafid Aslam
2016-12-30 17:42:59 +07:00
committed by showell
parent 156eefacc2
commit d3ee53bdef
7 changed files with 113 additions and 67 deletions

View File

@@ -778,8 +778,10 @@ function _setup_page() {
}
$("#deactivation_stream_modal").modal("hide");
$(".active_stream_row button").prop("disabled", true).text("Working…");
var stream_name = $(".active_stream_row").find('.stream_name').text();
var stream_id = stream_data.get_sub(stream_name).stream_id;
channel.del({
url: '/json/streams/' + encodeURIComponent($(".active_stream_row").find('.stream_name').text()),
url: '/json/streams/' + stream_id,
error: function (xhr) {
if (xhr.status.toString().charAt(0) === "4") {
$(".active_stream_row button").closest("td").html(