mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
markdown: Fix stream description with topic permalink not rendered.
Previously, when description for a channel -- either during its creating or when we change its description contained a topic permalink (through #-mention), then it was not rendered. This is because of lack of authorization to access the channel. This is fixed by passing the acting_user through the methods which update or add the description, so that permissions of the acting_user could be used to determine whether to render the #-mention in stream description or not.
This commit is contained in:
@@ -128,10 +128,14 @@ def get_default_value_for_history_public_to_subscribers(
|
||||
return history_public_to_subscribers
|
||||
|
||||
|
||||
def render_stream_description(text: str, realm: Realm) -> str:
|
||||
def render_stream_description(
|
||||
text: str, realm: Realm, *, acting_user: UserProfile | None = None
|
||||
) -> str:
|
||||
from zerver.lib.markdown import markdown_convert
|
||||
|
||||
return markdown_convert(text, message_realm=realm, no_previews=True).rendered_content
|
||||
return markdown_convert(
|
||||
text, message_realm=realm, no_previews=True, acting_user=acting_user
|
||||
).rendered_content
|
||||
|
||||
|
||||
def send_stream_creation_event(
|
||||
@@ -258,7 +262,9 @@ def create_stream_if_needed(
|
||||
recipient = Recipient.objects.create(type_id=stream.id, type=Recipient.STREAM)
|
||||
|
||||
stream.recipient = recipient
|
||||
stream.rendered_description = render_stream_description(stream_description, realm)
|
||||
stream.rendered_description = render_stream_description(
|
||||
stream_description, realm, acting_user=acting_user
|
||||
)
|
||||
stream.save(update_fields=["recipient", "rendered_description"])
|
||||
|
||||
event_time = timezone_now()
|
||||
|
||||
Reference in New Issue
Block a user