aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex20
-rw-r--r--lib/pleroma/web/common_api/utils.ex11
-rw-r--r--lib/pleroma/web/salmon/salmon.ex2
-rw-r--r--lib/pleroma/web/web_finger/web_finger.ex3
-rw-r--r--lib/pleroma/web/xml/xml.ex2
5 files changed, 19 insertions, 19 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index bcc34b38f..e146b562c 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -212,7 +212,7 @@ defmodule Pleroma.User do
end
def maybe_direct_follow(%User{} = follower, %User{} = followed) do
- if !User.ap_enabled?(followed) do
+ if not User.ap_enabled?(followed) do
follow(follower, followed)
else
{:ok, follower}
@@ -736,7 +736,8 @@ defmodule Pleroma.User do
source_data: %{"publicKey" => %{"publicKeyPem" => public_key_pem}}
}) do
key =
- :public_key.pem_decode(public_key_pem)
+ public_key_pem
+ |> :public_key.pem_decode()
|> hd()
|> :public_key.pem_entry_decode()
@@ -774,13 +775,10 @@ defmodule Pleroma.User do
def ap_enabled?(%User{info: info}), do: info.ap_enabled
def ap_enabled?(_), do: false
- def get_or_fetch(uri_or_nickname) do
- if String.starts_with?(uri_or_nickname, "http") do
- get_or_fetch_by_ap_id(uri_or_nickname)
- else
- get_or_fetch_by_nickname(uri_or_nickname)
- end
- end
+ @doc "Gets or fetch a user by uri or nickname."
+ @spec get_or_fetch(String.t()) :: User.t()
+ def get_or_fetch("http" <> _host = uri), do: get_or_fetch_by_ap_id(uri)
+ def get_or_fetch(nickname), do: get_or_fetch_by_nickname(nickname)
# wait a period of time and return newest version of the User structs
# this is because we have synchronous follow APIs and need to simulate them
@@ -821,7 +819,9 @@ defmodule Pleroma.User do
{String.trim(name, ":"), url}
end)
- CommonUtils.format_input(bio, mentions, tags, "text/plain") |> Formatter.emojify(emoji)
+ bio
+ |> CommonUtils.format_input(mentions, tags, "text/plain")
+ |> Formatter.emojify(emoji)
end
def tag(user_identifiers, tags) when is_list(user_identifiers) do
diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex
index 8f2625cef..ce0926b99 100644
--- a/lib/pleroma/web/common_api/utils.ex
+++ b/lib/pleroma/web/common_api/utils.ex
@@ -1,11 +1,12 @@
defmodule Pleroma.Web.CommonAPI.Utils do
- alias Pleroma.{Repo, Object, Formatter, Activity}
+ alias Calendar.Strftime
+ alias Comeonin.Pbkdf2
+ alias Pleroma.{Activity, Formatter, Object, Repo}
+ alias Pleroma.User
+ alias Pleroma.Web
alias Pleroma.Web.ActivityPub.Utils
alias Pleroma.Web.Endpoint
alias Pleroma.Web.MediaProxy
- alias Pleroma.User
- alias Calendar.Strftime
- alias Comeonin.Pbkdf2
# This is a hack for twidere.
def get_by_id_or_ap_id(id) do
@@ -148,7 +149,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do
|> Enum.sort_by(fn {tag, _} -> -String.length(tag) end)
Enum.reduce(tags, text, fn {full, tag}, text ->
- url = "<a href='#{Pleroma.Web.base_url()}/tag/#{tag}' rel='tag'>##{tag}</a>"
+ url = "<a href='#{Web.base_url()}/tag/#{tag}' rel='tag'>##{tag}</a>"
String.replace(text, full, url)
end)
end
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex
index 0e2cfddd0..b67b1333f 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -180,7 +180,7 @@ defmodule Pleroma.Web.Salmon do
"Undo",
"Delete"
]
- def publish(user, activity, poster \\ &@httpoison.post/4)
+ def publish(user, activity, poster \\ &@httpoison.post/3)
def publish(%{info: %{keys: keys}} = user, %{data: %{"type" => type}} = activity, poster)
when type in @supported_activities do
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex
index 0ff3b8b5f..47c733da2 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger/web_finger.ex
@@ -256,8 +256,7 @@ defmodule Pleroma.Web.WebFinger do
with response <-
@httpoison.get(
address,
- [Accept: "application/xrd+xml,application/jrd+json"],
- follow_redirect: true
+ Accept: "application/xrd+xml,application/jrd+json"
),
{:ok, %{status: status, body: body}} when status in 200..299 <- response do
doc = XML.parse_document(body)
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex
index 63d3302e0..b3ccf4a55 100644
--- a/lib/pleroma/web/xml/xml.ex
+++ b/lib/pleroma/web/xml/xml.ex
@@ -25,7 +25,7 @@ defmodule Pleroma.Web.XML do
{doc, _rest} =
text
|> :binary.bin_to_list()
- |> :xmerl_scan.string()
+ |> :xmerl_scan.string(quiet: true)
doc
rescue