From 9e6ae447294d055af6add2efa9aca0024a252fe1 Mon Sep 17 00:00:00 2001 From: lain Date: Sat, 21 Apr 2018 09:43:53 +0200 Subject: [PATCH] Formatting fixes. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 9 ++++++--- lib/pleroma/web/activity_pub/utils.ex | 3 ++- lib/pleroma/web/oauth/oauth_controller.ex | 3 ++- lib/pleroma/web/ostatus/activity_representer.ex | 9 ++++++--- lib/pleroma/web/web_finger/web_finger.ex | 5 ++++- test/web/activity_pub/transmogrifier_test.exs | 6 ++++-- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index 00b9f74ff..2871a2544 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -146,7 +146,8 @@ def handle_incoming( %{"type" => "Like", "object" => object_id, "actor" => actor, "id" => id} = data ) do with %User{} = actor <- User.get_or_fetch_by_ap_id(actor), - {:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), + {:ok, object} <- + get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), {:ok, activity, object} <- ActivityPub.like(actor, object, id, false) do {:ok, activity} else @@ -158,7 +159,8 @@ def handle_incoming( %{"type" => "Announce", "object" => object_id, "actor" => actor, "id" => id} = data ) do with %User{} = actor <- User.get_or_fetch_by_ap_id(actor), - {:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), + {:ok, object} <- + get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), {:ok, activity, object} <- ActivityPub.announce(actor, object, id, false) do {:ok, activity} else @@ -209,7 +211,8 @@ def handle_incoming( end with %User{} = actor <- User.get_or_fetch_by_ap_id(actor), - {:ok, object} <- get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), + {:ok, object} <- + get_obj_helper(object_id) || ActivityPub.fetch_object_from_id(object_id), {:ok, activity} <- ActivityPub.delete(object, false) do {:ok, activity} else diff --git a/lib/pleroma/web/activity_pub/utils.ex b/lib/pleroma/web/activity_pub/utils.ex index 7a0762e9f..7b2bf8fa7 100644 --- a/lib/pleroma/web/activity_pub/utils.ex +++ b/lib/pleroma/web/activity_pub/utils.ex @@ -175,7 +175,8 @@ def make_like_data(%User{ap_id: ap_id} = actor, %{data: %{"id" => id}} = object, def update_element_in_object(property, element, object) do with new_data <- - object.data |> Map.put("#{property}_count", length(element)) + object.data + |> Map.put("#{property}_count", length(element)) |> Map.put("#{property}s", element), changeset <- Changeset.change(object, data: new_data), {:ok, object} <- Repo.update(changeset), diff --git a/lib/pleroma/web/oauth/oauth_controller.ex b/lib/pleroma/web/oauth/oauth_controller.ex index 6297b7bae..11dc1806f 100644 --- a/lib/pleroma/web/oauth/oauth_controller.ex +++ b/lib/pleroma/web/oauth/oauth_controller.ex @@ -63,7 +63,8 @@ def token_exchange(conn, %{"grant_type" => "authorization_code"} = params) do client_secret: params["client_secret"] ), fixed_token = fix_padding(params["code"]), - %Authorization{} = auth <- Repo.get_by(Authorization, token: fixed_token, app_id: app.id), + %Authorization{} = auth <- + Repo.get_by(Authorization, token: fixed_token, app_id: app.id), {:ok, token} <- Token.exchange_token(app, auth) do response = %{ token_type: "Bearer", diff --git a/lib/pleroma/web/ostatus/activity_representer.ex b/lib/pleroma/web/ostatus/activity_representer.ex index 2f28c456e..921a89bd0 100644 --- a/lib/pleroma/web/ostatus/activity_representer.ex +++ b/lib/pleroma/web/ostatus/activity_representer.ex @@ -131,7 +131,8 @@ def to_simple_form(%{data: %{"object" => %{"type" => "Note"}}} = activity, user, h.(activity.data["object"]["content"] |> String.replace(~r/[\n\r]/, ""))}, {:published, h.(inserted_at)}, {:updated, h.(updated_at)}, - {:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])}, + {:"ostatus:conversation", [ref: h.(activity.data["context"])], + h.(activity.data["context"])}, {:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []} ] ++ summary ++ @@ -162,7 +163,8 @@ def to_simple_form(%{data: %{"type" => "Like"}} = activity, user, with_author) d # For notes, federate the object id. {:id, h.(activity.data["object"])} ]}, - {:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])}, + {:"ostatus:conversation", [ref: h.(activity.data["context"])], + h.(activity.data["context"])}, {:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}, {:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []}, {:"thr:in-reply-to", [ref: to_charlist(activity.data["object"])], []} @@ -193,7 +195,8 @@ def to_simple_form(%{data: %{"type" => "Announce"}} = activity, user, with_autho {:content, [type: 'html'], ['RT #{retweeted_activity.data["object"]["content"]}']}, {:published, h.(inserted_at)}, {:updated, h.(updated_at)}, - {:"ostatus:conversation", [ref: h.(activity.data["context"])], h.(activity.data["context"])}, + {:"ostatus:conversation", [ref: h.(activity.data["context"])], + h.(activity.data["context"])}, {:link, [ref: h.(activity.data["context"]), rel: 'ostatus:conversation'], []}, {:link, [rel: 'self', type: ['application/atom+xml'], href: h.(activity.data["id"])], []}, {:"activity:object", retweeted_xml} diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger/web_finger.ex index e45c0ed8d..dc9ad2014 100644 --- a/lib/pleroma/web/web_finger/web_finger.ex +++ b/lib/pleroma/web/web_finger/web_finger.ex @@ -81,7 +81,10 @@ def represent_user(user, "JSON") do "href" => user.ap_id }, %{"rel" => "salmon", "href" => OStatus.salmon_path(user)}, - %{"rel" => "magic-public-key", "href" => "data:application/magic-public-key,#{magic_key}"}, + %{ + "rel" => "magic-public-key", + "href" => "data:application/magic-public-key,#{magic_key}" + }, %{"rel" => "self", "type" => "application/activity+json", "href" => user.ap_id}, %{ "rel" => "http://ostatus.org/schema/1.0/subscribe", diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 060ebe9f1..3dab59746 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -102,7 +102,8 @@ test "it works for incoming follow requests" do user = insert(:user) data = - File.read!("test/fixtures/mastodon-follow-activity.json") |> Poison.decode!() + File.read!("test/fixtures/mastodon-follow-activity.json") + |> Poison.decode!() |> Map.put("object", user.ap_id) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) @@ -118,7 +119,8 @@ test "it works for incoming likes" do {:ok, activity} = CommonAPI.post(user, %{"status" => "hello"}) data = - File.read!("test/fixtures/mastodon-like.json") |> Poison.decode!() + File.read!("test/fixtures/mastodon-like.json") + |> Poison.decode!() |> Map.put("object", activity.data["object"]["id"]) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)