formatting the code
authorMaksim Pechnikov <parallel588@gmail.com>
Tue, 4 Dec 2018 14:48:55 +0000 (17:48 +0300)
committerMaksim Pechnikov <parallel588@gmail.com>
Tue, 4 Dec 2018 14:48:55 +0000 (17:48 +0300)
lib/pleroma/http/connection.ex
lib/pleroma/http/http.ex
test/formatter_test.exs
test/support/http_request_mock.ex
test/web/activity_pub/activity_pub_controller_test.exs
test/web/activity_pub/transmogrifier_test.exs

index f64d4e18e2f35750cbfbc1baed4a3a512e2050b4..5e8f2aabd1b3ed26b70ea548cae283da232962a3 100644 (file)
@@ -1,4 +1,8 @@
 defmodule Pleroma.HTTP.Connection do
+  @moduledoc """
+  Connection for http-requests.
+  """
+
   @hackney_options [pool: :default]
   @adapter Application.get_env(:tesla, :adapter)
 
index 59afacf4cd54c5fc4659b6e9307dd111dcb4fd8b..4ab12ed3ade7041f2d0572dd6db8648ed387f15f 100644 (file)
@@ -1,8 +1,10 @@
 defmodule Pleroma.HTTP do
-  require HTTPoison
   alias Pleroma.HTTP.Connection
   alias Pleroma.HTTP.RequestBuilder, as: Builder
 
+  @doc """
+  Builds and perform http request.
+  """
   def request(method, url, body \\ "", headers \\ [], options \\ []) do
     options =
       process_request_options(options)
@@ -19,6 +21,7 @@ defmodule Pleroma.HTTP do
   end
 
   defp process_sni_options(options, nil), do: options
+
   defp process_sni_options(options, url) do
     uri = URI.parse(url)
     host = uri.host |> to_charlist()
index d5c74a321eeb165341975b944fb20ef819af4adf..5d745510f083b2d2b2a1103d0caeebebfcb8e1af 100644 (file)
@@ -4,6 +4,7 @@ defmodule Pleroma.FormatterTest do
   use Pleroma.DataCase
 
   import Pleroma.Factory
+
   setup_all do
     Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
     :ok
index c1b1c858910f1595e09a71ce8e0dbcf76c41c9d3..391342ad78bf464ae8331352d9f7b05b3a5ee40c 100644 (file)
@@ -14,7 +14,7 @@ defmodule HttpRequestMock do
       res
     else
       {_, r} = error ->
-        #Logger.warn(r)
+        # Logger.warn(r)
         error
     end
   end
@@ -27,13 +27,17 @@ defmodule HttpRequestMock do
     {:ok,
      %Tesla.Env{
        status: 200,
-       body: File.read!(
-         "test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json"
-       )
+       body:
+         File.read!("test/fixtures/httpoison_mock/https___osada.macgirvin.com_channel_mike.json")
      }}
   end
 
-  def get("https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://osada.macgirvin.com/.well-known/webfinger?resource=acct:mike@osada.macgirvin.com",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -41,8 +45,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
-    _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://social.heldscal.la/.well-known/webfinger?resource=https://social.heldscal.la/user/29191",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -58,8 +66,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
-    _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://pawoo.net/.well-known/webfinger?resource=acct:https://pawoo.net/users/pekorino",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -67,7 +79,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom", _, _, _) do
+  def get(
+        "https://social.stopwatchingus-heidelberg.de/api/statuses/user_timeline/18330.atom",
+        _,
+        _,
+        _
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -75,8 +92,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
-    _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://social.stopwatchingus-heidelberg.de/.well-known/webfinger?resource=acct:https://social.stopwatchingus-heidelberg.de/user/18330",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -92,8 +113,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
-    _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://mamot.fr/.well-known/webfinger?resource=acct:https://mamot.fr/users/Skruyb",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
@@ -101,7 +126,12 @@ defmodule HttpRequestMock do
      }}
   end
 
-  def get("https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la", _, _, [Accept: "application/xrd+xml,application/jrd+json"]) do
+  def get(
+        "https://social.heldscal.la/.well-known/webfinger?resource=nonexistant@social.heldscal.la",
+        _,
+        _,
+        Accept: "application/xrd+xml,application/jrd+json"
+      ) do
     {:ok,
      %Tesla.Env{
        status: 200,
index 41475911038fb06dbe02cea6bae34f603fdccbff..980f43553b6810e9ffd2616fbbfa273f7a1d1053 100644 (file)
@@ -4,10 +4,12 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
   alias Pleroma.Web.ActivityPub.{UserView, ObjectView}
   alias Pleroma.{Repo, User}
   alias Pleroma.Activity
+
   setup_all do
     Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
     :ok
   end
+
   describe "/relay" do
     test "with the relay active, it returns the relay user", %{conn: conn} do
       res =
index eeb0cb5cf8291c400783cd7dcbdd8b3bdd63a259..fa526a2226e2ebd8cd272e1fcd35dbed85c39edd 100644 (file)
@@ -11,6 +11,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
 
   import Pleroma.Factory
   alias Pleroma.Web.CommonAPI
+
   setup_all do
     Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
     :ok