Last active
April 15, 2023 03:32
-
-
Save rayrayzayzay/83da6bb3266301e0f3e3541f98e253ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Felt.Channels.MapChannel do | |
use ChannelHandler.Router | |
def join(_topic, _payload, socket) do | |
{:ok, socket} | |
end | |
router do | |
plug &Plugs.ensure_authenticated/4 | |
scope "elements:" do | |
plug &Plugs.ensure_map_editable/4 | |
plug &Plugs.check_feature_flag/4, :element_imports | |
event "create", Felt.Channels.ElementHandler, :create | |
event "update", Felt.Channels.ElementHandler, :update | |
event "delete", Felt.Channels.ElementHandler, :delete | |
end | |
delegate "layer:", Felt.Channels.LayerHandler | |
delegate "sync:", Felt.Channels.SyncHandler | |
# Catch all clause | |
handle "", fn _payload, _context, socket -> | |
{:reply, {:error, "Unknown message format"}, socket} | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment