From ffe028cd7392404c85ab65eca167a16e85b3f788 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 7 May 2018 18:11:37 +0200 Subject: [PATCH] More warning fixes. --- lib/pleroma/web/activity_pub/transmogrifier.ex | 2 +- lib/pleroma/web/activity_pub/views/user_view.ex | 8 ++++---- lib/pleroma/web/federator/federator.ex | 4 ++++ lib/pleroma/web/oauth/authorization.ex | 2 +- lib/pleroma/web/oauth/token.ex | 2 +- lib/pleroma/web/streamer.ex | 4 ++++ 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/pleroma/web/activity_pub/transmogrifier.ex b/lib/pleroma/web/activity_pub/transmogrifier.ex index a0e45510c..5f86f67cd 100644 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@ -74,7 +74,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do name = if String.starts_with?(name, ":") do - name = name |> String.slice(1..-2) + name |> String.slice(1..-2) else name end diff --git a/lib/pleroma/web/activity_pub/views/user_view.ex b/lib/pleroma/web/activity_pub/views/user_view.ex index a1f0be9ed..ffd76b529 100644 --- a/lib/pleroma/web/activity_pub/views/user_view.ex +++ b/lib/pleroma/web/activity_pub/views/user_view.ex @@ -147,21 +147,21 @@ defmodule Pleroma.Web.ActivityPub.UserView do end end - def collection(collection, iri, page, _total \\ nil) do + def collection(collection, iri, page, total \\ nil) do offset = (page - 1) * 10 items = Enum.slice(collection, offset, 10) items = Enum.map(items, fn user -> user.ap_id end) - total = _total || length(collection) + total = total || length(collection) map = %{ "id" => "#{iri}?page=#{page}", "type" => "OrderedCollectionPage", "partOf" => iri, - "totalItems" => length(collection), + "totalItems" => total, "orderedItems" => items } - if offset < length(collection) do + if offset < total do Map.put(map, "next", "#{iri}?page=#{page + 1}") end end diff --git a/lib/pleroma/web/federator/federator.ex b/lib/pleroma/web/federator/federator.ex index c4c18192c..f84af2f15 100644 --- a/lib/pleroma/web/federator/federator.ex +++ b/lib/pleroma/web/federator/federator.ex @@ -14,6 +14,10 @@ defmodule Pleroma.Web.Federator do @federating Keyword.get(@instance, :federating) @max_jobs 20 + def init(args) do + {:ok, args} + end + def start_link do spawn(fn -> # 1 minute diff --git a/lib/pleroma/web/oauth/authorization.ex b/lib/pleroma/web/oauth/authorization.ex index 94f44c9f2..23e8eb7b1 100644 --- a/lib/pleroma/web/oauth/authorization.ex +++ b/lib/pleroma/web/oauth/authorization.ex @@ -11,7 +11,7 @@ defmodule Pleroma.Web.OAuth.Authorization do field(:valid_until, :naive_datetime) field(:used, :boolean, default: false) belongs_to(:user, Pleroma.User) - belongs_to(:app, Pleroma.App) + belongs_to(:app, App) timestamps() end diff --git a/lib/pleroma/web/oauth/token.ex b/lib/pleroma/web/oauth/token.ex index 65abd78c8..343fc0c45 100644 --- a/lib/pleroma/web/oauth/token.ex +++ b/lib/pleroma/web/oauth/token.ex @@ -9,7 +9,7 @@ defmodule Pleroma.Web.OAuth.Token do field(:refresh_token, :string) field(:valid_until, :naive_datetime) belongs_to(:user, Pleroma.User) - belongs_to(:app, Pleroma.App) + belongs_to(:app, App) timestamps() end diff --git a/lib/pleroma/web/streamer.ex b/lib/pleroma/web/streamer.ex index 3375af841..33041ec12 100644 --- a/lib/pleroma/web/streamer.ex +++ b/lib/pleroma/web/streamer.ex @@ -3,6 +3,10 @@ defmodule Pleroma.Web.Streamer do require Logger alias Pleroma.{User, Notification} + def init(args) do + {:ok, args} + end + def start_link do spawn(fn -> # 30 seconds