mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 04:53:36 +00:00
attachments: Add is_web_public field.
This commit adds the is_web_public field in the AbstractAttachment class. This is useful when validating user access to the attachment, as otherwise we would have to make a query in the db to check if that attachment was sent in a message in a web-public stream or not.
This commit is contained in:
@@ -879,9 +879,11 @@ def upload_message_file(uploaded_file_name: str, uploaded_file_size: int,
|
||||
def claim_attachment(user_profile: UserProfile,
|
||||
path_id: str,
|
||||
message: Message,
|
||||
is_message_realm_public: bool) -> Attachment:
|
||||
is_message_realm_public: bool,
|
||||
is_message_web_public: bool=False) -> Attachment:
|
||||
attachment = Attachment.objects.get(path_id=path_id)
|
||||
attachment.messages.add(message)
|
||||
attachment.is_web_public = attachment.is_web_public or is_message_web_public
|
||||
attachment.is_realm_public = attachment.is_realm_public or is_message_realm_public
|
||||
attachment.save()
|
||||
return attachment
|
||||
|
||||
Reference in New Issue
Block a user