mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
streams: Add API endpoint to get stream email.
This commit adds new API endpoint to get stream email which is used by the web-app as well to get the email when a user tries to open the stream email modal. The stream email is returned only to the users who have access to it. Specifically for private streams only subscribed users have access to its email. And for public streams, all non-guest users and only subscribed guests have access to its email. All users can access email of web-public streams.
This commit is contained in:
committed by
Alex Vandiver
parent
0a3800332f
commit
6e119842bd
@@ -47,6 +47,7 @@ from zerver.decorator import (
|
||||
require_post,
|
||||
require_realm_admin,
|
||||
)
|
||||
from zerver.lib.email_mirror_helpers import encode_email_address
|
||||
from zerver.lib.exceptions import (
|
||||
ErrorCode,
|
||||
JsonableError,
|
||||
@@ -1073,3 +1074,18 @@ def update_subscription_properties_backend(
|
||||
)
|
||||
|
||||
return json_success(request)
|
||||
|
||||
|
||||
@has_request_variables
|
||||
def get_stream_email_address(
|
||||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
stream_id: int = REQ("stream", converter=to_non_negative_int, path_only=True),
|
||||
) -> HttpResponse:
|
||||
(stream, sub) = access_stream_by_id(
|
||||
user_profile,
|
||||
stream_id,
|
||||
)
|
||||
stream_email = encode_email_address(stream, show_sender=True)
|
||||
|
||||
return json_success(request, data={"email": stream_email})
|
||||
|
||||
Reference in New Issue
Block a user