search: Check if user can access stream topics before fetching history.

When building search suggestions for stream topics, instead of
assuming that the user has access to the stream's topic history
from the server, we check whether the user has access to the
stream's topics.
This commit is contained in:
Lauryn Menard
2022-10-18 19:01:58 +02:00
committed by Tim Abbott
parent c4823bfd03
commit cba8738eea
2 changed files with 20 additions and 11 deletions

View File

@@ -530,6 +530,13 @@ export function can_toggle_subscription(sub) {
);
}
export function can_access_topic_history(sub) {
// Anyone can access topic history for web-public streams and
// subscriptions; additionally, members can access history for
// public streams.
return sub.is_web_public || can_toggle_subscription(sub);
}
export function can_preview(sub) {
return sub.subscribed || !sub.invite_only || sub.previously_subscribed;
}