Merge branch 'develop' into tests/mastodon_api_controller.ex
[akkoma] / lib / pleroma / web / streamer / streamer_socket.ex
1 defmodule Pleroma.Web.Streamer.StreamerSocket do
2 defstruct transport_pid: nil, user: nil
3
4 alias Pleroma.User
5 alias Pleroma.Web.Streamer.StreamerSocket
6
7 def from_socket(%{
8 transport_pid: transport_pid,
9 assigns: %{user: nil}
10 }) do
11 %StreamerSocket{
12 transport_pid: transport_pid
13 }
14 end
15
16 def from_socket(%{
17 transport_pid: transport_pid,
18 assigns: %{user: %User{} = user}
19 }) do
20 %StreamerSocket{
21 transport_pid: transport_pid,
22 user: user
23 }
24 end
25
26 def from_socket(%{transport_pid: transport_pid}) do
27 %StreamerSocket{
28 transport_pid: transport_pid
29 }
30 end
31 end