Local copy of Pleroma, an ActivityPub server software. Contains modifications running live on fedi.underscore.world
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

digest.ex 917B

123456789101112131415161718192021222324252627282930313233
  1. defmodule Mix.Tasks.Pleroma.Digest do
  2. use Mix.Task
  3. @shortdoc "Manages digest emails"
  4. @moduledoc """
  5. Manages digest emails
  6. ## Send digest email since given date (user registration date by default)
  7. ignoring user activity status.
  8. ``mix pleroma.digest test <nickname> <since_date>``
  9. Example: ``mix pleroma.digest test donaldtheduck 2019-05-20``
  10. """
  11. def run(["test", nickname | opts]) do
  12. Mix.Pleroma.start_pleroma()
  13. user = Pleroma.User.get_by_nickname(nickname)
  14. last_digest_emailed_at =
  15. with [date] <- opts,
  16. {:ok, datetime} <- Timex.parse(date, "{YYYY}-{0M}-{0D}") do
  17. datetime
  18. else
  19. _ -> user.inserted_at
  20. end
  21. patched_user = %{user | last_digest_emailed_at: last_digest_emailed_at}
  22. _user = Pleroma.DigestEmailWorker.perform(patched_user)
  23. Mix.shell().info("Digest email have been sent to #{nickname} (#{user.email})")
  24. end
  25. end