aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web
diff options
context:
space:
mode:
authorIvan Tashkinov <ivantashkinov@gmail.com>2019-01-29 13:12:28 +0300
committerIvan Tashkinov <ivantashkinov@gmail.com>2019-01-29 13:12:28 +0300
commit92753b0cd9cfcdc5edb64a5e55ad27f73079f9e0 (patch)
tree606de2d652366d27ce34faebf3ad4274facfd15d /lib/pleroma/web
parentd3f9e6f6fed382ede8e314c370c21e84a119f65a (diff)
downloadpleroma-92753b0cd9cfcdc5edb64a5e55ad27f73079f9e0.tar.gz
[#534] Made federation push sender be determined basing on content instead of `referer` header. Updated tests.
Diffstat (limited to 'lib/pleroma/web')
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub.ex3
-rw-r--r--lib/pleroma/web/activity_pub/activity_pub_controller.ex11
-rw-r--r--lib/pleroma/web/ostatus/ostatus.ex3
-rw-r--r--lib/pleroma/web/ostatus/ostatus_controller.ex1
-rw-r--r--lib/pleroma/web/salmon/salmon.ex5
-rw-r--r--lib/pleroma/web/websub/websub.ex3
-rw-r--r--lib/pleroma/web/websub/websub_controller.ex2
7 files changed, 16 insertions, 12 deletions
diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex
index 22c7824fa..4016808e8 100644
--- a/lib/pleroma/web/activity_pub/activity_pub.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub.ex
@@ -784,8 +784,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
[
{"Content-Type", "application/activity+json"},
{"signature", signature},
- {"digest", digest},
- {"referer", Pleroma.Web.Endpoint.url()}
+ {"digest", digest}
]
) do
Instances.set_reachable(inbox)
diff --git a/lib/pleroma/web/activity_pub/activity_pub_controller.ex b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
index fadb038a2..4dea6ab83 100644
--- a/lib/pleroma/web/activity_pub/activity_pub_controller.ex
+++ b/lib/pleroma/web/activity_pub/activity_pub_controller.ex
@@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
action_fallback(:errors)
plug(Pleroma.Web.FederatingPlug when action in [:inbox, :relay])
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:inbox])
+ plug(:set_requester_reachable when action in [:inbox])
plug(:relay_active? when action in [:relay])
def relay_active?(conn, _) do
@@ -291,4 +291,13 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubController do
|> put_status(500)
|> json("error")
end
+
+ defp set_requester_reachable(%Plug.Conn{} = conn, _) do
+ with actor <- conn.params["actor"],
+ true <- is_binary(actor) do
+ Pleroma.Instances.set_reachable(actor)
+ end
+
+ conn
+ end
end
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex
index a3155b79d..a20ca17bb 100644
--- a/lib/pleroma/web/ostatus/ostatus.ex
+++ b/lib/pleroma/web/ostatus/ostatus.ex
@@ -48,6 +48,9 @@ defmodule Pleroma.Web.OStatus do
def handle_incoming(xml_string) do
with doc when doc != :error <- parse_document(xml_string) do
+ with {:ok, actor_user} <- find_make_or_update_user(doc),
+ do: Pleroma.Instances.set_reachable(actor_user.ap_id)
+
entries = :xmerl_xpath.string('//entry', doc)
activities =
diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex
index 9392a97f0..302ff38a4 100644
--- a/lib/pleroma/web/ostatus/ostatus_controller.ex
+++ b/lib/pleroma/web/ostatus/ostatus_controller.ex
@@ -14,7 +14,6 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.Web.ActivityPub.ActivityPub
plug(Pleroma.Web.FederatingPlug when action in [:salmon_incoming])
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:salmon_incoming])
action_fallback(:errors)
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex
index e96455423..07ca42a5f 100644
--- a/lib/pleroma/web/salmon/salmon.ex
+++ b/lib/pleroma/web/salmon/salmon.ex
@@ -172,10 +172,7 @@ defmodule Pleroma.Web.Salmon do
poster.(
url,
feed,
- [
- {"Content-Type", "application/magic-envelope+xml"},
- {"referer", Pleroma.Web.Endpoint.url()}
- ]
+ [{"Content-Type", "application/magic-envelope+xml"}]
) do
Instances.set_reachable(url)
Logger.debug(fn -> "Pushed to #{url}, code #{code}" end)
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index abe148270..8f7d53b03 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -278,8 +278,7 @@ defmodule Pleroma.Web.Websub do
xml,
[
{"Content-Type", "application/atom+xml"},
- {"X-Hub-Signature", "sha1=#{signature}"},
- {"referer", Pleroma.Web.Endpoint.url()}
+ {"X-Hub-Signature", "sha1=#{signature}"}
]
) do
Instances.set_reachable(callback)
diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex
index 9da7e70a1..a92dfe87b 100644
--- a/lib/pleroma/web/websub/websub_controller.ex
+++ b/lib/pleroma/web/websub/websub_controller.ex
@@ -20,8 +20,6 @@ defmodule Pleroma.Web.Websub.WebsubController do
]
)
- plug(Pleroma.Web.Plugs.SetRequesterReachablePlug when action in [:websub_incoming])
-
def websub_subscription_request(conn, %{"nickname" => nickname} = params) do
user = User.get_cached_by_nickname(nickname)