mirror of
https://github.com/zulip/zulip.git
synced 2025-11-14 10:57:58 +00:00
message_edit: Check previous message content to prevent races.
Similar to group based setting values, we expect the client to send the previous content alongwith the edited content to the edit message endpoint. We reject the request incase the previous content doesn't match the current message content, which could happen in case two users simultaneously edit a message - which will be implemented in #33051.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import hashlib
|
||||
import re
|
||||
import secrets
|
||||
from collections.abc import Callable
|
||||
@@ -68,3 +69,7 @@ def get_fk_field_name(model: type[models.Model], related_model: type[models.Mode
|
||||
assert len(foreign_key_fields_to_related_model) == 1
|
||||
|
||||
return foreign_key_fields_to_related_model[0].name
|
||||
|
||||
|
||||
def sha256_hash(text: str) -> str:
|
||||
return hashlib.sha256(text.encode()).hexdigest()
|
||||
|
||||
Reference in New Issue
Block a user