stream_data: Get is_invite_only by stream_id instead of name.

This commit is contained in:
evykassirer 2023-08-05 15:00:41 -07:00 committed by Tim Abbott
parent 8e33b7a3a7
commit 45af8a9406
3 changed files with 8 additions and 5 deletions

View File

@ -190,7 +190,9 @@ function populate_group_from_message_container(group, message_container) {
const color = stream_data.get_color(message_container.msg.stream_id); const color = stream_data.get_color(message_container.msg.stream_id);
group.recipient_bar_color = stream_color.get_recipient_bar_color(color); group.recipient_bar_color = stream_color.get_recipient_bar_color(color);
group.stream_privacy_icon_color = stream_color.get_stream_privacy_icon_color(color); group.stream_privacy_icon_color = stream_color.get_stream_privacy_icon_color(color);
group.invite_only = stream_data.is_invite_only_by_stream_name(message_container.msg.stream); group.invite_only = stream_data.is_invite_only_by_stream_id(
message_container.msg.stream_id,
);
group.is_web_public = stream_data.is_web_public(message_container.msg.stream_id); group.is_web_public = stream_data.is_web_public(message_container.msg.stream_id);
group.topic = message_container.msg.topic; group.topic = message_container.msg.topic;
group.match_topic = util.get_match_topic(message_container.msg); group.match_topic = util.get_match_topic(message_container.msg);

View File

@ -679,8 +679,8 @@ export function is_web_public(stream_id: number): boolean {
return sub ? sub.is_web_public : false; return sub ? sub.is_web_public : false;
} }
export function is_invite_only_by_stream_name(stream_name: string): boolean { export function is_invite_only_by_stream_id(stream_id: number): boolean {
const sub = get_sub(stream_name); const sub = get_sub_by_id(stream_id);
if (sub === undefined) { if (sub === undefined) {
return false; return false;
} }

View File

@ -133,8 +133,9 @@ test("basics", () => {
assert.ok(!stream_data.is_web_public_by_stream_name(social.name)); assert.ok(!stream_data.is_web_public_by_stream_name(social.name));
assert.ok(!stream_data.is_web_public_by_stream_name("unknown")); assert.ok(!stream_data.is_web_public_by_stream_name("unknown"));
assert.ok(stream_data.is_invite_only_by_stream_name("social")); assert.ok(stream_data.is_invite_only_by_stream_id(social.stream_id));
assert.ok(!stream_data.is_invite_only_by_stream_name("unknown")); // Unknown stream id
assert.ok(!stream_data.is_invite_only_by_stream_id(1000));
assert.equal(stream_data.get_color(social.stream_id), "red"); assert.equal(stream_data.get_color(social.stream_id), "red");
assert.equal(stream_data.get_color(""), "#c2c2c2"); assert.equal(stream_data.get_color(""), "#c2c2c2");