streams: Fix warning shown when unsubscribing from private stream.

We no longer archive the stream when private stream becomes
vacant, so removed that part from the warning.

When a private stream becomes vacant, everyone in the organization
can lose content access to it if no one has permission to subscribe
themselves or others to the stream. So, the warning is updated to
mention this.
This commit is contained in:
Sahil Batra
2025-04-14 09:20:13 +05:30
committed by Tim Abbott
parent 51dab09c69
commit d3c06234e2
4 changed files with 25 additions and 14 deletions

View File

@@ -352,7 +352,10 @@ function remove_subscriber({
const html_body = render_unsubscribe_private_stream_modal({
unsubscribing_other_user,
display_stream_archive_warning: sub_count === 1,
organization_will_lose_content_access:
sub_count === 1 &&
user_groups.is_setting_group_set_to_nobody_group(sub.can_subscribe_group) &&
user_groups.is_setting_group_set_to_nobody_group(sub.can_add_subscribers_group),
});
let html_heading;

View File

@@ -19,6 +19,7 @@ import * as stream_data from "./stream_data.ts";
import * as stream_settings_data from "./stream_settings_data.ts";
import type {StreamSubscription} from "./sub_store.ts";
import * as ui_report from "./ui_report.ts";
import * as user_groups from "./user_groups.ts";
export let filter_dropdown_widget: DropdownWidget;
@@ -228,7 +229,11 @@ export function unsubscribe_from_private_stream(sub: StreamSubscription): void {
const html_body = render_unsubscribe_private_stream_modal({
unsubscribing_other_user: false,
display_stream_archive_warning: sub_count === 1 && invite_only,
organization_will_lose_content_access:
sub_count === 1 &&
invite_only &&
user_groups.is_setting_group_set_to_nobody_group(sub.can_subscribe_group) &&
user_groups.is_setting_group_set_to_nobody_group(sub.can_add_subscribers_group),
});
function unsubscribe_from_stream(): void {

View File

@@ -305,6 +305,19 @@ export function is_setting_group_empty(setting_group: GroupSettingValue): boolea
return true;
}
export function is_setting_group_set_to_nobody_group(setting_group: GroupSettingValue): boolean {
if (typeof setting_group === "number") {
const user_group = get_user_group_from_id(setting_group);
if (user_group.name === "role:nobody") {
return true;
}
return false;
}
return setting_group.direct_subgroups.length === 0 && setting_group.direct_members.length === 0;
}
export function get_user_groups_of_user(
user_id: number,
include_deactivated_groups = false,

View File

@@ -1,18 +1,8 @@
{{#unless unsubscribing_other_user}}
<p>{{t "Once you leave this channel, you will not be able to rejoin."}}</p>
{{/unless}}
{{#if display_stream_archive_warning}}
{{#if organization_will_lose_content_access}}
<p>
{{#if unsubscribing_other_user}}
{{#tr}}
Because you are removing the last subscriber from a private channel, it will be automatically <z-link>archived</z-link>.
{{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-channel">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{else}}
{{#tr}}
Because you are the only subscriber, this channel will be automatically <z-link>archived</z-link>.
{{#*inline "z-link"}}<a target="_blank" rel="noopener noreferrer" href="/help/archive-a-channel">{{> @partial-block}}</a>{{/inline}}
{{/tr}}
{{/if}}
{{t "Your organization will lose access content in this channel, and nobody will be able to subscribe to it in the future."}}
</p>
{{/if}}