Repository: zulip/zulip

Issue:
Rename not_subscribed key to not_removed in users/me/subscriptions DELETE response
The response that would be generated when someone try to remove a user that is not subscribed to a stream is this.

```
{
    "msg": "",
    "not_subscribed": [
        "new stream"
    ],
    "removed": []
    "result": "success"
}
```

`not_subscribed` should be renamed to `not_removed` since that makes more sense.

http://zulip.zulipdev.com:9991/api/remove-subscriptions

This should be an easy easy issue to work.


Discussion:
Hello @zulip/server-api members, this issue was labeled with the "area: api", "area: documentation (api and integrations)" labels, so you may want to check it out!

<!-- areaLabelAddition -->
Hmm, yeah, good catch.  I guess one can tell by the fact we're just discovering this that nothing is actually processing that strong, so we should aim to fix this soon so that API callers that do eventually need this API don't have to deal with the old version.
@zulipbot assign
oh, I forgot... :P @zulipbot claim

Resolving patch:
diff --git a/zerver/views/streams.py b/zerver/views/streams.py
--- a/zerver/views/streams.py
+++ b/zerver/views/streams.py
@@ -257,7 +257,7 @@ def remove_subscriptions_backend(
     else:
         people_to_unsub = set([user_profile])
 
-    result = dict(removed=[], not_subscribed=[])  # type: Dict[str, List[str]]
+    result = dict(removed=[], not_removed=[])  # type: Dict[str, List[str]]
     (removed, not_subscribed) = bulk_remove_subscriptions(people_to_unsub, streams,
                                                           request.client,
                                                           acting_user=user_profile)
@@ -265,7 +265,7 @@ def remove_subscriptions_backend(
     for (subscriber, removed_stream) in removed:
         result["removed"].append(removed_stream.name)
     for (subscriber, not_subscribed_stream) in not_subscribed:
-        result["not_subscribed"].append(not_subscribed_stream.name)
+        result["not_removed"].append(not_subscribed_stream.name)
 
     return json_success(result)
 


Test patch:
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py
--- a/zerver/tests/test_docs.py
+++ b/zerver/tests/test_docs.py
@@ -126,7 +126,7 @@ def test_doc_endpoints(self) -> None:
         self._test('/api/get-profile', 'takes no arguments')
         self._test('/api/add-subscriptions', 'authorization_errors_fatal')
         self._test('/api/create-user', 'zuliprc-admin')
-        self._test('/api/remove-subscriptions', 'not_subscribed')
+        self._test('/api/remove-subscriptions', 'not_removed')
         self._test('/team/', 'industry veterans')
         self._test('/history/', 'Cambridge, Massachusetts')
         # Test the i18n version of one of these pages.
diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py
--- a/zerver/tests/test_subs.py
+++ b/zerver/tests/test_subs.py
@@ -991,7 +991,7 @@ def test_admin_remove_others_from_public_stream(self) -> None:
             other_user_subbed=True)
         json = self.assert_json_success(result)
         self.assertEqual(len(json["removed"]), 1)
-        self.assertEqual(len(json["not_subscribed"]), 0)
+        self.assertEqual(len(json["not_removed"]), 0)
 
     def test_admin_remove_others_from_subbed_private_stream(self) -> None:
         """
@@ -1003,7 +1003,7 @@ def test_admin_remove_others_from_subbed_private_stream(self) -> None:
             other_user_subbed=True)
         json = self.assert_json_success(result)
         self.assertEqual(len(json["removed"]), 1)
-        self.assertEqual(len(json["not_subscribed"]), 0)
+        self.assertEqual(len(json["not_removed"]), 0)
 
     def test_admin_remove_others_from_unsubbed_private_stream(self) -> None:
         """
@@ -1015,7 +1015,7 @@ def test_admin_remove_others_from_unsubbed_private_stream(self) -> None:
             other_user_subbed=True, other_sub_users=[self.example_user("othello")])
         json = self.assert_json_success(result)
         self.assertEqual(len(json["removed"]), 1)
-        self.assertEqual(len(json["not_subscribed"]), 0)
+        self.assertEqual(len(json["not_removed"]), 0)
 
     def test_create_stream_policy_setting(self) -> None:
         """
@@ -1155,7 +1155,7 @@ def test_remove_already_not_subbed(self) -> None:
             other_user_subbed=False)
         json = self.assert_json_success(result)
         self.assertEqual(len(json["removed"]), 0)
-        self.assertEqual(len(json["not_subscribed"]), 1)
+        self.assertEqual(len(json["not_removed"]), 1)
 
     def test_remove_invalid_user(self) -> None:
         """
@@ -2839,7 +2839,7 @@ def helper_check_subs_before_and_after_remove(self, subscriptions: List[str],
 
         {"msg": "",
          "removed": ["Denmark", "Scotland", "Verona"],
-         "not_subscribed": ["Rome"], "result": "success"}
+         "not_removed": ["Rome"], "result": "success"}
         """
         result = self.client_delete("/json/users/me/subscriptions",
                                     {"subscriptions": ujson.dumps(subscriptions)})
@@ -2868,7 +2868,7 @@ def test_successful_subscriptions_remove(self) -> None:
         try_to_remove = not_subbed[:3]  # attempt to remove up to 3 streams not already subbed to
         streams_to_remove.extend(try_to_remove)
         self.helper_check_subs_before_and_after_remove(streams_to_remove,
-                                                       {"removed": self.streams[1:], "not_subscribed": try_to_remove},
+                                                       {"removed": self.streams[1:], "not_removed": try_to_remove},
                                                        self.test_email, [self.streams[0]], self.test_realm)
 
     def test_subscriptions_remove_fake_stream(self) -> None: