Merge remote-tracking branch 'origin/develop' into activity-pub-use-atoms-as-keys
authorEgor Kislitsyn <egor@kislitsyn.com>
Fri, 5 Jun 2020 19:15:10 +0000 (23:15 +0400)
committerEgor Kislitsyn <egor@kislitsyn.com>
Fri, 5 Jun 2020 19:15:10 +0000 (23:15 +0400)
1  2 
lib/pleroma/web/activity_pub/activity_pub.ex
lib/pleroma/web/activity_pub/utils.ex
lib/pleroma/web/controller_helper.ex
lib/pleroma/web/feed/tag_controller.ex
lib/pleroma/web/feed/user_controller.ex
lib/pleroma/web/mastodon_api/controllers/account_controller.ex
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex

index ef21f180b8e419e83c0a8eb83c3a66ded84056e1,75468f415ced7755a50ce130021f954b1dab293a..eb73c95fe6cc8452ee38c51411e7fa3cdf1fad3b
@@@ -316,11 -321,10 +311,11 @@@ defmodule Pleroma.Web.ActivityPub.Activ
      local = Map.get(params, :local, true)
      activity_id = Map.get(params, :activity_id, nil)
  
 -    with data <-
 -           %{"to" => to, "type" => type, "actor" => actor.ap_id, "object" => object}
 -           |> Maps.put_if_present("id", activity_id),
 -         {:ok, activity} <- insert(data, local),
 +    data =
 +      %{"to" => to, "type" => type, "actor" => actor.ap_id, "object" => object}
-       |> Utils.maybe_put("id", activity_id)
++      |> Maps.put_if_present("id", activity_id)
 +
 +    with {:ok, activity} <- insert(data, local),
           _ <- notify_and_stream(activity),
           :ok <- maybe_federate(activity) do
        {:ok, activity}
      local = !(params[:local] == false)
      activity_id = params[:activity_id]
  
 -    with data <- %{
 -           "to" => to,
 -           "cc" => cc,
 -           "type" => "Update",
 -           "actor" => actor,
 -           "object" => object
 -         },
 -         data <- Maps.put_if_present(data, "id", activity_id),
 -         {:ok, activity} <- insert(data, local),
 +    data =
 +      %{
 +        "to" => to,
 +        "cc" => cc,
 +        "type" => "Update",
 +        "actor" => actor,
 +        "object" => object
 +      }
-       |> Utils.maybe_put("id", activity_id)
++      |> Maps.put_if_present("id", activity_id)
 +
 +    with {:ok, activity} <- insert(data, local),
           _ <- notify_and_stream(activity),
           :ok <- maybe_federate(activity) do
        {:ok, activity}
Simple merge
Simple merge
index 3404d2856159cc16af50a39377f329a0bb5667ae,4e86cfeb58221b0cd2c8085c4393029caa042e70..39b2a766a503cc25ff8715e435d18ec6917f1c82
@@@ -15,8 -13,8 +13,8 @@@ defmodule Pleroma.Web.Feed.TagControlle
      {format, tag} = parse_tag(raw_tag)
  
      activities =
 -      %{"type" => ["Create"], "tag" => tag}
 -      |> Pleroma.Maps.put_if_present("max_id", params["max_id"])
 +      %{type: ["Create"], tag: tag}
-       |> put_if_exist(:max_id, params["max_id"])
++      |> Pleroma.Maps.put_if_present(:max_id, params["max_id"])
        |> ActivityPub.fetch_public_activities()
  
      conn
index 7bf9bd3e3180dfadb28761654b78ab92b8fd1faf,7c2e0d5220036f309fc9bdc5f0b02fb9c33620e4..d56f438184fa920457ad4f8d6ceaf5f5b6b932a4
@@@ -52,10 -50,10 +50,10 @@@ defmodule Pleroma.Web.Feed.UserControll
      with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
        activities =
          %{
 -          "type" => ["Create"],
 -          "actor_id" => user.ap_id
 +          type: ["Create"],
 +          actor_id: user.ap_id
          }
-         |> put_if_exist(:max_id, params["max_id"])
 -        |> Pleroma.Maps.put_if_present("max_id", params["max_id"])
++        |> Pleroma.Maps.put_if_present(:max_id, params["max_id"])
          |> ActivityPub.fetch_public_or_unlisted_activities()
  
        conn
index ed74a771a399bffce0cea1456b01b9a1ccda8158,f3b9285a918f9ddac622c7b5151514e04cca3921..9270ca267a75f27704646f261a3a5c2150dd1191
@@@ -44,16 -44,15 +44,14 @@@ defmodule Pleroma.Web.MastodonAPI.Timel
    def home(%{assigns: %{user: user}} = conn, params) do
      params =
        params
 -      |> Map.new(fn {key, value} -> {to_string(key), value} end)
 -      |> Map.put("type", ["Create", "Announce"])
 -      |> Map.put("blocking_user", user)
 -      |> Map.put("muting_user", user)
 -      |> Map.put("reply_filtering_user", user)
 -      |> Map.put("user", user)
 +      |> Map.put(:type, ["Create", "Announce"])
 +      |> Map.put(:blocking_user, user)
 +      |> Map.put(:muting_user, user)
 +      |> Map.put(:reply_filtering_user, user)
 +      |> Map.put(:user, user)
  
-     recipients = [user.ap_id | User.following(user)]
      activities =
-       recipients
+       [user.ap_id | User.following(user)]
        |> ActivityPub.fetch_activities(params)
        |> Enum.reverse()