zulip: Make a DELETE request in remove_subscriptions.

Previously, remove_subscriptions called the
PATCH /api/v1/users/me/subscriptions endpoint, which is more like
an ad-hoc endpoint for bulk adding/removing subscriptions for the
user that makes the request. However, making a DELETE request
allows an admin to pass in the `principals` argument to unsubscribe
other users from streams as well, which is more consistent with how
add_subscriptions works.
This commit is contained in:
Eeshan Garg 2018-01-11 19:09:04 -03:30 committed by showell
parent da4b830571
commit 67cdb6f8f0

View file

@ -810,15 +810,18 @@ class Client(object):
request=request, request=request,
) )
def remove_subscriptions(self, streams): def remove_subscriptions(self, streams, principals=[]):
# type: (Iterable[str]) -> Dict[str, Any] # type: (Iterable[str], Optional[Iterable[str]]) -> Dict[str, Any]
''' '''
See examples/unsubscribe for example usage. See examples/unsubscribe for example usage.
''' '''
request = dict(delete=streams) request = dict(
subscriptions=streams,
principals=principals
)
return self.call_endpoint( return self.call_endpoint(
url='users/me/subscriptions', url='users/me/subscriptions',
method='PATCH', method='DELETE',
request=request, request=request,
) )