mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
streams: Remove API support for changing stream_post_policy.
This commit is contained in:
@@ -1355,82 +1355,6 @@ def send_stream_posting_permission_update_notification(
|
||||
)
|
||||
|
||||
|
||||
def send_change_stream_post_policy_notification(
|
||||
stream: Stream, *, old_post_policy: int, new_post_policy: int, acting_user: UserProfile
|
||||
) -> None:
|
||||
sender = get_system_bot(settings.NOTIFICATION_BOT, acting_user.realm_id)
|
||||
user_mention = silent_mention_syntax_for_user(acting_user)
|
||||
|
||||
with override_language(stream.realm.default_language):
|
||||
notification_string = _(
|
||||
"{user} changed the [posting permissions]({help_link}) "
|
||||
"for this channel:\n\n"
|
||||
"* **Old permissions**: {old_policy}.\n"
|
||||
"* **New permissions**: {new_policy}.\n"
|
||||
)
|
||||
notification_string = notification_string.format(
|
||||
user=user_mention,
|
||||
help_link="/help/channel-posting-policy",
|
||||
old_policy=Stream.POST_POLICIES[old_post_policy],
|
||||
new_policy=Stream.POST_POLICIES[new_post_policy],
|
||||
)
|
||||
internal_send_stream_message(
|
||||
sender, stream, str(Realm.STREAM_EVENTS_NOTIFICATION_TOPIC_NAME), notification_string
|
||||
)
|
||||
|
||||
|
||||
@transaction.atomic(durable=True)
|
||||
def do_change_stream_post_policy(
|
||||
stream: Stream, stream_post_policy: int, *, acting_user: UserProfile
|
||||
) -> None:
|
||||
old_post_policy = stream.stream_post_policy
|
||||
stream.stream_post_policy = stream_post_policy
|
||||
stream.save(update_fields=["stream_post_policy"])
|
||||
RealmAuditLog.objects.create(
|
||||
realm=stream.realm,
|
||||
acting_user=acting_user,
|
||||
modified_stream=stream,
|
||||
event_type=AuditLogEventType.CHANNEL_PROPERTY_CHANGED,
|
||||
event_time=timezone_now(),
|
||||
extra_data={
|
||||
RealmAuditLog.OLD_VALUE: old_post_policy,
|
||||
RealmAuditLog.NEW_VALUE: stream_post_policy,
|
||||
"property": "stream_post_policy",
|
||||
},
|
||||
)
|
||||
|
||||
event = dict(
|
||||
op="update",
|
||||
type="stream",
|
||||
property="stream_post_policy",
|
||||
value=stream_post_policy,
|
||||
stream_id=stream.id,
|
||||
name=stream.name,
|
||||
)
|
||||
send_event_on_commit(stream.realm, event, can_access_stream_user_ids(stream))
|
||||
|
||||
# Backwards-compatibility code: We removed the
|
||||
# is_announcement_only property in early 2020, but we send a
|
||||
# duplicate event for legacy mobile clients that might want the
|
||||
# data.
|
||||
event = dict(
|
||||
op="update",
|
||||
type="stream",
|
||||
property="is_announcement_only",
|
||||
value=stream.stream_post_policy == Stream.STREAM_POST_POLICY_ADMINS,
|
||||
stream_id=stream.id,
|
||||
name=stream.name,
|
||||
)
|
||||
send_event_on_commit(stream.realm, event, can_access_stream_user_ids(stream))
|
||||
|
||||
send_change_stream_post_policy_notification(
|
||||
stream,
|
||||
old_post_policy=old_post_policy,
|
||||
new_post_policy=stream_post_policy,
|
||||
acting_user=acting_user,
|
||||
)
|
||||
|
||||
|
||||
@transaction.atomic(durable=True)
|
||||
def do_rename_stream(stream: Stream, new_name: str, user_profile: UserProfile) -> None:
|
||||
old_name = stream.name
|
||||
|
||||
Reference in New Issue
Block a user