add websocket group unsubscribe reply

* This change adds more than just an unsubscribe reply.
* Websockets canrequest to join/leave groups. They do so using a single
idempotent request. This change replies to group requests over the
websockets with the diff of the group subscription. i.e. what groups the
user currenntly is in, what groups were left, and what groups were
joined.
This commit is contained in:
chris meyers 2020-01-24 10:53:41 -05:00 committed by Ryan Petrello
parent 088373963b
commit feac93fd24
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -204,6 +204,11 @@ class EventConsumer(AsyncJsonWebsocketConsumer):
)
logger.debug(f"Channel {self.channel_name} left groups {old_groups} and joined {new_groups_exclusive}")
self.scope['session']['groups'] = new_groups
await self.send_json({
"groups_current": list(new_groups),
"groups_left": list(old_groups),
"groups_joined": list(new_groups_exclusive)
})
async def internal_message(self, event):
await self.send(event['text'])