X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Factivity_pub%2Factivity_pub.ex;h=cc20197912485fababc2a7383b80d1920b6b797f;hb=b52672294e8cbc6f1ff53b9c7193e55781db84a6;hp=a0d36d03ad07ebb0bc36bc0117492279c0d9fd7c;hpb=decbf3a47fbcaea9ebc6b5ab9348260289100faf;p=akkoma diff --git a/lib/pleroma/web/activity_pub/activity_pub.ex b/lib/pleroma/web/activity_pub/activity_pub.ex index a0d36d03a..cc2019791 100644 --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@ -2,6 +2,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do alias Pleroma.{Activity, Repo, Object, Upload, User, Notification} alias Pleroma.Web.ActivityPub.Transmogrifier alias Pleroma.Web.WebFinger + alias Pleroma.Web.Federator import Ecto.Query import Pleroma.Web.ActivityPub.Utils require Logger @@ -272,7 +273,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do name: data["name"] } - User.insert_or_update_user(user_data) + if user = User.get_by_ap_id(ap_id) do + User.info_changeset(user, user_data) + |> Repo.update + else + User.insert_or_update_user(user_data) + end end end @@ -300,13 +306,17 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do {:ok, data} = Transmogrifier.prepare_outgoing(activity.data) json = Poison.encode!(data) Enum.each remote_inboxes, fn(inbox) -> - Logger.info("Federating #{activity.data["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}]) + Federator.enqueue(:publish_single_ap, %{inbox: inbox, json: json, actor: actor, id: activity.data["id"]}) end end + def publish_one(%{inbox: inbox, json: json, actor: actor, id: id}) 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}]) + end + # TODO: # This will create a Create activity, which we need internally at the moment. def fetch_object_from_id(id) do