streamer_socket.ex 653 Bytes
Newer Older
Steven Fuchs's avatar
Steven Fuchs committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
defmodule Pleroma.Web.Streamer.StreamerSocket do
  defstruct transport_pid: nil, user: nil

  alias Pleroma.User
  alias Pleroma.Web.Streamer.StreamerSocket

  def from_socket(%{
        transport_pid: transport_pid,
        assigns: %{user: nil}
      }) do
    %StreamerSocket{
      transport_pid: transport_pid
    }
  end

  def from_socket(%{
        transport_pid: transport_pid,
        assigns: %{user: %User{} = user}
      }) do
    %StreamerSocket{
      transport_pid: transport_pid,
      user: user
    }
  end

  def from_socket(%{transport_pid: transport_pid}) do
    %StreamerSocket{
      transport_pid: transport_pid
    }
  end
end