summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-08-19 14:10:11 +0200
committerlain <lain@soykaf.club>2020-08-19 14:10:11 +0200
commit9aae342e7a599c14dbe543a60db9626cba0d8371 (patch)
tree073a5d666d1064ee941a9df22dc04c421599d777
parent5316e231b0b007ce05bc1bffdf6ce0244749fb9e (diff)
parent5054a6aa9a6f29ad1e2c51710265f75f1324acf8 (diff)
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into features/validators-audio2
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--lib/mix/pleroma.ex2
-rw-r--r--lib/mix/tasks/pleroma/emoji.ex10
-rw-r--r--lib/pleroma/emails/user_email.ex31
-rw-r--r--test/emails/mailer_test.exs4
-rw-r--r--test/tasks/digest_test.exs2
-rw-r--r--test/tasks/email_test.exs2
7 files changed, 34 insertions, 19 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9e9107ce3..be0dd4773 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -194,7 +194,7 @@ amd64:
variables: &release-variables
MIX_ENV: prod
before_script: &before-release
- - apt install cmake -y
+ - apt-get update && apt-get install -y cmake
- echo "import Mix.Config" > config/prod.secret.exs
- mix local.hex --force
- mix local.rebar --force
diff --git a/lib/mix/pleroma.ex b/lib/mix/pleroma.ex
index 074492a46..fe9b0d16c 100644
--- a/lib/mix/pleroma.ex
+++ b/lib/mix/pleroma.ex
@@ -14,7 +14,7 @@ defmodule Mix.Pleroma do
:swoosh,
:timex
]
- @cachex_children ["object", "user"]
+ @cachex_children ["object", "user", "scrubber"]
@doc "Common functions to be reused in mix tasks"
def start_pleroma do
Pleroma.Config.Holder.save_default()
diff --git a/lib/mix/tasks/pleroma/emoji.ex b/lib/mix/tasks/pleroma/emoji.ex
index f4eaeac98..8f52ee98d 100644
--- a/lib/mix/tasks/pleroma/emoji.ex
+++ b/lib/mix/tasks/pleroma/emoji.ex
@@ -15,7 +15,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
{options, [], []} = parse_global_opts(args)
url_or_path = options[:manifest] || default_manifest()
- manifest = fetch_and_decode(url_or_path)
+ manifest = fetch_and_decode!(url_or_path)
Enum.each(manifest, fn {name, info} ->
to_print = [
@@ -42,7 +42,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
url_or_path = options[:manifest] || default_manifest()
- manifest = fetch_and_decode(url_or_path)
+ manifest = fetch_and_decode!(url_or_path)
for pack_name <- pack_names do
if Map.has_key?(manifest, pack_name) do
@@ -92,7 +92,7 @@ defmodule Mix.Tasks.Pleroma.Emoji do
])
)
- files = fetch_and_decode(files_loc)
+ files = fetch_and_decode!(files_loc)
IO.puts(IO.ANSI.format(["Unpacking ", :bright, pack_name]))
@@ -243,9 +243,11 @@ defmodule Mix.Tasks.Pleroma.Emoji do
IO.puts("Emoji packs have been reloaded.")
end
- defp fetch_and_decode(from) do
+ defp fetch_and_decode!(from) do
with {:ok, json} <- fetch(from) do
Jason.decode!(json)
+ else
+ {:error, error} -> raise "#{from} cannot be fetched. Error: #{error} occur."
end
end
diff --git a/lib/pleroma/emails/user_email.ex b/lib/pleroma/emails/user_email.ex
index 313533859..1d8c72ae9 100644
--- a/lib/pleroma/emails/user_email.ex
+++ b/lib/pleroma/emails/user_email.ex
@@ -107,25 +107,34 @@ defmodule Pleroma.Emails.UserEmail do
|> Enum.filter(&(&1.activity.data["type"] == "Create"))
|> Enum.map(fn notification ->
object = Pleroma.Object.normalize(notification.activity)
- object = update_in(object.data["content"], &format_links/1)
- %{
- data: notification,
- object: object,
- from: User.get_by_ap_id(notification.activity.actor)
- }
+ if not is_nil(object) do
+ object = update_in(object.data["content"], &format_links/1)
+
+ %{
+ data: notification,
+ object: object,
+ from: User.get_by_ap_id(notification.activity.actor)
+ }
+ end
end)
+ |> Enum.filter(& &1)
followers =
notifications
|> Enum.filter(&(&1.activity.data["type"] == "Follow"))
|> Enum.map(fn notification ->
- %{
- data: notification,
- object: Pleroma.Object.normalize(notification.activity),
- from: User.get_by_ap_id(notification.activity.actor)
- }
+ from = User.get_by_ap_id(notification.activity.actor)
+
+ if not is_nil(from) do
+ %{
+ data: notification,
+ object: Pleroma.Object.normalize(notification.activity),
+ from: User.get_by_ap_id(notification.activity.actor)
+ }
+ end
end)
+ |> Enum.filter(& &1)
unless Enum.empty?(mentions) do
styling = Config.get([__MODULE__, :styling])
diff --git a/test/emails/mailer_test.exs b/test/emails/mailer_test.exs
index 3da45056b..9e232d2a0 100644
--- a/test/emails/mailer_test.exs
+++ b/test/emails/mailer_test.exs
@@ -14,10 +14,10 @@ defmodule Pleroma.Emails.MailerTest do
subject: "Pleroma test email",
to: [{"Test User", "user1@example.com"}]
}
- setup do: clear_config([Pleroma.Emails.Mailer, :enabled])
+ setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
test "not send email when mailer is disabled" do
- Pleroma.Config.put([Pleroma.Emails.Mailer, :enabled], false)
+ clear_config([Pleroma.Emails.Mailer, :enabled], false)
Mailer.deliver(@email)
:timer.sleep(100)
diff --git a/test/tasks/digest_test.exs b/test/tasks/digest_test.exs
index eefbc8936..0b444c86d 100644
--- a/test/tasks/digest_test.exs
+++ b/test/tasks/digest_test.exs
@@ -17,6 +17,8 @@ defmodule Mix.Tasks.Pleroma.DigestTest do
:ok
end
+ setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
+
describe "pleroma.digest test" do
test "Sends digest to the given user" do
user1 = insert(:user)
diff --git a/test/tasks/email_test.exs b/test/tasks/email_test.exs
index 944c07064..c3af7ef68 100644
--- a/test/tasks/email_test.exs
+++ b/test/tasks/email_test.exs
@@ -16,6 +16,8 @@ defmodule Mix.Tasks.Pleroma.EmailTest do
:ok
end
+ setup do: clear_config([Pleroma.Emails.Mailer, :enabled], true)
+
describe "pleroma.email test" do
test "Sends test email with no given address" do
mail_to = Config.get([:instance, :email])