from django.urls import path

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from channels.security.websocket import AllowedHostsOriginValidator

from froide.problem.consumers import ModerationConsumer


websocket_urls = [
    path('moderation/', ModerationConsumer)
]

application = ProtocolTypeRouter({
    'websocket': AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            URLRouter([
                path('ws/', URLRouter(websocket_urls))
            ])
        )
    ),
})

from django.urls import path

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from channels.security.websocket import AllowedHostsOriginValidator

from froide.problem.consumers import ModerationConsumer


websocket_urls = [
    path('moderation/', ModerationConsumer.as_asgi())
]

application = ProtocolTypeRouter({
    'websocket': AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            URLRouter([
                path('ws/', URLRouter(websocket_urls))
            ])
        )
    ),
})

Fix ws consumers for channels 3.x
Fix ws consumers for channels 3.x
  from django.urls import path
  
  from channels.routing import ProtocolTypeRouter, URLRouter
  from channels.auth import AuthMiddlewareStack
  from channels.security.websocket import AllowedHostsOriginValidator
  
  from froide.problem.consumers import ModerationConsumer
  
  
  websocket_urls = [
-     path('moderation/', ModerationConsumer)
+     path('moderation/', ModerationConsumer.as_asgi())
  ]
  
  application = ProtocolTypeRouter({
      'websocket': AllowedHostsOriginValidator(
          AuthMiddlewareStack(
              URLRouter([
                  path('ws/', URLRouter(websocket_urls))
              ])
          )
      ),
  })
  
Fix ws consumers for channels 3.x
## Code Before:
from django.urls import path

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from channels.security.websocket import AllowedHostsOriginValidator

from froide.problem.consumers import ModerationConsumer


websocket_urls = [
    path('moderation/', ModerationConsumer)
]

application = ProtocolTypeRouter({
    'websocket': AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            URLRouter([
                path('ws/', URLRouter(websocket_urls))
            ])
        )
    ),
})

## Instruction:
Fix ws consumers for channels 3.x
## Code After:
from django.urls import path

from channels.routing import ProtocolTypeRouter, URLRouter
from channels.auth import AuthMiddlewareStack
from channels.security.websocket import AllowedHostsOriginValidator

from froide.problem.consumers import ModerationConsumer


websocket_urls = [
    path('moderation/', ModerationConsumer.as_asgi())
]

application = ProtocolTypeRouter({
    'websocket': AllowedHostsOriginValidator(
        AuthMiddlewareStack(
            URLRouter([
                path('ws/', URLRouter(websocket_urls))
            ])
        )
    ),
})
