Fix Credo warnings

This commit is contained in:
Roman Chvanikov 2019-04-20 19:57:43 +07:00
parent 60f213bb1a
commit 724311e151
5 changed files with 8 additions and 6 deletions

View file

@ -187,7 +187,7 @@ defmodule Pleroma.Application do
end end
end end
defp after_supervisor_start() do defp after_supervisor_start do
with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest], with digest_config <- Application.get_env(:pleroma, :email_notifications)[:digest],
true <- digest_config[:active], true <- digest_config[:active],
%Crontab.CronExpression{} = schedule <- %Crontab.CronExpression{} = schedule <-

View file

@ -4,7 +4,7 @@ defmodule Pleroma.DigestEmailWorker do
# alias Pleroma.User # alias Pleroma.User
def run() do def run do
Logger.warn("Running digester") Logger.warn("Running digester")
config = Application.get_env(:pleroma, :email_notifications)[:digest] config = Application.get_env(:pleroma, :email_notifications)[:digest]
negative_interval = -Map.fetch!(config, :interval) negative_interval = -Map.fetch!(config, :interval)
@ -14,7 +14,7 @@ defmodule Pleroma.DigestEmailWorker do
now = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second) now = NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
from(u in inactive_users_query, from(u in inactive_users_query,
where: fragment("? #> '{\"email_notifications\",\"digest\"}' @> 'true'", u.info), where: fragment(~s(? #> '{"email_notifications","digest"}' @> 'true'), u.info),
where: u.last_digest_emailed_at < datetime_add(^now, ^negative_interval, "day"), where: u.last_digest_emailed_at < datetime_add(^now, ^negative_interval, "day"),
select: u select: u
) )

View file

@ -1,7 +1,9 @@
defmodule Pleroma.Web.Mailer.SubscriptionController do defmodule Pleroma.Web.Mailer.SubscriptionController do
use Pleroma.Web, :controller use Pleroma.Web, :controller
alias Pleroma.{JWT, Repo, User} alias Pleroma.JWT
alias Pleroma.Repo
alias Pleroma.User
def unsubscribe(conn, %{"token" => encoded_token}) do def unsubscribe(conn, %{"token" => encoded_token}) do
with {:ok, token} <- Base.decode64(encoded_token), with {:ok, token} <- Base.decode64(encoded_token),

View file

@ -8,7 +8,7 @@ defmodule Pleroma.Mixfile do
elixir: "~> 1.7", elixir: "~> 1.7",
elixirc_paths: elixirc_paths(Mix.env()), elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(), compilers: [:phoenix, :gettext] ++ Mix.compilers(),
# elixirc_options: [warnings_as_errors: true], elixirc_options: [warnings_as_errors: true],
xref: [exclude: [:eldap]], xref: [exclude: [:eldap]],
start_permanent: Mix.env() == :prod, start_permanent: Mix.env() == :prod,
aliases: aliases(), aliases: aliases(),

View file

@ -335,7 +335,7 @@ defmodule Pleroma.NotificationTest do
recent_notifications_ids = recent_notifications_ids =
user2 user2
|> Notification.for_user_since( |> Notification.for_user_since(
NaiveDateTime.add(NaiveDateTime.utc_now(), -5 * 86400, :second) NaiveDateTime.add(NaiveDateTime.utc_now(), -5 * 86_400, :second)
) )
|> Enum.map(& &1.id) |> Enum.map(& &1.id)