mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
do_update_message_flags: Accept a Client object.
This is important for upcoming logging changes.
This commit is contained in:
@@ -3614,6 +3614,7 @@ def do_mark_stream_messages_as_read(user_profile: UserProfile,
|
|||||||
return count
|
return count
|
||||||
|
|
||||||
def do_update_message_flags(user_profile: UserProfile,
|
def do_update_message_flags(user_profile: UserProfile,
|
||||||
|
client: Client,
|
||||||
operation: str,
|
operation: str,
|
||||||
flag: str,
|
flag: str,
|
||||||
messages: Optional[Sequence[int]]) -> int:
|
messages: Optional[Sequence[int]]) -> int:
|
||||||
|
|||||||
@@ -749,7 +749,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||||||
)
|
)
|
||||||
user_profile = self.example_user('hamlet')
|
user_profile = self.example_user('hamlet')
|
||||||
events = self.do_test(
|
events = self.do_test(
|
||||||
lambda: do_update_message_flags(user_profile, 'add', 'starred', [message]),
|
lambda: do_update_message_flags(user_profile, get_client("website"), 'add', 'starred', [message]),
|
||||||
state_change_expected=False,
|
state_change_expected=False,
|
||||||
)
|
)
|
||||||
error = schema_checker('events[0]', events[0])
|
error = schema_checker('events[0]', events[0])
|
||||||
@@ -762,7 +762,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||||||
('operation', equals("remove")),
|
('operation', equals("remove")),
|
||||||
])
|
])
|
||||||
events = self.do_test(
|
events = self.do_test(
|
||||||
lambda: do_update_message_flags(user_profile, 'remove', 'starred', [message]),
|
lambda: do_update_message_flags(user_profile, get_client("website"), 'remove', 'starred', [message]),
|
||||||
state_change_expected=False,
|
state_change_expected=False,
|
||||||
)
|
)
|
||||||
error = schema_checker('events[0]', events[0])
|
error = schema_checker('events[0]', events[0])
|
||||||
@@ -781,7 +781,7 @@ class EventsRegisterTest(ZulipTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
self.do_test(
|
self.do_test(
|
||||||
lambda: do_update_message_flags(user_profile, 'add', 'read', [message]),
|
lambda: do_update_message_flags(user_profile, get_client("website"), 'add', 'read', [message]),
|
||||||
state_change_expected=True,
|
state_change_expected=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -974,7 +974,7 @@ def update_message_flags(request: HttpRequest, user_profile: UserProfile,
|
|||||||
messages: List[int]=REQ(validator=check_list(check_int)),
|
messages: List[int]=REQ(validator=check_list(check_int)),
|
||||||
operation: str=REQ('op'), flag: str=REQ()) -> HttpResponse:
|
operation: str=REQ('op'), flag: str=REQ()) -> HttpResponse:
|
||||||
|
|
||||||
count = do_update_message_flags(user_profile, operation, flag, messages)
|
count = do_update_message_flags(user_profile, request.client, operation, flag, messages)
|
||||||
|
|
||||||
target_count_str = str(len(messages))
|
target_count_str = str(len(messages))
|
||||||
log_data_str = "[%s %s/%s] actually %s" % (operation, flag, target_count_str, count)
|
log_data_str = "[%s %s/%s] actually %s" % (operation, flag, target_count_str, count)
|
||||||
|
|||||||
Reference in New Issue
Block a user