diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/plugs/http_signature.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/user.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub.ex | 9 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/activity_pub_controller.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/activity_pub/transmogrifier.ex | 57 | ||||
-rw-r--r-- | lib/pleroma/web/chat_channel.ex | 13 | ||||
-rw-r--r-- | lib/pleroma/web/federator/federator.ex | 14 | ||||
-rw-r--r-- | lib/pleroma/web/http_signatures/http_signatures.ex | 32 | ||||
-rw-r--r-- | lib/pleroma/web/mastodon_api/views/status_view.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/media_proxy/controller.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/oauth/authorization.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/ostatus/ostatus.ex | 10 | ||||
-rw-r--r-- | lib/pleroma/web/salmon/salmon.ex | 6 | ||||
-rw-r--r-- | lib/pleroma/web/templates/mastodon_api/mastodon/index.html.eex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/web_finger/web_finger.ex | 4 | ||||
-rw-r--r-- | lib/pleroma/web/websub/websub.ex | 5 | ||||
-rw-r--r-- | lib/pleroma/web/websub/websub_controller.ex | 2 | ||||
-rw-r--r-- | lib/pleroma/web/xml/xml.ex | 2 |
18 files changed, 132 insertions, 53 deletions
diff --git a/lib/pleroma/plugs/http_signature.ex b/lib/pleroma/plugs/http_signature.ex index d2d4bdd63..af160f3ee 100644 --- a/lib/pleroma/plugs/http_signature.ex +++ b/lib/pleroma/plugs/http_signature.ex @@ -14,9 +14,14 @@ defmodule Pleroma.Web.Plugs.HTTPSignaturePlug do def call(conn, opts) do user = conn.params["actor"] Logger.debug("Checking sig for #{user}") + if get_req_header(conn, "signature") do - conn = conn - |> put_req_header("(request-target)", String.downcase("#{conn.method}") <> " #{conn.request_path}") + conn = + conn + |> put_req_header( + "(request-target)", + String.downcase("#{conn.method}") <> " #{conn.request_path}" + ) assign(conn, :valid_signature, HTTPSignatures.validate_conn(conn)) else diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex index a503a5b3f..5da146014 100644 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@ -417,7 +417,7 @@ defmodule Pleroma.User do _ -> case OStatus.make_user(ap_id) do {:ok, user} -> user - _ -> {:error, "Could not fetch by ap id"} + _ -> {:error, "Could not fetch by AP id"} end end end diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index 965f2cc9b..7b1207ce2 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -301,7 +301,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {:ok, data} <- Poison.decode(body) do user_data_from_user_object(data) else - e -> Logger.error("Could not user at fetch #{ap_id}, #{inspect(e)}") + e -> Logger.error("Could not decode user at fetch #{ap_id}, #{inspect(e)}") end end @@ -321,7 +321,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do with {:ok, %{"ap_id" => ap_id}} when not is_nil(ap_id) <- WebFinger.finger(nickname) do make_user_from_ap_id(ap_id) else - _e -> {:error, "No ap id in webfinger"} + _e -> {:error, "No AP id in WebFinger"} end end @@ -351,7 +351,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do Logger.info("Federating #{id} to #{inbox}") host = URI.parse(inbox).host signature = Pleroma.Web.HTTPSignatures.sign(actor, %{host: host, "content-length": byte_size(json)}) - @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}]) + @httpoison.post(inbox, json, [{"Content-Type", "application/activity+json"}, {"signature", signature}], hackney: [pool: :default]) end # TODO: @@ -361,7 +361,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {:ok, object} else Logger.info("Fetching #{id} via AP") - with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000), + with true <- String.starts_with?(id, "http"), + {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(id, [Accept: "application/activity+json"], follow_redirect: true, timeout: 10000, recv_timeout: 20000), {:ok, data} <- Poison.decode(body), nil <- Object.get_by_ap_id(data["id"]), params <- %{"type" => "Create", "to" => data["to"], "cc" => data["cc"], "actor" => data["attributedTo"], "object" => data}, diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex index edbcb938a..85fc95427 100644 --- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex +++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex @@ -36,9 +36,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do def inbox(conn, params) do headers = Enum.into(conn.req_headers, %{}) if !(String.contains?(headers["signature"] || "", params["actor"])) do - Logger.info("Signature not from author, relayed message, ignoring.") + Logger.info("Signature not from author, relayed message, ignoring") else - Logger.info("Signature error.") + Logger.info("Signature error") Logger.info("Could not validate #{params["actor"]}") Logger.info(inspect(conn.req_headers)) end diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index afb25b97b..d759ca2b2 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -21,6 +21,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> fix_attachments |> fix_context |> fix_in_reply_to + |> fix_emoji end def fix_in_reply_to(%{"inReplyTo" => in_reply_to_id} = object) when not is_nil(in_reply_to_id) do @@ -56,6 +57,25 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> Map.put("attachment", attachments) end + def fix_emoji(object) do + tags = (object["tag"] || []) + emoji = tags |> Enum.filter(fn (data) -> data["type"] == "Emoji" and data["icon"] end) + emoji = emoji |> Enum.reduce(%{}, fn (data, mapping) -> + name = data["name"] + if String.starts_with?(name, ":") do + name = name |> String.slice(1..-2) + end + + mapping |> Map.put(name, data["icon"]["url"]) + end) + + # we merge mastodon and pleroma emoji into a single mapping, to allow for both wire formats + emoji = Map.merge(object["emoji"] || %{}, emoji) + + object + |> Map.put("emoji", emoji) + end + # TODO: validate those with a Ecto scheme # - tags # - emoji @@ -168,6 +188,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> set_sensitive |> add_hashtags |> add_mention_tags + |> add_emoji_tags |> add_attributed_to |> prepare_attachments |> set_conversation @@ -189,11 +210,31 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do def prepare_outgoing(%{"type" => type} = data) do data = data + |> maybe_fix_object_url |> Map.put("@context", "https://www.w3.org/ns/activitystreams") {:ok, data} end + def maybe_fix_object_url(data) do + if is_binary(data["object"]) and not String.starts_with?(data["object"], "http") do + case ActivityPub.fetch_object_from_id(data["object"]) do + {:ok, relative_object} -> + if relative_object.data["external_url"] do + data = data + |> Map.put("object", relative_object.data["external_url"]) + else + data + end + e -> + Logger.error("Couldn't fetch #{data["object"]} #{inspect(e)}") + data + end + else + data + end + end + def add_hashtags(object) do tags = (object["tag"] || []) |> Enum.map fn (tag) -> %{"href" => Pleroma.Web.Endpoint.url() <> "/tags/#{tag}", "name" => "##{tag}", "type" => "Hashtag"} end @@ -215,6 +256,22 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do |> Map.put("tag", tags ++ mentions) end + # TODO: we should probably send mtime instead of unix epoch time for updated + def add_emoji_tags(object) do + tags = object["tag"] || [] + emoji = object["emoji"] || [] + out = emoji |> Enum.map(fn {name, url} -> + %{"icon" => %{"url" => url, "type" => "Image"}, + "name" => ":" <> name <> ":", + "type" => "Emoji", + "updated" => "1970-01-01T00:00:00Z", + "id" => url} + end) + + object + |> Map.put("tag", tags ++ out) + end + def set_conversation(object) do Map.put(object, "conversation", object["context"]) end diff --git a/lib/pleroma/web/chat_channel.ex b/lib/pleroma/web/chat_channel.ex index 48a3553bf..ddc1d6f80 100644 --- a/lib/pleroma/web/chat_channel.ex +++ b/lib/pleroma/web/chat_channel.ex @@ -14,11 +14,14 @@ defmodule Pleroma.Web.ChatChannel do end def handle_in("new_msg", %{"text" => text}, %{assigns: %{user_name: user_name}} = socket) do - author = User.get_cached_by_nickname(user_name) - author = Pleroma.Web.MastodonAPI.AccountView.render("account.json", user: author) - message = ChatChannelState.add_message(%{text: text, author: author}) - - broadcast! socket, "new_msg", message + text = String.trim(text) + if String.length(text) > 0 do + author = User.get_cached_by_nickname(user_name) + author = Pleroma.Web.MastodonAPI.AccountView.render("account.json", user: author) + message = ChatChannelState.add_message(%{text: text, author: author}) + + broadcast! socket, "new_msg", message + end {:noreply, socket} end end diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index daf836a40..51d293196 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -12,7 +12,7 @@ defmodule Pleroma.Web.Federator do @httpoison Application.get_env(:pleroma, :httpoison) @instance Application.get_env(:pleroma, :instance) @federating Keyword.get(@instance, :federating) - @max_jobs 10 + @max_jobs 20 def start_link do spawn(fn -> @@ -48,10 +48,10 @@ defmodule Pleroma.Web.Federator do with actor when not is_nil(actor) <- User.get_cached_by_ap_id(activity.data["actor"]) do {:ok, actor} = WebFinger.ensure_keys_present(actor) if ActivityPub.is_public?(activity) do - Logger.info(fn -> "Sending #{activity.data["id"]} out via websub" end) + Logger.info(fn -> "Sending #{activity.data["id"]} out via WebSub" end) Websub.publish(Pleroma.Web.OStatus.feed_path(actor), actor, activity) - Logger.info(fn -> "Sending #{activity.data["id"]} out via salmon" end) + Logger.info(fn -> "Sending #{activity.data["id"]} out via Salmon" end) Pleroma.Web.Salmon.publish(actor, activity) end @@ -61,7 +61,7 @@ defmodule Pleroma.Web.Federator do end def handle(:verify_websub, websub) do - Logger.debug(fn -> "Running websub verification for #{websub.id} (#{websub.topic}, #{websub.callback})" end) + Logger.debug(fn -> "Running WebSub verification for #{websub.id} (#{websub.topic}, #{websub.callback})" end) @websub.verify(websub) end @@ -71,7 +71,7 @@ defmodule Pleroma.Web.Federator do end def handle(:incoming_ap_doc, params) do - Logger.info("Handling incoming ap activity") + Logger.info("Handling incoming AP activity") with {:ok, _user} <- ap_enabled_actor(params["actor"]), nil <- Activity.get_by_ap_id(params["id"]), {:ok, activity} <- Transmogrifier.handle_incoming(params) do @@ -96,7 +96,7 @@ defmodule Pleroma.Web.Federator do with {:ok, %{status_code: code}} <- @httpoison.post(callback, xml, [ {"Content-Type", "application/atom+xml"}, {"X-Hub-Signature", "sha1=#{signature}"} - ], timeout: 10000, recv_timeout: 20000) do + ], timeout: 10000, recv_timeout: 20000, hackney: [pool: :default]) do Logger.debug(fn -> "Pushed to #{callback}, code #{code}" end) else e -> Logger.debug(fn -> "Couldn't push to #{callback}, #{inspect(e)}" end) @@ -105,7 +105,7 @@ defmodule Pleroma.Web.Federator do def handle(type, _) do Logger.debug(fn -> "Unknown task: #{type}" end) - {:error, "Don't know what do do with this"} + {:error, "Don't know what to do with this"} end def enqueue(type, payload, priority \\ 1) do diff --git a/lib/pleroma/web/http_signatures/http_signatures.ex b/lib/pleroma/web/http_signatures/http_signatures.ex index 93c7c310d..0ea3b7554 100644 --- a/lib/pleroma/web/http_signatures/http_signatures.ex +++ b/lib/pleroma/web/http_signatures/http_signatures.ex @@ -7,20 +7,23 @@ defmodule Pleroma.Web.HTTPSignatures do def split_signature(sig) do default = %{"headers" => "date"} - sig = sig - |> String.trim() - |> String.split(",") - |> Enum.reduce(default, fn(part, acc) -> - [key | rest] = String.split(part, "=") - value = Enum.join(rest, "=") - Map.put(acc, key, String.trim(value, "\"")) - end) + sig = + sig + |> String.trim() + |> String.split(",") + |> Enum.reduce(default, fn part, acc -> + [key | rest] = String.split(part, "=") + value = Enum.join(rest, "=") + Map.put(acc, key, String.trim(value, "\"")) + end) Map.put(sig, "headers", String.split(sig["headers"], ~r/\s/)) end def validate(headers, signature, public_key) do sigstring = build_signing_string(headers, signature["headers"]) + Logger.debug("Signature: #{signature["signature"]}") + Logger.debug("Sigstring: #{sigstring}") {:ok, sig} = Base.decode64(signature["signature"]) :public_key.verify(sigstring, :sha256, sig, public_key) end @@ -33,7 +36,7 @@ defmodule Pleroma.Web.HTTPSignatures do if validate_conn(conn, public_key) do true else - Logger.debug("Could not validate, re-fetching user and trying one more time.") + Logger.debug("Could not validate, re-fetching user and trying one more time") # Fetch user anew and try one more time with actor_id <- conn.params["actor"], {:ok, _user} <- ActivityPub.make_user_from_ap_id(actor_id), @@ -44,6 +47,7 @@ defmodule Pleroma.Web.HTTPSignatures do else e -> Logger.debug("Could not public key!") + false end end @@ -55,7 +59,7 @@ defmodule Pleroma.Web.HTTPSignatures do def build_signing_string(headers, used_headers) do used_headers - |> Enum.map(fn (header) -> "#{header}: #{headers[header]}" end) + |> Enum.map(fn header -> "#{header}: #{headers[header]}" end) |> Enum.join("\n") end @@ -63,8 +67,10 @@ defmodule Pleroma.Web.HTTPSignatures do with {:ok, %{info: %{"keys" => keys}}} <- Pleroma.Web.WebFinger.ensure_keys_present(user), {:ok, private_key, _} = Pleroma.Web.Salmon.keys_from_pem(keys) do sigstring = build_signing_string(headers, Map.keys(headers)) - signature = :public_key.sign(sigstring, :sha256, private_key) - |> Base.encode64() + + signature = + :public_key.sign(sigstring, :sha256, private_key) + |> Base.encode64() [ keyId: user.ap_id <> "#main-key", @@ -72,7 +78,7 @@ defmodule Pleroma.Web.HTTPSignatures do headers: Map.keys(headers) |> Enum.join(" "), signature: signature ] - |> Enum.map(fn({k, v}) -> "#{k}=\"#{v}\"" end) + |> Enum.map(fn {k, v} -> "#{k}=\"#{v}\"" end) |> Enum.join(",") end end diff --git a/lib/pleroma/web/mastodon_api/views/status_view.ex b/lib/pleroma/web/mastodon_api/views/status_view.ex index 4f395d0f7..55675ae1c 100644 --- a/lib/pleroma/web/mastodon_api/views/status_view.ex +++ b/lib/pleroma/web/mastodon_api/views/status_view.ex @@ -16,7 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do reblogged = Activity.get_create_activity_by_object_ap_id(object) reblogged = render("status.json", Map.put(opts, :activity, reblogged)) - mentions = activity.data["to"] + mentions = activity.recipients |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end) |> Enum.filter(&(&1)) |> Enum.map(fn (user) -> AccountView.render("mention.json", %{user: user}) end) @@ -60,7 +60,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do tags = object["tag"] || [] sensitive = object["sensitive"] || Enum.member?(tags, "nsfw") - mentions = activity.data["to"] + mentions = activity.recipients |> Enum.map(fn (ap_id) -> User.get_cached_by_ap_id(ap_id) end) |> Enum.filter(&(&1)) |> Enum.map(fn (user) -> AccountView.render("mention.json", %{user: user}) end) diff --git a/lib/pleroma/web/media_proxy/controller.ex b/lib/pleroma/web/media_proxy/controller.ex index 9327e7253..b0bbe8b64 100644 --- a/lib/pleroma/web/media_proxy/controller.ex +++ b/lib/pleroma/web/media_proxy/controller.ex @@ -3,7 +3,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do require Logger @httpoison Application.get_env(:pleroma, :httpoison) - + @max_body_length 25 * 1048576 @cache_control %{ @@ -31,7 +31,7 @@ defmodule Pleroma.Web.MediaProxy.MediaProxyController do defp proxy_request(link) do headers = [{"user-agent", "Pleroma/MediaProxy; #{Pleroma.Web.base_url()} <#{Application.get_env(:pleroma, :instance)[:email]}>"}] - options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}]) + options = @httpoison.process_request_options([:insecure, {:follow_redirect, true}]) ++ [{:pool, :default}] with \ {:ok, 200, headers, client} <- :hackney.request(:get, link, headers, "", options), headers = Enum.into(headers, Map.new), diff --git a/lib/pleroma/web/oauth/authorization.ex b/lib/pleroma/web/oauth/authorization.ex index 1ba5be602..5a68bd593 100644 --- a/lib/pleroma/web/oauth/authorization.ex +++ b/lib/pleroma/web/oauth/authorization.ex @@ -40,8 +40,8 @@ defmodule Pleroma.Web.OAuth.Authorization do if NaiveDateTime.diff(NaiveDateTime.utc_now, valid_until) < 0 do Repo.update(use_changeset(auth, %{used: true})) else - {:error, "token expired"} + {:error, "Token expired"} end end - def use_token(%Authorization{used: true}), do: {:error, "already used"} + def use_token(%Authorization{used: true}), do: {:error, "Already used"} end diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index bed15e8c0..f3ef4d690 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -291,13 +291,14 @@ defmodule Pleroma.Web.OStatus do [[_, match]] = Regex.scan(@gs_classic_regex, body) {:ok, match} true -> - Logger.debug(fn -> "Couldn't find atom link in #{inspect(body)}" end) - {:error, "Couldn't find the atom link"} + Logger.debug(fn -> "Couldn't find Atom link in #{inspect(body)}" end) + {:error, "Couldn't find the Atom link"} end end def fetch_activity_from_atom_url(url) do - with {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do + with true <- String.starts_with?(url, "http"), + {:ok, %{body: body, status_code: code}} when code in 200..299 <- @httpoison.get(url, [Accept: "application/atom+xml"], follow_redirect: true, timeout: 10000, recv_timeout: 20000) do Logger.debug("Got document from #{url}, handling...") handle_incoming(body) else @@ -309,7 +310,8 @@ defmodule Pleroma.Web.OStatus do def fetch_activity_from_html_url(url) do Logger.debug("Trying to fetch #{url}") - with {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000), + with true <- String.starts_with?(url, "http"), + {:ok, %{body: body}} <- @httpoison.get(url, [], follow_redirect: true, timeout: 10000, recv_timeout: 20000), {:ok, atom_url} <- get_atom_url(body) do fetch_activity_from_atom_url(atom_url) else diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index 46ca645d1..ab0f97d55 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -147,10 +147,10 @@ defmodule Pleroma.Web.Salmon do end defp send_to_user(%{info: %{"salmon" => salmon}}, feed, poster) do - with {:ok, %{status_code: code}} <- poster.(salmon, feed, [{"Content-Type", "application/magic-envelope+xml"}], timeout: 10000, recv_timeout: 20000) do + with {:ok, %{status_code: code}} <- poster.(salmon, feed, [{"Content-Type", "application/magic-envelope+xml"}], timeout: 10000, recv_timeout: 20000, hackney: [pool: :default]) do Logger.debug(fn -> "Pushed to #{salmon}, code #{code}" end) else - e -> Logger.debug(fn -> "Pushing salmon to #{salmon} failed, #{inspect(e)}" end) + e -> Logger.debug(fn -> "Pushing Salmon to #{salmon} failed, #{inspect(e)}" end) end end @@ -178,7 +178,7 @@ defmodule Pleroma.Web.Salmon do remote_users(activity) |> Enum.each(fn(remote_user) -> Task.start(fn -> - Logger.debug(fn -> "sending salmon to #{remote_user.ap_id}" end) + Logger.debug(fn -> "Sending Salmon to #{remote_user.ap_id}" end) send_to_user(remote_user, feed, poster) end) end) diff --git a/lib/pleroma/web/templates/mastodon_api/mastodon/index.html.eex b/lib/pleroma/web/templates/mastodon_api/mastodon/index.html.eex index ac50ad46b..f96b15d64 100644 --- a/lib/pleroma/web/templates/mastodon_api/mastodon/index.html.eex +++ b/lib/pleroma/web/templates/mastodon_api/mastodon/index.html.eex @@ -1,8 +1,12 @@ <!DOCTYPE html> <html lang='en'> <head> +<title> +<%= Application.get_env(:pleroma, :instance)[:name] %> +</title> <meta charset='utf-8'> <meta content='width=device-width, initial-scale=1' name='viewport'> +<link rel="icon" type="image/png" href="/favicon.png"/> <link rel="stylesheet" media="all" href="/packs/common.css" /> <link rel="stylesheet" media="all" href="/packs/default.css" /> <link rel="stylesheet" media="all" href="/packs/pl-dark-masto-fe.css" /> diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index c59a7e82d..019210124 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -100,7 +100,7 @@ defmodule Pleroma.Web.WebFinger do with {:ok, %{body: body}} <- @httpoison.get("https://#{domain}/.well-known/host-meta", []) do get_template_from_xml(body) else - e -> {:error, "Can't find lrdd template: #{inspect(e)}"} + e -> {:error, "Can't find LRDD template: #{inspect(e)}"} end end end @@ -122,7 +122,7 @@ defmodule Pleroma.Web.WebFinger do {:ok, data} else e -> - Logger.debug(fn -> "Couldn't finger #{account}." end) + Logger.debug(fn -> "Couldn't finger #{account}" end) Logger.debug(fn -> inspect(e) end) {:error, e} end diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex index 47a01849d..5caa8198c 100644 --- a/lib/pleroma/web/websub/websub.ex +++ b/lib/pleroma/web/websub/websub.ex @@ -49,7 +49,8 @@ defmodule Pleroma.Web.Websub do def publish(topic, user, %{data: %{"type" => type}} = activity) when type in @supported_activities do # TODO: Only send to still valid subscriptions. query = from sub in WebsubServerSubscription, - where: sub.topic == ^topic and sub.state == "active" + where: sub.topic == ^topic and sub.state == "active", + where: fragment("? > NOW()", sub.valid_until) subscriptions = Repo.all(query) Enum.each(subscriptions, fn(sub) -> response = user @@ -97,7 +98,7 @@ defmodule Pleroma.Web.Websub do {:ok, websub} else {:error, reason} -> - Logger.debug("Couldn't create subscription.") + Logger.debug("Couldn't create subscription") Logger.debug(inspect(reason)) {:error, reason} diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex index 6c9164ec8..115b64902 100644 --- a/lib/pleroma/web/websub/websub_controller.ex +++ b/lib/pleroma/web/websub/websub_controller.ex @@ -20,7 +20,7 @@ defmodule Pleroma.Web.Websub.WebsubController do # TODO: Extract this into the Websub module def websub_subscription_confirmation(conn, %{"id" => id, "hub.mode" => "subscribe", "hub.challenge" => challenge, "hub.topic" => topic} = params) do - Logger.debug("Got websub confirmation") + Logger.debug("Got WebSub confirmation") Logger.debug(inspect(params)) lease_seconds = if params["hub.lease_seconds"] do String.to_integer(params["hub.lease_seconds"]) diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml/xml.ex index 026672ad1..8b28a7e7d 100644 --- a/lib/pleroma/web/xml/xml.ex +++ b/lib/pleroma/web/xml/xml.ex @@ -21,7 +21,7 @@ defmodule Pleroma.Web.XML do doc catch :exit, _error -> - Logger.debug("Couldn't parse xml: #{inspect(text)}") + Logger.debug("Couldn't parse XML: #{inspect(text)}") :error end end |