unread: Remove unused client parameter.

This commit is contained in:
Steve Howell 2022-03-10 13:30:45 +00:00 committed by Steve Howell
parent c2f2863d37
commit a90d9ef536
5 changed files with 10 additions and 21 deletions

View File

@ -1431,8 +1431,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
self.subscribe(user2, stream.name)
self.send_personal_message(user1, user2)
client = get_client("website")
do_mark_all_as_read(user2, client)
do_mark_all_as_read(user2)
self.assertEqual(
1,
UserCount.objects.filter(property=read_count_property).aggregate(Sum("value"))[
@ -1463,7 +1462,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
)
message = self.send_stream_message(user2, stream.name)
do_update_message_flags(user1, client, "add", "read", [message])
do_update_message_flags(user1, "add", "read", [message])
self.assertEqual(
4,
UserCount.objects.filter(property=read_count_property).aggregate(Sum("value"))[

View File

@ -6151,7 +6151,7 @@ class ReadMessagesEvent:
flag: str = field(default="read", init=False)
def do_mark_all_as_read(user_profile: UserProfile, client: Client) -> int:
def do_mark_all_as_read(user_profile: UserProfile) -> int:
log_statsd_event("bankruptcy")
# First, we clear mobile push notifications. This is safer in the
@ -6346,7 +6346,7 @@ def do_clear_mobile_push_notifications_for_ids(
def do_update_message_flags(
user_profile: UserProfile, client: Client, operation: str, flag: str, messages: List[int]
user_profile: UserProfile, operation: str, flag: str, messages: List[int]
) -> int:
valid_flags = [item for item in UserMessage.flags if item not in UserMessage.NON_API_FLAGS]
if flag not in valid_flags:

View File

@ -625,17 +625,13 @@ class NormalActionsTest(BaseAction):
)
user_profile = self.example_user("hamlet")
events = self.verify_action(
lambda: do_update_message_flags(
user_profile, get_client("website"), "add", "starred", [message]
),
lambda: do_update_message_flags(user_profile, "add", "starred", [message]),
state_change_expected=True,
)
check_update_message_flags_add("events[0]", events[0])
events = self.verify_action(
lambda: do_update_message_flags(
user_profile, get_client("website"), "remove", "starred", [message]
),
lambda: do_update_message_flags(user_profile, "remove", "starred", [message]),
state_change_expected=True,
)
check_update_message_flags_remove("events[0]", events[0])
@ -653,9 +649,7 @@ class NormalActionsTest(BaseAction):
)
self.verify_action(
lambda: do_update_message_flags(
user_profile, get_client("website"), "add", "read", [message]
),
lambda: do_update_message_flags(user_profile, "add", "read", [message]),
state_change_expected=True,
)

View File

@ -1638,9 +1638,7 @@ class TestAPNs(PushNotificationTest):
# Mark the messages as read and test whether
# the count decreases correctly.
for i, message_id in enumerate(message_ids):
do_update_message_flags(
user_profile, get_client("website"), "add", "read", [message_id]
)
do_update_message_flags(user_profile, "add", "read", [message_id])
self.assertEqual(get_apns_badge_count(user_profile), 0)
self.assertEqual(get_apns_badge_count_future(user_profile), num_messages - i - 1)

View File

@ -36,10 +36,9 @@ def update_message_flags(
flag: str = REQ(),
) -> HttpResponse:
request_notes = RequestNotes.get_notes(request)
assert request_notes.client is not None
assert request_notes.log_data is not None
count = do_update_message_flags(user_profile, request_notes.client, operation, flag, messages)
count = do_update_message_flags(user_profile, operation, flag, messages)
target_count_str = str(len(messages))
log_data_str = f"[{operation} {flag}/{target_count_str}] actually {count}"
@ -51,8 +50,7 @@ def update_message_flags(
@has_request_variables
def mark_all_as_read(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
request_notes = RequestNotes.get_notes(request)
assert request_notes.client is not None
count = do_mark_all_as_read(user_profile, request_notes.client)
count = do_mark_all_as_read(user_profile)
log_data_str = f"[{count} updated]"
assert request_notes.log_data is not None