Subscribe to remote users on following.
This commit is contained in:
parent
9cafb67fc1
commit
bda389d7d9
3 changed files with 27 additions and 5 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 ->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue