Skip to content

Commit 6812864

Browse files
andersktimabbott
authored andcommitted
zulip: Fix principals default for remove_subscriptions.
The documented API for DELETE /api/v1/users/me/subscriptions is that principals should be omitted to remove a subscription for the calling user. A call with principals=[] should have a different meaning, but a server bug currently conflates this with a call omitting principals. Avoid relying on this bug. Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 70b8661 commit 6812864

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

zulip/zulip/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1383,12 +1383,16 @@ def add_subscriptions(self, streams: Iterable[Dict[str, Any]], **kwargs: Any) ->
13831383
)
13841384

13851385
def remove_subscriptions(
1386-
self, streams: Iterable[str], principals: Union[Sequence[str], Sequence[int]] = []
1386+
self,
1387+
streams: Iterable[str],
1388+
principals: Optional[Union[Sequence[str], Sequence[int]]] = None,
13871389
) -> Dict[str, Any]:
13881390
"""
13891391
See examples/unsubscribe for example usage.
13901392
"""
1391-
request = dict(subscriptions=streams, principals=principals)
1393+
request: Dict[str, object] = dict(subscriptions=streams)
1394+
if principals is not None:
1395+
request["principals"] = principals
13921396
return self.call_endpoint(
13931397
url="users/me/subscriptions",
13941398
method="DELETE",

0 commit comments

Comments
 (0)