events: Stop sending occupy/vacate events.

We used to send occupy/vacate events when
either the first person entered a stream
or the last person exited.

It appears that our two main apps have never
looked at these events.  Instead, it's
generally the case that clients handle
events related to stream creation/deactivation
and subscribe/unsubscribe.

Note that we removed the apply_events code
related to these events.  This doesn't affect
the webapp, because the webapp doesn't care
about the "streams" field in do_events_register.

There is a theoretical situation where a
third party client could be the victim of
a race where the "streams" data includes
a stream where the last subscriber has left.
I suspect in most of those situations it
will be harmless, or possibly even helpful
to the extent that they'll learn about
streams that are in a "quasi" state where
they're activated but not occupied.

We could try to patch apply_event to
detect when subscriptions get added
or removed. Or we could just make the
"streams" piece of do_events_register
not care about occupy/vacate semantics.
I favor the latter, since it might
actually be what users what, and it will
also simplify the code and improve
performance.
This commit is contained in:
Steve Howell
2020-10-14 11:48:24 +00:00
committed by Tim Abbott
parent 1bcb8d8ee8
commit a9356508ca
8 changed files with 26 additions and 150 deletions

View File

@@ -87,7 +87,7 @@ def create_integration_stream(integration: WebhookIntegration, bot: UserProfile)
assert isinstance(bot.bot_owner, UserProfile)
realm = bot.bot_owner.realm
stream, created = create_stream_if_needed(realm, integration.stream_name)
bulk_add_subscriptions(realm, [stream], [bot, bot.bot_owner], from_stream_creation=created)
bulk_add_subscriptions(realm, [stream], [bot, bot.bot_owner])
def get_integration(integration_name: str) -> WebhookIntegration:
integration = INTEGRATIONS[integration_name]