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:
Kislay Verma
2025-04-05 19:53:19 +05:30
committed by Tim Abbott
parent 5b5be39b19
commit e2e0603689
11 changed files with 137 additions and 12 deletions

View File

@@ -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()