2019-10-04 17:21:45 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-09-16 12:03:37 +02:00
|
|
|
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
|