diff options
| author | Melonai <einebeere@gmail.com> | 2021-05-22 18:18:56 +0200 |
|---|---|---|
| committer | Melonai <einebeere@gmail.com> | 2021-05-22 18:18:56 +0200 |
| commit | e0cabfea7c7b442acd3636e7495958b87e253176 (patch) | |
| tree | 62e15eb61189c1da58265e37b4a8328a75017205 /lib/rook_web/channels/request_channel.ex | |
| parent | 0bd75cadf7164979cc06f001ecc057f6275a2e3b (diff) | |
| download | rook-e0cabfea7c7b442acd3636e7495958b87e253176.tar.zst rook-e0cabfea7c7b442acd3636e7495958b87e253176.zip | |
Request and Share communication
Diffstat (limited to 'lib/rook_web/channels/request_channel.ex')
| -rw-r--r-- | lib/rook_web/channels/request_channel.ex | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/rook_web/channels/request_channel.ex b/lib/rook_web/channels/request_channel.ex new file mode 100644 index 0000000..6290ae6 --- /dev/null +++ b/lib/rook_web/channels/request_channel.ex @@ -0,0 +1,20 @@ +defmodule RookWeb.RequestChannel do + use RookWeb, :channel + + def join("request:" <> token, %{"share" => share_token}, socket) do + if Rook.Token.match?(token, socket) do + if Rook.Share.exists?(share_token) do + Rook.Request.start(token, share_token) + {:ok, socket} + else + {:error, %{reason: "No such share exists."}} + end + else + {:error, %{reason: "Wrong token."}} + end + end + + def join("request:" <> _token, _params, _socket) do + {:error, %{reason: "No share given to request."}} + end +end |
