projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'chore/fix-mix-env' into 'develop'
[akkoma]
/
lib
/
pleroma
/
emails
/
mailer.ex
diff --git
a/lib/pleroma/emails/mailer.ex
b/lib/pleroma/emails/mailer.ex
index bb534f6026cd31860e490d3d86f9bff7447cb398..c68550beed312b08a3964e403dfd2ead97916e73 100644
(file)
--- a/
lib/pleroma/emails/mailer.ex
+++ b/
lib/pleroma/emails/mailer.ex
@@
-1,5
+1,5
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
21
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.Mailer do
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.Mailer do
@@
-9,8
+9,7
@@
defmodule Pleroma.Emails.Mailer do
The module contains functions to delivery email using Swoosh.Mailer.
"""
The module contains functions to delivery email using Swoosh.Mailer.
"""
- alias Pleroma.Repo
- alias Pleroma.Workers.Mailer, as: MailerWorker
+ alias Pleroma.Workers.MailerWorker
alias Swoosh.DeliveryError
@otp_app :pleroma
alias Swoosh.DeliveryError
@otp_app :pleroma
@@
-19,8
+18,6
@@
defmodule Pleroma.Emails.Mailer do
@spec enabled?() :: boolean()
def enabled?, do: Pleroma.Config.get([__MODULE__, :enabled])
@spec enabled?() :: boolean()
def enabled?, do: Pleroma.Config.get([__MODULE__, :enabled])
- defdelegate worker_args(queue), to: Pleroma.Workers.Helper
-
@doc "add email to queue"
def deliver_async(email, config \\ []) do
encoded_email =
@doc "add email to queue"
def deliver_async(email, config \\ []) do
encoded_email =
@@
-28,9
+25,7
@@
defmodule Pleroma.Emails.Mailer do
|> :erlang.term_to_binary()
|> Base.encode64()
|> :erlang.term_to_binary()
|> Base.encode64()
- %{"op" => "email", "encoded_email" => encoded_email, "config" => config}
- |> MailerWorker.new(worker_args(:mailer))
- |> Repo.insert()
+ MailerWorker.enqueue("email", %{"encoded_email" => encoded_email, "config" => config})
end
@doc "callback to perform send email from queue"
end
@doc "callback to perform send email from queue"
@@
-40,6
+35,11
@@
defmodule Pleroma.Emails.Mailer do
def deliver(email, config \\ [])
def deliver(email, config) do
def deliver(email, config \\ [])
def deliver(email, config) do
+ # temporary hackney fix until hackney max_connections bug is fixed
+ # https://git.pleroma.social/pleroma/pleroma/-/issues/2101
+ email =
+ Swoosh.Email.put_private(email, :hackney_options, ssl_options: [versions: [:"tlsv1.2"]])
+
case enabled?() do
true -> Swoosh.Mailer.deliver(email, parse_config(config))
false -> {:error, :deliveries_disabled}
case enabled?() do
true -> Swoosh.Mailer.deliver(email, parse_config(config))
false -> {:error, :deliveries_disabled}