giant massive dep upgrade and dialyxir-found error emporium #371

Merged
floatingghost merged 13 commits from dialyxer into develop 2022-12-14 12:38:49 +00:00
9 changed files with 66 additions and 14 deletions
Showing only changes of commit ae2c0379d8 - Show all commits

View file

@ -92,7 +92,7 @@ defmodule Pleroma.Web.Auth.PleromaAuthenticator do
Registration.changeset(registration, %{user_id: new_user.id}) |> Repo.update() do
{:ok, new_user}
else
err -> {:error, err}
err -> err
end
end

View file

@ -116,6 +116,7 @@ defmodule Pleroma.Web.Endpoint do
plug(Phoenix.CodeReloader)
end
plug(Pleroma.Web.Plugs.TrailingFormatPlug)
plug(Plug.RequestId)
plug(Plug.Logger, log: :debug)

View file

@ -35,8 +35,6 @@ defmodule Pleroma.Web.Feed.UserController do
end
def feed(conn, %{"nickname" => nickname} = params) do
[nickname | _rest] = String.split(nickname, ".")
IO.puts(nickname)
format = get_format(conn)
format =

View file

@ -96,8 +96,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
# Schema definition: https://github.com/jhass/nodeinfo/blob/master/schemas/2.0/schema.json
# and https://github.com/jhass/nodeinfo/blob/master/schemas/2.1/schema.json
# and some backwards-compatibility to allow the `.json` extension
def nodeinfo(conn, %{"version" => version}) when version in ["2.0", "2.0.json"] do
def nodeinfo(conn, %{"version" => "2.0"}) do
conn
|> put_resp_header(
"content-type",
@ -106,7 +105,7 @@ defmodule Pleroma.Web.Nodeinfo.NodeinfoController do
|> json(raw_nodeinfo())
end
def nodeinfo(conn, %{"version" => version}) when version in ["2.1", "2.1.json"] do
def nodeinfo(conn, %{"version" => "2.1"}) do
raw_response = raw_nodeinfo()
updated_software =

View file

@ -17,6 +17,7 @@ defmodule Pleroma.Web.Plugs.RemoteIp do
if Config.get([__MODULE__, :enabled]) do
{headers, proxies} = remote_ip_opts()
new_remote_ip = RemoteIp.from(conn.req_headers, headers: headers, proxies: proxies)
if new_remote_ip != original_remote_ip do
Map.put(conn, :remote_ip, new_remote_ip)
else

View file

@ -0,0 +1,42 @@
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.Plugs.TrailingFormatPlug do
@moduledoc "Calls TrailingFormatPlug for specific paths. Ideally we would just do this in the router, but TrailingFormatPlug needs to be called before Plug.Parsers."
@behaviour Plug
@paths [
"/api/statusnet",
"/api/statuses",
"/api/qvitter",
"/api/search",
"/api/account",
"/api/friends",
"/api/mutes",
"/api/media",
"/api/favorites",
"/api/blocks",
"/api/friendships",
"/api/users",
"/users",
"/nodeinfo",
"/api/help",
"/api/externalprofile",
"/notice",
"/api/pleroma/emoji",
"/api/oauth_tokens"
]
def init(opts) do
TrailingFormatPlug.init(opts)
end
for path <- @paths do
def call(%{request_path: unquote(path) <> _} = conn, opts) do
TrailingFormatPlug.call(conn, opts)
end
end
def call(conn, _opts), do: conn
end

View file

@ -136,6 +136,7 @@ defmodule Pleroma.Mixfile do
{:cowlib, "~> 2.9"},
{:finch, "~> 0.14.0"},
{:jason, "~> 1.2"},
{:trailing_format_plug, "~> 0.0.7"},
{:mogrify, "~> 0.9.1"},
{:ex_aws, "~> 2.1.6"},
{:ex_aws_s3, "~> 2.0"},

View file

@ -115,6 +115,7 @@
"temple": {:git, "https://akkoma.dev/AkkomaGang/temple.git", "066a699ade472d8fa42a9d730b29a61af9bc8b59", [ref: "066a699ade472d8fa42a9d730b29a61af9bc8b59"]},
"tesla": {:hex, :tesla, "1.4.4", "bb89aa0c9745190930366f6a2ac612cdf2d0e4d7fff449861baa7875afd797b2", [:mix], [{:castore, "~> 0.1", [hex: :castore, repo: "hexpm", optional: true]}, {:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:finch, "~> 0.3", [hex: :finch, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:gun, "~> 1.3", [hex: :gun, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.0", [hex: :mint, repo: "hexpm", optional: true]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "d5503a49f9dec1b287567ea8712d085947e247cb11b06bc54adb05bfde466457"},
"timex": {:hex, :timex, "3.7.9", "790cdfc4acfce434e442f98c02ea6d84d0239073bfd668968f82ac63e9a6788d", [:mix], [{:combine, "~> 0.10", [hex: :combine, repo: "hexpm", optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, repo: "hexpm", optional: false]}, {:tzdata, "~> 1.1", [hex: :tzdata, repo: "hexpm", optional: false]}], "hexpm", "64691582e5bb87130f721fc709acfb70f24405833998fabf35be968984860ce1"},
"trailing_format_plug": {:hex, :trailing_format_plug, "0.0.7", "64b877f912cf7273bed03379936df39894149e35137ac9509117e59866e10e45", [:mix], [{:plug, "> 0.12.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "bd4fde4c15f3e993a999e019d64347489b91b7a9096af68b2bdadd192afa693f"},
"tzdata": {:hex, :tzdata, "1.1.1", "20c8043476dfda8504952d00adac41c6eda23912278add38edc140ae0c5bcc46", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "a69cec8352eafcd2e198dea28a34113b60fdc6cb57eb5ad65c10292a6ba89787"},
"ueberauth": {:hex, :ueberauth, "0.10.3", "4a3bd7ab7b5d93d301d264f0f6858392654ee92171f4437d067d1ae227c051d9", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "1394f36a6c64e97f2038cf95228e7e52b4cb75417962e30418fbe9902b30e6d3"},
"unicode_util_compat": {:hex, :unicode_util_compat, "0.7.0", "bc84380c9ab48177092f43ac89e4dfa2c6d62b40b8bd132b1059ecc7232f9a78", [:rebar3], [], "hexpm", "25eee6d67df61960cf6a794239566599b09e17e668d3700247bc498638152521"},

View file

@ -14,6 +14,7 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
clear_config([RemoteIp, :enabled], true)
clear_config([RemoteIp, :headers], ["x-forwarded-for"])
clear_config([RemoteIp, :proxies], [])
clear_config(
[RemoteIp, :reserved],
[
@ -33,7 +34,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
%{remote_ip: remote_ip} = conn(:get, "/")
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "1.1.1.1")
|> RemoteIp.call(nil)
@ -42,7 +44,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
test "enabled" do
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "1.1.1.1")
|> RemoteIp.call(nil)
@ -54,14 +57,16 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
clear_config([RemoteIp, :headers], ["cf-connecting-ip"])
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "1.1.1.1")
|> RemoteIp.call(nil)
refute conn.remote_ip == {1, 1, 1, 1}
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("cf-connecting-ip", "1.1.1.1")
|> RemoteIp.call(nil)
@ -70,7 +75,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
test "custom proxies" do
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "173.245.48.1, 1.1.1.1, 173.245.48.2")
|> RemoteIp.call(nil)
@ -79,7 +85,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
clear_config([RemoteIp, :proxies], ["173.245.48.0/20"])
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "173.245.48.1, 1.1.1.1, 173.245.48.2")
|> RemoteIp.call(nil)
@ -90,7 +97,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
clear_config([RemoteIp, :proxies], ["173.245.48.1"])
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "173.245.48.1, 1.1.1.1")
|> RemoteIp.call(nil)
@ -102,7 +110,8 @@ defmodule Pleroma.Web.Plugs.RemoteIpTest do
clear_config([RemoteIp, :proxies], ["10.0.0.3/24"])
conn =
conn(:get, "/")
:get
|> conn("/")
|> put_req_header("x-forwarded-for", "10.0.0.3, 1.1.1.1")
|> RemoteIp.call(nil)