mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 03:41:58 +00:00
actions: Remove acting_client parameter from bulk_remove_subscriptions.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
0b795e492f
commit
0d061f44c1
@@ -4061,7 +4061,6 @@ SubAndRemovedT = Tuple[List[Tuple[UserProfile, Stream]], List[Tuple[UserProfile,
|
||||
def bulk_remove_subscriptions(
|
||||
users: Iterable[UserProfile],
|
||||
streams: Iterable[Stream],
|
||||
acting_client: Client,
|
||||
*,
|
||||
acting_user: Optional[UserProfile],
|
||||
) -> SubAndRemovedT:
|
||||
|
||||
@@ -88,7 +88,6 @@ from zerver.models import (
|
||||
UserProfile,
|
||||
clear_supported_auth_backends_cache,
|
||||
flush_per_request_caches,
|
||||
get_client,
|
||||
get_display_recipient,
|
||||
get_realm,
|
||||
get_realm_stream,
|
||||
@@ -1003,9 +1002,8 @@ Output:
|
||||
return stream
|
||||
|
||||
def unsubscribe(self, user_profile: UserProfile, stream_name: str) -> None:
|
||||
client = get_client("website")
|
||||
stream = get_stream(stream_name, user_profile.realm)
|
||||
bulk_remove_subscriptions([user_profile], [stream], client, acting_user=None)
|
||||
bulk_remove_subscriptions([user_profile], [stream], acting_user=None)
|
||||
|
||||
# Subscribe to a stream by making an API request
|
||||
def common_subscribe_to_streams(
|
||||
|
||||
@@ -76,7 +76,6 @@ class Command(ZulipBaseCommand):
|
||||
bulk_remove_subscriptions(
|
||||
[sub.user_profile for sub in subs_to_deactivate],
|
||||
[stream_to_destroy],
|
||||
self.get_client(),
|
||||
acting_user=None,
|
||||
)
|
||||
do_deactivate_stream(stream_to_destroy, acting_user=None)
|
||||
|
||||
@@ -25,9 +25,7 @@ class Command(ZulipBaseCommand):
|
||||
stream_name = options["stream"].strip()
|
||||
stream = get_stream(stream_name, realm)
|
||||
|
||||
result = bulk_remove_subscriptions(
|
||||
user_profiles, [stream], self.get_client(), acting_user=None
|
||||
)
|
||||
result = bulk_remove_subscriptions(user_profiles, [stream], acting_user=None)
|
||||
not_subscribed = result[1]
|
||||
not_subscribed_users = {tup[0] for tup in not_subscribed}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ from zerver.models import (
|
||||
Recipient,
|
||||
Subscription,
|
||||
UserProfile,
|
||||
get_client,
|
||||
get_realm,
|
||||
get_stream,
|
||||
)
|
||||
@@ -294,7 +293,7 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||
self.assertEqual(modified_stream.id, stream.id)
|
||||
self.assertEqual(subscription_creation_logs[0].modified_user, user)
|
||||
|
||||
bulk_remove_subscriptions([user], [stream], get_client("website"), acting_user=acting_user)
|
||||
bulk_remove_subscriptions([user], [stream], acting_user=acting_user)
|
||||
subscription_deactivation_logs = RealmAuditLog.objects.filter(
|
||||
event_type=RealmAuditLog.SUBSCRIPTION_DEACTIVATED,
|
||||
event_time__gte=now,
|
||||
|
||||
@@ -1808,7 +1808,7 @@ class NormalActionsTest(BaseAction):
|
||||
stream = get_stream("test_stream", self.user_profile.realm)
|
||||
|
||||
action = lambda: bulk_remove_subscriptions(
|
||||
[self.example_user("othello")], [stream], get_client("website"), acting_user=None
|
||||
[self.example_user("othello")], [stream], acting_user=None
|
||||
)
|
||||
events = self.verify_action(action)
|
||||
check_subscription_peer_remove("events[0]", events[0])
|
||||
@@ -2252,7 +2252,7 @@ class SubscribeActionTest(BaseAction):
|
||||
# Now remove the first user, to test the normal unsubscribe flow and
|
||||
# 'peer_remove' event for subscribed streams.
|
||||
action = lambda: bulk_remove_subscriptions(
|
||||
[self.example_user("othello")], [stream], get_client("website"), acting_user=None
|
||||
[self.example_user("othello")], [stream], acting_user=None
|
||||
)
|
||||
events = self.verify_action(
|
||||
action,
|
||||
@@ -2263,7 +2263,7 @@ class SubscribeActionTest(BaseAction):
|
||||
|
||||
# Now remove the user himself, to test the 'remove' event flow
|
||||
action = lambda: bulk_remove_subscriptions(
|
||||
[self.example_user("hamlet")], [stream], get_client("website"), acting_user=None
|
||||
[self.example_user("hamlet")], [stream], acting_user=None
|
||||
)
|
||||
events = self.verify_action(
|
||||
action, include_subscribers=include_subscribers, include_streams=False, num_events=2
|
||||
@@ -2287,7 +2287,7 @@ class SubscribeActionTest(BaseAction):
|
||||
|
||||
# Remove the user to test 'peer_remove' event flow for unsubscribed stream.
|
||||
action = lambda: bulk_remove_subscriptions(
|
||||
[self.example_user("iago")], [stream], get_client("website"), acting_user=None
|
||||
[self.example_user("iago")], [stream], acting_user=None
|
||||
)
|
||||
events = self.verify_action(
|
||||
action,
|
||||
|
||||
@@ -79,7 +79,6 @@ from zerver.models import (
|
||||
UserProfile,
|
||||
active_non_guest_user_ids,
|
||||
flush_per_request_caches,
|
||||
get_client,
|
||||
get_default_stream_groups,
|
||||
get_realm,
|
||||
get_stream,
|
||||
@@ -3679,12 +3678,11 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
bulk_remove_subscriptions(
|
||||
[user1, user2],
|
||||
[stream1, stream2, stream3, private],
|
||||
get_client("website"),
|
||||
acting_user=None,
|
||||
)
|
||||
|
||||
self.assert_length(query_count, 28)
|
||||
self.assert_length(cache_count, 4)
|
||||
self.assert_length(query_count, 27)
|
||||
self.assert_length(cache_count, 3)
|
||||
|
||||
peer_events = [e for e in events if e["event"].get("op") == "peer_remove"]
|
||||
|
||||
@@ -3747,7 +3745,6 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
bulk_remove_subscriptions(
|
||||
users=[mit_user],
|
||||
streams=streams,
|
||||
acting_client=get_client("website"),
|
||||
acting_user=None,
|
||||
)
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ from zerver.lib.exceptions import (
|
||||
OrganizationOwnerRequired,
|
||||
ResourceNotFoundError,
|
||||
)
|
||||
from zerver.lib.request import REQ, get_request_notes, has_request_variables
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
from zerver.lib.response import json_success
|
||||
from zerver.lib.retention import parse_message_retention_days
|
||||
from zerver.lib.streams import (
|
||||
@@ -405,10 +405,8 @@ def remove_subscriptions_backend(
|
||||
people_to_unsub = {user_profile}
|
||||
|
||||
result: Dict[str, List[str]] = dict(removed=[], not_removed=[])
|
||||
client = get_request_notes(request).client
|
||||
assert client is not None
|
||||
(removed, not_subscribed) = bulk_remove_subscriptions(
|
||||
people_to_unsub, streams, client, acting_user=user_profile
|
||||
people_to_unsub, streams, acting_user=user_profile
|
||||
)
|
||||
|
||||
for (subscriber, removed_stream) in removed:
|
||||
|
||||
Reference in New Issue
Block a user