fix warnings
This commit is contained in:
@ -7,7 +7,7 @@ defmodule SomethingErlang.Accounts do
|
|||||||
alias SomethingErlang.Repo
|
alias SomethingErlang.Repo
|
||||||
|
|
||||||
alias SomethingErlang.AwfulApi.Client
|
alias SomethingErlang.AwfulApi.Client
|
||||||
alias SomethingErlang.Accounts.{User, UserToken, UserNotifier}
|
alias SomethingErlang.Accounts.{User, UserToken}
|
||||||
|
|
||||||
## Database getters
|
## Database getters
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ defmodule SomethingErlang.Accounts.User do
|
|||||||
timestamps()
|
timestamps()
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_changeset(user, attrs, opts \\ []) do
|
def registration_changeset(user, attrs, _opts \\ []) do
|
||||||
user
|
user
|
||||||
|> cast(attrs, [:bbuserid])
|
|> cast(attrs, [:bbuserid])
|
||||||
|> validate_required([:bbuserid])
|
|> validate_required([:bbuserid])
|
||||||
|
@ -2,8 +2,11 @@ defmodule SomethingErlang.AwfulApi.Client do
|
|||||||
@base_url "https://forums.somethingawful.com/"
|
@base_url "https://forums.somethingawful.com/"
|
||||||
@user_agent "SomethingErlangClient/0.1"
|
@user_agent "SomethingErlangClient/0.1"
|
||||||
|
|
||||||
|
require Logger
|
||||||
|
|
||||||
def thread_doc(id, page, user) do
|
def thread_doc(id, page, user) do
|
||||||
resp = new(user) |> get_thread(id, page)
|
resp = new(user) |> get_thread(id, page)
|
||||||
|
Logger.debug("Client reply in #{resp.private.time}ms ")
|
||||||
:unicode.characters_to_binary(resp.body, :latin1)
|
:unicode.characters_to_binary(resp.body, :latin1)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -66,8 +69,16 @@ defmodule SomethingErlang.AwfulApi.Client do
|
|||||||
cache: true,
|
cache: true,
|
||||||
headers: [cookie: [cookies(%{bbuserid: user.id, bbpassword: user.hash})]]
|
headers: [cookie: [cookies(%{bbuserid: user.id, bbpassword: user.hash})]]
|
||||||
)
|
)
|
||||||
|
|> Req.Request.append_request_steps(
|
||||||
# |> Req.Request.append_request_steps(inspect: &IO.inspect/1)
|
time: fn req -> Req.Request.put_private(req, :time, Time.utc_now()) end
|
||||||
|
)
|
||||||
|
|> Req.Request.prepend_response_steps(
|
||||||
|
time: fn {req, res} ->
|
||||||
|
start = req.private.time
|
||||||
|
diff = Time.diff(Time.utc_now(), start, :millisecond)
|
||||||
|
{req, Req.Response.put_private(res, :time, diff)}
|
||||||
|
end
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp new() do
|
defp new() do
|
||||||
@ -76,8 +87,6 @@ defmodule SomethingErlang.AwfulApi.Client do
|
|||||||
user_agent: @user_agent,
|
user_agent: @user_agent,
|
||||||
redirect: false
|
redirect: false
|
||||||
)
|
)
|
||||||
|
|
||||||
# |> Req.Request.append_request_steps(inspect: &IO.inspect/1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
defp cookies(args) when is_map(args) do
|
defp cookies(args) when is_map(args) do
|
||||||
|
@ -27,7 +27,7 @@ defmodule SomethingErlangWeb.PageController do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_forum_path(conn, params) do
|
def to_forum_path(conn, _params) do
|
||||||
render(conn, :home)
|
render(conn, :home)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,7 +50,7 @@ defmodule SomethingErlangWeb.ThreadLive do
|
|||||||
~H"""
|
~H"""
|
||||||
<aside class="userinfo bg-base-100">
|
<aside class="userinfo bg-base-100">
|
||||||
<h3 class="mb-4"><%= @info.name %></h3>
|
<h3 class="mb-4"><%= @info.name %></h3>
|
||||||
<div class="title hidden sm:flex flex-col text-sm pr-4 sm:hidden">
|
<div class="title hidden sm:flex flex-col text-sm pr-4">
|
||||||
<%= raw(@info.title) %>
|
<%= raw(@info.title) %>
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
@ -85,7 +85,7 @@ defmodule SomethingErlangWeb.ThreadLive do
|
|||||||
|
|
||||||
defp label_button(%{label: "«", page: page} = assigns),
|
defp label_button(%{label: "«", page: page} = assigns),
|
||||||
do: ~H"""
|
do: ~H"""
|
||||||
<Heroicons.chevron_double_left mini /><%= @page %>
|
<Heroicons.chevron_double_left mini /><%= page %>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
defp label_button(%{label: "‹", page: page} = assigns),
|
defp label_button(%{label: "‹", page: page} = assigns),
|
||||||
@ -128,9 +128,11 @@ defmodule SomethingErlangWeb.ThreadLive do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def mount(_params, session, socket) do
|
def mount(_params, session, socket) do
|
||||||
|
user =
|
||||||
socket.assigns.current_user
|
socket.assigns.current_user
|
||||||
|> Map.put(:bbpassword, session["bbpassword"])
|
|> Map.put(:bbpassword, session["bbpassword"])
|
||||||
|> Grover.mount()
|
|
||||||
|
Grover.mount(user)
|
||||||
|
|
||||||
{:ok, socket}
|
{:ok, socket}
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user