refactor: Remove maybe_clear_subscribers().

The maybe_clear_subscribers() function was an artifact of
when we used to attach subscribers to the "sub" records in
stream_data.js.  I think it was basically a refactoring
shim, and due to some other recent cleanup, it was only
used in test code.

We also change how we validate stream ids.

Going forward, peer_data just looks up stream_ids with the
normal stream_data API when it's trying to warn about
rogue stream_ids coming in.  As I alluded to in an earlier
commit, some of the warning code here might be overly
defensive, but at least it's pretty self-contained.
This commit is contained in:
Steve Howell
2021-01-30 12:38:55 +00:00
committed by Tim Abbott
parent e44e48ef20
commit 58855e8224
4 changed files with 13 additions and 15 deletions

View File

@@ -972,6 +972,8 @@ run_test("warn_if_private_stream_is_linked", () => {
stream_id: 100,
name: "Denmark",
};
stream_data.add_sub(denmark);
peer_data.set_subscribers(denmark.stream_id, [1, 2, 3]);
function test_noop_case(invite_only) {

View File

@@ -240,7 +240,11 @@ run_test("get_subscriber_count", () => {
run_test("is_subscriber_subset", () => {
function make_sub(stream_id, user_ids) {
const sub = {stream_id};
const sub = {
stream_id,
name: `stream ${stream_id}`,
};
stream_data.add_sub(sub);
peer_data.set_subscribers(sub.stream_id, user_ids);
return sub;
}