aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2017-05-06 14:09:39 +0200
committerRoger Braun <roger@rogerbraun.net>2017-05-06 14:09:39 +0200
commitbda389d7d942b7e90ffb519bc680a424a8400e2f (patch)
tree56296b4b848ce82e0a42fff916b43f6f375b01d2 /lib
parent9cafb67fc177ace3af176a86366ae676b89ea368 (diff)
downloadpleroma-bda389d7d942b7e90ffb519bc680a424a8400e2f.tar.gz
Subscribe to remote users on following.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/user.ex6
-rw-r--r--lib/pleroma/web/websub/websub.ex2
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/pleroma/user.ex b/lib/pleroma/user.ex
index 23be6276e..551c23445 100644
--- a/lib/pleroma/user.ex
+++ b/lib/pleroma/user.ex
@@ -4,7 +4,7 @@ defmodule Pleroma.User do
import Ecto.{Changeset, Query}
alias Pleroma.{Repo, User, Object, Web}
alias Comeonin.Pbkdf2
- alias Pleroma.Web.OStatus
+ alias Pleroma.Web.{OStatus, Websub}
schema "users" do
field :bio, :string
@@ -88,6 +88,10 @@ defmodule Pleroma.User do
{:error,
"Could not follow user: #{followed.nickname} is already on your list."}
else
+ if !followed.local do
+ Websub.subscribe(follower, followed)
+ end
+
following = [ap_followers | follower.following]
|> Enum.uniq
diff --git a/lib/pleroma/web/websub/websub.ex b/lib/pleroma/web/websub/websub.ex
index a5abc303c..7c8efa917 100644
--- a/lib/pleroma/web/websub/websub.ex
+++ b/lib/pleroma/web/websub/websub.ex
@@ -126,7 +126,7 @@ defmodule Pleroma.Web.Websub do
topic = subscribed.info["topic"]
# FIXME: Race condition, use transactions
{:ok, subscription} = with subscription when not is_nil(subscription) <- Repo.get_by(WebsubClientSubscription, topic: topic) do
- subscribers = [subscriber.ap_id, subscription.subscribers] |> Enum.uniq
+ subscribers = [subscriber.ap_id | subscription.subscribers] |> Enum.uniq
change = Ecto.Changeset.change(subscription, %{subscribers: subscribers})
Repo.update(change)
else _e ->