Merge branch 'feature/digest-email' into 'develop'
Feature/digest email See merge request pleroma/pleroma!1078
This commit is contained in:
commit
29807ef6a5
33 changed files with 658 additions and 17 deletions
33
lib/mix/tasks/pleroma/digest.ex
Normal file
33
lib/mix/tasks/pleroma/digest.ex
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
defmodule Mix.Tasks.Pleroma.Digest do
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "Manages digest emails"
|
||||
@moduledoc """
|
||||
Manages digest emails
|
||||
|
||||
## Send digest email since given date (user registration date by default)
|
||||
ignoring user activity status.
|
||||
|
||||
``mix pleroma.digest test <nickname> <since_date>``
|
||||
|
||||
Example: ``mix pleroma.digest test donaldtheduck 2019-05-20``
|
||||
"""
|
||||
def run(["test", nickname | opts]) do
|
||||
Mix.Pleroma.start_pleroma()
|
||||
|
||||
user = Pleroma.User.get_by_nickname(nickname)
|
||||
|
||||
last_digest_emailed_at =
|
||||
with [date] <- opts,
|
||||
{:ok, datetime} <- Timex.parse(date, "{YYYY}-{0M}-{0D}") do
|
||||
datetime
|
||||
else
|
||||
_ -> user.inserted_at
|
||||
end
|
||||
|
||||
patched_user = %{user | last_digest_emailed_at: last_digest_emailed_at}
|
||||
|
||||
_user = Pleroma.DigestEmailWorker.perform(patched_user)
|
||||
Mix.shell().info("Digest email have been sent to #{nickname} (#{user.email})")
|
||||
end
|
||||
end
|
||||
|
|
@ -183,6 +183,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
|
|||
)
|
||||
|
||||
secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
jwt_secret = :crypto.strong_rand_bytes(64) |> Base.encode64() |> binary_part(0, 64)
|
||||
signing_salt = :crypto.strong_rand_bytes(8) |> Base.encode64() |> binary_part(0, 8)
|
||||
{web_push_public_key, web_push_private_key} = :crypto.generate_key(:ecdh, :prime256v1)
|
||||
template_dir = Application.app_dir(:pleroma, "priv") <> "/templates"
|
||||
|
|
@ -200,6 +201,7 @@ defmodule Mix.Tasks.Pleroma.Instance do
|
|||
dbuser: dbuser,
|
||||
dbpass: dbpass,
|
||||
secret: secret,
|
||||
jwt_secret: jwt_secret,
|
||||
signing_salt: signing_salt,
|
||||
web_push_public_key: Base.url_encode64(web_push_public_key, padding: false),
|
||||
web_push_private_key: Base.url_encode64(web_push_private_key, padding: false),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue