outposts: handle disconnects without outpost better
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
		@ -50,7 +50,7 @@ class WebsocketMessage:
 | 
			
		||||
class OutpostConsumer(AuthJsonConsumer):
 | 
			
		||||
    """Handler for Outposts that connect over websockets for health checks and live updates"""
 | 
			
		||||
 | 
			
		||||
    outpost: Outpost
 | 
			
		||||
    outpost: Optional[Outpost] = None
 | 
			
		||||
 | 
			
		||||
    last_uid: Optional[str] = None
 | 
			
		||||
 | 
			
		||||
@ -95,6 +95,9 @@ class OutpostConsumer(AuthJsonConsumer):
 | 
			
		||||
        uid = msg.args.get("uuid", self.channel_name)
 | 
			
		||||
        self.last_uid = uid
 | 
			
		||||
 | 
			
		||||
        if not self.outpost:
 | 
			
		||||
            raise DenyConnection()
 | 
			
		||||
 | 
			
		||||
        state = OutpostState.for_instance_uid(self.outpost, uid)
 | 
			
		||||
        if self.channel_name not in state.channel_ids:
 | 
			
		||||
            state.channel_ids.append(self.channel_name)
 | 
			
		||||
 | 
			
		||||
@ -3,7 +3,6 @@ from typing import Any, Optional
 | 
			
		||||
 | 
			
		||||
from django.http import HttpRequest, HttpResponse
 | 
			
		||||
from django.http.response import HttpResponseBadRequest
 | 
			
		||||
from django.utils.translation import gettext_lazy as _
 | 
			
		||||
from django.views import View
 | 
			
		||||
from structlog.stdlib import get_logger
 | 
			
		||||
 | 
			
		||||
@ -38,14 +37,14 @@ class UserInfoView(View):
 | 
			
		||||
        # GitHub Compatibility Scopes are handeled differently, since they required custom paths
 | 
			
		||||
        # Hence they don't exist as Scope objects
 | 
			
		||||
        github_scope_map = {
 | 
			
		||||
            SCOPE_GITHUB_USER: _("GitHub Compatibility: Access your User Information"),
 | 
			
		||||
            SCOPE_GITHUB_USER_READ: _(
 | 
			
		||||
            SCOPE_GITHUB_USER: ("GitHub Compatibility: Access your User Information"),
 | 
			
		||||
            SCOPE_GITHUB_USER_READ: (
 | 
			
		||||
                "GitHub Compatibility: Access your User Information"
 | 
			
		||||
            ),
 | 
			
		||||
            SCOPE_GITHUB_USER_EMAIL: _(
 | 
			
		||||
            SCOPE_GITHUB_USER_EMAIL: (
 | 
			
		||||
                "GitHub Compatibility: Access you Email addresses"
 | 
			
		||||
            ),
 | 
			
		||||
            SCOPE_GITHUB_ORG_READ: _("GitHub Compatibility: Access your Groups"),
 | 
			
		||||
            SCOPE_GITHUB_ORG_READ: ("GitHub Compatibility: Access your Groups"),
 | 
			
		||||
        }
 | 
			
		||||
        for scope in scopes:
 | 
			
		||||
            if scope in github_scope_map:
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user