aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-05-06 12:34:40 +0200
committerRoger Braun <roger@rogerbraun.net>2017-05-06 12:34:40 +0200
commit22ddddce766b5ba867c561dbd8060c67393c5504 (patch)
tree8ada350fbbe0769ff1ccf87f800e55a3a5a02d47 /lib
parent7e65cad9fe91cf7c0c25e8f307358083b3c8f784 (diff)
downloadpleroma-22ddddce766b5ba867c561dbd8060c67393c5504.tar.gz
Handle incoming items through the queue.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/federator/federator.ex6
-rw-r--r--lib/pleroma/web/ostatus/ostatus_controller.ex4
-rw-r--r--lib/pleroma/web/websub/websub_controller.ex6
3 files changed, 10 insertions, 6 deletions
diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex
index 69ba7ed7f..ab3313de1 100644
--- a/lib/pleroma/web/federator/federator.ex
+++ b/lib/pleroma/web/federator/federator.ex
@@ -5,6 +5,7 @@ defmodule Pleroma.Web.Federator do
require Logger
@websub Application.get_env(:pleroma, :websub)
+ @ostatus Application.get_env(:pleroma, :ostatus)
@max_jobs 10
def start_link do
@@ -28,6 +29,11 @@ defmodule Pleroma.Web.Federator do
@websub.verify(websub)
end
+ def handle(:incoming_doc, doc) do
+ Logger.debug("Got document, trying to parse")
+ @ostatus.handle_incoming(doc)
+ end
+
def handle(type, payload) do
Logger.debug(fn -> "Unknown task: #{type}" end)
{:error, "Don't know what do do with this"}
diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/ostatus/ostatus_controller.ex
index 5f79cc7e9..e6822463d 100644
--- a/lib/pleroma/web/ostatus/ostatus_controller.ex
+++ b/lib/pleroma/web/ostatus/ostatus_controller.ex
@@ -4,7 +4,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
alias Pleroma.{User, Activity}
alias Pleroma.Web.OStatus.{FeedRepresenter, ActivityRepresenter}
alias Pleroma.Repo
- alias Pleroma.Web.OStatus
+ alias Pleroma.Web.{OStatus, Federator}
import Ecto.Query
def feed_redirect(conn, %{"nickname" => nickname}) do
@@ -37,7 +37,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
{:ok, magic_key} = Pleroma.Web.Salmon.fetch_magic_key(body)
{:ok, doc} = Pleroma.Web.Salmon.decode_and_validate(magic_key, body)
- Pleroma.Web.OStatus.handle_incoming(doc)
+ Federator.enqueue(:incoming_doc, doc)
conn
|> send_resp(200, "")
diff --git a/lib/pleroma/web/websub/websub_controller.ex b/lib/pleroma/web/websub/websub_controller.ex
index e860ec9e5..4fc693214 100644
--- a/lib/pleroma/web/websub/websub_controller.ex
+++ b/lib/pleroma/web/websub/websub_controller.ex
@@ -1,12 +1,10 @@
defmodule Pleroma.Web.Websub.WebsubController do
use Pleroma.Web, :controller
alias Pleroma.{Repo, User}
- alias Pleroma.Web.Websub
+ alias Pleroma.Web.{Websub, Federator}
alias Pleroma.Web.Websub.WebsubClientSubscription
require Logger
- @ostatus Application.get_env(:pleroma, :ostatus)
-
def websub_subscription_request(conn, %{"nickname" => nickname} = params) do
user = User.get_cached_by_nickname(nickname)
@@ -38,7 +36,7 @@ defmodule Pleroma.Web.Websub.WebsubController do
%WebsubClientSubscription{} = websub <- Repo.get(WebsubClientSubscription, id),
{:ok, body, _conn} = read_body(conn),
^signature <- Websub.sign(websub.secret, body) do
- @ostatus.handle_incoming(body)
+ Federator.enqueue(:incoming_doc, body)
conn
|> send_resp(200, "OK")
else _e ->