Hotlink logo instead of attachment

This commit is contained in:
Egor Kislitsyn 2020-02-11 23:33:05 +04:00
parent 6875ccb6bf
commit 50d9fcbe29
No known key found for this signature in database
GPG key ID: 1B49CB15B71E7805
5 changed files with 19 additions and 21 deletions

View file

@ -488,7 +488,7 @@
{"0 * * * *", Pleroma.Workers.Cron.StatsWorker}, {"0 * * * *", Pleroma.Workers.Cron.StatsWorker},
{"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker}, {"* * * * *", Pleroma.Workers.Cron.PurgeExpiredActivitiesWorker},
{"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker}, {"0 0 * * 0", Pleroma.Workers.Cron.DigestEmailsWorker},
{"0 0 * * *", Pleroma.Workers.NewUsersDigestWorker} {"0 0 * * *", Pleroma.Workers.Cron.NewUsersDigestWorker}
] ]
config :pleroma, :workers, config :pleroma, :workers,

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server # Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Emails.NewUsersDigestEmail do defmodule Pleroma.Emails.NewUsersDigestEmail do
@ -12,14 +12,10 @@ defp instance_notify_email do
def new_users(to, users_and_statuses) do def new_users(to, users_and_statuses) do
instance_name = Pleroma.Config.get([:instance, :name]) instance_name = Pleroma.Config.get([:instance, :name])
styling = Pleroma.Config.get([Pleroma.Emails.UserEmail, :styling]) styling = Pleroma.Config.get([Pleroma.Emails.UserEmail, :styling])
logo = Pleroma.Config.get([Pleroma.Emails.UserEmail, :logo])
logo_path = logo_url =
if is_nil(logo) do Pleroma.Web.Endpoint.url() <>
Path.join(:code.priv_dir(:pleroma), "static/static/logo.png") Pleroma.Config.get([:frontend_configurations, :pleroma_fe, :logo])
else
Path.join(Pleroma.Config.get([:instance, :static_dir]), logo)
end
new() new()
|> to({to.name, to.email}) |> to({to.name, to.email})
@ -29,8 +25,8 @@ def new_users(to, users_and_statuses) do
title: "New Users", title: "New Users",
users_and_statuses: users_and_statuses, users_and_statuses: users_and_statuses,
instance: instance_name, instance: instance_name,
styling: styling styling: styling,
logo_url: logo_url
}) })
|> attachment(Swoosh.Attachment.new(logo_path, filename: "logo.png", type: :inline))
end end
end end

View file

@ -128,7 +128,7 @@
<div align="center" class="img-container center" <div align="center" class="img-container center"
style="padding-right: 0px;padding-left: 0px;"> style="padding-right: 0px;padding-left: 0px;">
<!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr style="line-height:0px"><td style="padding-right: 0px;padding-left: 0px;" align="center"><![endif]--><img <!--[if mso]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr style="line-height:0px"><td style="padding-right: 0px;padding-left: 0px;" align="center"><![endif]--><img
align="center" alt="Image" border="0" class="center" src="cid:logo.png" align="center" alt="Image" border="0" class="center" src="<%= @logo_url %>"
style="text-decoration: none; -ms-interpolation-mode: bicubic; border: 0; height: 80px; width: auto; max-height: 80px; display: block;" style="text-decoration: none; -ms-interpolation-mode: bicubic; border: 0; height: 80px; width: auto; max-height: 80px; display: block;"
title="Image" height="80" /> title="Image" height="80" />
<!--[if mso]></td></tr></table><![endif]--> <!--[if mso]></td></tr></table><![endif]-->

View file

@ -1,8 +1,8 @@
# Pleroma: A lightweight social networking server # Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.NewUsersDigestWorker do defmodule Pleroma.Workers.Cron.NewUsersDigestWorker do
alias Pleroma.Activity alias Pleroma.Activity
alias Pleroma.Repo alias Pleroma.Repo
alias Pleroma.User alias Pleroma.User
@ -48,6 +48,7 @@ def perform(_args, _job) do
{user, total_statuses, latest_status} {user, total_statuses, latest_status}
end) end)
if users_and_statuses != [] do
%{is_admin: true} %{is_admin: true}
|> User.Query.build() |> User.Query.build()
|> Repo.all() |> Repo.all()
@ -55,4 +56,5 @@ def perform(_args, _job) do
|> Enum.each(&Pleroma.Emails.Mailer.deliver/1) |> Enum.each(&Pleroma.Emails.Mailer.deliver/1)
end end
end end
end
end end

View file

@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server # Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/> # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only # SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
@ -8,7 +8,7 @@ defmodule Pleroma.Workers.Cron.NewUsersDigestWorkerTest do
alias Pleroma.Tests.ObanHelpers alias Pleroma.Tests.ObanHelpers
alias Pleroma.Web.CommonAPI alias Pleroma.Web.CommonAPI
alias Pleroma.Workers.NewUsersDigestWorker alias Pleroma.Workers.Cron.NewUsersDigestWorker
test "it sends new users digest emails" do test "it sends new users digest emails" do
yesterday = NaiveDateTime.utc_now() |> Timex.shift(days: -1) yesterday = NaiveDateTime.utc_now() |> Timex.shift(days: -1)