From: Egor Kislitsyn Date: Fri, 5 Jun 2020 19:15:10 +0000 (+0400) Subject: Merge remote-tracking branch 'origin/develop' into activity-pub-use-atoms-as-keys X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=b02df1803e16b40ad8a30465604e2892b6d65e6f;p=akkoma Merge remote-tracking branch 'origin/develop' into activity-pub-use-atoms-as-keys --- b02df1803e16b40ad8a30465604e2892b6d65e6f diff --cc lib/pleroma/web/activity_pub/activity_pub.ex index ef21f180b,75468f415..eb73c95fe --- a/lib/pleroma/web/activity_pub/activity_pub.ex +++ b/lib/pleroma/web/activity_pub/activity_pub.ex @@@ -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} @@@ -332,17 -336,15 +327,17 @@@ 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} diff --cc lib/pleroma/web/feed/tag_controller.ex index 3404d2856,4e86cfeb5..39b2a766a --- a/lib/pleroma/web/feed/tag_controller.ex +++ b/lib/pleroma/web/feed/tag_controller.ex @@@ -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 diff --cc lib/pleroma/web/feed/user_controller.ex index 7bf9bd3e3,7c2e0d522..d56f43818 --- a/lib/pleroma/web/feed/user_controller.ex +++ b/lib/pleroma/web/feed/user_controller.ex @@@ -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 diff --cc lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex index ed74a771a,f3b9285a9..9270ca267 --- a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex +++ b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex @@@ -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()