1 defmodule Mix.Tasks.Pleroma.Digest do
3 alias Mix.Tasks.Pleroma.Common
5 @shortdoc "Manages digest emails"
9 ## Send digest email since given date (user registration date by default)
10 ignoring user activity status.
12 ``mix pleroma.digest test <nickname> <since_date>``
14 Example: ``mix pleroma.digest test donaldtheduck 2019-05-20``
16 def run(["test", nickname | opts]) do
17 Common.start_pleroma()
19 user = Pleroma.User.get_by_nickname(nickname)
21 last_digest_emailed_at =
23 {:ok, datetime} <- Timex.parse(date, "{YYYY}-{0M}-{0D}") do
29 patched_user = %{user | last_digest_emailed_at: last_digest_emailed_at}
31 :ok = Pleroma.DigestEmailWorker.run([patched_user])
32 Mix.shell().info("Digest email have been sent to #{nickname} (#{user.email})")