mirror of https://github.com/zulip/zulip.git
message: Refactor code for parsing message time limit settings.
This commit renames parse_message_content_edit_or_delete_limit to parse_message_time_limit_setting and also renames MESSAGE_CONTENT_EDIT_OR_DELETE_LIMIT_SPECIAL_VALUES_MAP to MESSAGE_TIME_LIMIT_SETTING_SPECIAL_VALUES_MAP. We do this change since this function and object will also be used for message move limit and it makes sense to have a more generic name.
This commit is contained in:
parent
1a656d2e23
commit
5b1f6a696e
|
@ -15,10 +15,7 @@ from zerver.actions.user_groups import update_users_in_full_members_system_group
|
|||
from zerver.actions.user_settings import do_delete_avatar_image, send_user_email_update_event
|
||||
from zerver.lib.cache import flush_user_profile
|
||||
from zerver.lib.create_user import get_display_email_address
|
||||
from zerver.lib.message import (
|
||||
parse_message_content_edit_or_delete_limit,
|
||||
update_first_visible_message_id,
|
||||
)
|
||||
from zerver.lib.message import parse_message_time_limit_setting, update_first_visible_message_id
|
||||
from zerver.lib.send_email import FromAddress, send_email_to_admins
|
||||
from zerver.lib.sessions import delete_user_sessions
|
||||
from zerver.lib.user_counts import realm_user_count_by_role
|
||||
|
@ -124,9 +121,9 @@ def do_set_realm_property(
|
|||
def parse_and_set_setting_value_if_required(
|
||||
realm: Realm, setting_name: str, value: Union[int, str], *, acting_user: Optional[UserProfile]
|
||||
) -> Tuple[Optional[int], bool]:
|
||||
parsed_value = parse_message_content_edit_or_delete_limit(
|
||||
parsed_value = parse_message_time_limit_setting(
|
||||
value,
|
||||
Realm.MESSAGE_CONTENT_EDIT_OR_DELETE_LIMIT_SPECIAL_VALUES_MAP,
|
||||
Realm.MESSAGE_TIME_LIMIT_SETTING_SPECIAL_VALUES_MAP,
|
||||
setting_name=setting_name,
|
||||
)
|
||||
|
||||
|
|
|
@ -1614,7 +1614,7 @@ def wildcard_mention_allowed(sender: UserProfile, stream: Stream) -> bool:
|
|||
raise AssertionError("Invalid wildcard mention policy")
|
||||
|
||||
|
||||
def parse_message_content_edit_or_delete_limit(
|
||||
def parse_message_time_limit_setting(
|
||||
value: Union[int, str],
|
||||
special_values_map: Mapping[str, Optional[int]],
|
||||
*,
|
||||
|
|
|
@ -464,7 +464,7 @@ class Realm(models.Model): # type: ignore[django-manager-missing] # django-stub
|
|||
DEFAULT_MESSAGE_CONTENT_DELETE_LIMIT_SECONDS = (
|
||||
600 # if changed, also change in admin.js, setting_org.js
|
||||
)
|
||||
MESSAGE_CONTENT_EDIT_OR_DELETE_LIMIT_SPECIAL_VALUES_MAP = {
|
||||
MESSAGE_TIME_LIMIT_SETTING_SPECIAL_VALUES_MAP = {
|
||||
"unlimited": None,
|
||||
}
|
||||
message_content_delete_limit_seconds = models.PositiveIntegerField(
|
||||
|
|
Loading…
Reference in New Issue