瀏覽代碼

Merge branch 'bugfix/pleroma-email-naming' into 'develop'

Make the filename and module name of Pleroma.Emails.* orthogonal

See merge request pleroma/pleroma!1029
tags/v1.1.4
lambda 5 年之前
父節點
當前提交
184ae60b21
共有 15 個文件被更改,包括 39 次插入22 次删除
  1. +8
    -0
      Changelog.md
  2. +1
    -1
      config/config.exs
  3. +1
    -1
      config/dev.exs
  4. +1
    -1
      config/test.exs
  5. +4
    -4
      docs/config.md
  6. +1
    -1
      lib/pleroma/emails/admin_email.ex
  7. +1
    -1
      lib/pleroma/emails/mailer.ex
  8. +1
    -1
      lib/pleroma/emails/user_email.ex
  9. +2
    -2
      lib/pleroma/user.ex
  10. +2
    -2
      lib/pleroma/web/activity_pub/activity_pub.ex
  11. +7
    -2
      lib/pleroma/web/admin_api/admin_api_controller.ex
  12. +2
    -2
      lib/pleroma/web/twitter_api/twitter_api.ex
  13. +1
    -1
      test/web/admin_api/admin_api_controller_test.exs
  14. +4
    -2
      test/web/twitter_api/twitter_api_controller_test.exs
  15. +3
    -1
      test/web/twitter_api/twitter_api_test.exs

+ 8
- 0
Changelog.md 查看文件

@@ -0,0 +1,8 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]
### Changed
- Configuration: move from Pleroma.Mailer to Pleroma.Emails.Mailer

+ 1
- 1
config/config.exs 查看文件

@@ -413,7 +413,7 @@ config :ueberauth,

config :pleroma, :auth, oauth_consumer_strategies: oauth_consumer_strategies

config :pleroma, Pleroma.Mailer, adapter: Swoosh.Adapters.Sendmail
config :pleroma, Pleroma.Emails.Mailer, adapter: Swoosh.Adapters.Sendmail

config :prometheus, Pleroma.Web.Endpoint.MetricsExporter, path: "/api/pleroma/app_metrics"



+ 1
- 1
config/dev.exs 查看文件

@@ -18,7 +18,7 @@ config :pleroma, Pleroma.Web.Endpoint,
watchers: [],
secure_cookie_flag: false

config :pleroma, Pleroma.Mailer, adapter: Swoosh.Adapters.Local
config :pleroma, Pleroma.Emails.Mailer, adapter: Swoosh.Adapters.Local

# ## SSL Support
#


+ 1
- 1
config/test.exs 查看文件

@@ -21,7 +21,7 @@ config :pleroma, Pleroma.Upload, filters: [], link_name: false

config :pleroma, Pleroma.Uploaders.Local, uploads: "test/uploads"

config :pleroma, Pleroma.Mailer, adapter: Swoosh.Adapters.Test
config :pleroma, Pleroma.Emails.Mailer, adapter: Swoosh.Adapters.Test

# Configure your database
config :pleroma, Pleroma.Repo,


+ 4
- 4
docs/config.md 查看文件

@@ -31,14 +31,14 @@ This filter replaces the filename (not the path) of an upload. For complete obfu

* `text`: Text to replace filenames in links. If empty, `{random}.extension` will be used.

## Pleroma.Mailer
## Pleroma.Emails.Mailer
* `adapter`: one of the mail adapters listed in [Swoosh readme](https://github.com/swoosh/swoosh#adapters), or `Swoosh.Adapters.Local` for in-memory mailbox.
* `api_key` / `password` and / or other adapter-specific settings, per the above documentation.

An example for Sendgrid adapter:

```exs
config :pleroma, Pleroma.Mailer,
config :pleroma, Pleroma.Emails.Mailer,
adapter: Swoosh.Adapters.Sendgrid,
api_key: "YOUR_API_KEY"
```
@@ -46,7 +46,7 @@ config :pleroma, Pleroma.Mailer,
An example for SMTP adapter:

```exs
config :pleroma, Pleroma.Mailer,
config :pleroma, Pleroma.Emails.Mailer,
adapter: Swoosh.Adapters.SMTP,
relay: "smtp.gmail.com",
username: "YOUR_USERNAME@gmail.com",
@@ -317,7 +317,7 @@ Pleroma has the following queues:

* `federator_outgoing` - Outgoing federation
* `federator_incoming` - Incoming federation
* `mailer` - Email sender, see [`Pleroma.Mailer`](#pleroma-mailer)
* `mailer` - Email sender, see [`Pleroma.Emails.Mailer`](#pleroma-emails-mailer)
* `transmogrifier` - Transmogrifier
* `web_push` - Web push notifications
* `scheduled_activities` - Scheduled activities, see [`Pleroma.ScheduledActivities`](#pleromascheduledactivity)


+ 1
- 1
lib/pleroma/emails/admin_email.ex 查看文件

@@ -2,7 +2,7 @@
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.AdminEmail do
defmodule Pleroma.Emails.AdminEmail do
@moduledoc "Admin emails"

import Swoosh.Email


+ 1
- 1
lib/pleroma/emails/mailer.ex 查看文件

@@ -2,7 +2,7 @@
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Mailer do
defmodule Pleroma.Emails.Mailer do
use Swoosh.Mailer, otp_app: :pleroma

def deliver_async(email, config \\ []) do


+ 1
- 1
lib/pleroma/emails/user_email.ex 查看文件

@@ -2,7 +2,7 @@
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.UserEmail do
defmodule Pleroma.Emails.UserEmail do
@moduledoc "User emails"

import Swoosh.Email


+ 2
- 2
lib/pleroma/user.ex 查看文件

@@ -279,8 +279,8 @@ defmodule Pleroma.User do
if user.info.confirmation_pending &&
Pleroma.Config.get([:instance, :account_activation_required]) do
user
|> Pleroma.UserEmail.account_confirmation_email()
|> Pleroma.Mailer.deliver_async()
|> Pleroma.Emails.UserEmail.account_confirmation_email()
|> Pleroma.Emails.Mailer.deliver_async()
else
{:ok, :noop}
end


+ 2
- 2
lib/pleroma/web/activity_pub/activity_pub.ex 查看文件

@@ -450,8 +450,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
:ok <- maybe_federate(activity) do
Enum.each(User.all_superusers(), fn superuser ->
superuser
|> Pleroma.AdminEmail.report(actor, account, statuses, content)
|> Pleroma.Mailer.deliver_async()
|> Pleroma.Emails.AdminEmail.report(actor, account, statuses, content)
|> Pleroma.Emails.Mailer.deliver_async()
end)

{:ok, activity}


+ 7
- 2
lib/pleroma/web/admin_api/admin_api_controller.ex 查看文件

@@ -238,8 +238,13 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
!Pleroma.Config.get([:instance, :registrations_open]),
{:ok, invite_token} <- UserInviteToken.create_invite(),
email <-
Pleroma.UserEmail.user_invitation_email(user, invite_token, email, params["name"]),
{:ok, _} <- Pleroma.Mailer.deliver(email) do
Pleroma.Emails.UserEmail.user_invitation_email(
user,
invite_token,
email,
params["name"]
),
{:ok, _} <- Pleroma.Emails.Mailer.deliver(email) do
json_response(conn, :no_content, "")
end
end


+ 2
- 2
lib/pleroma/web/twitter_api/twitter_api.ex 查看文件

@@ -4,10 +4,10 @@

defmodule Pleroma.Web.TwitterAPI.TwitterAPI do
alias Pleroma.Activity
alias Pleroma.Mailer
alias Pleroma.Emails.Mailer
alias Pleroma.Emails.UserEmail
alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.UserEmail
alias Pleroma.UserInviteToken
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.CommonAPI


+ 1
- 1
test/web/admin_api/admin_api_controller_test.exs 查看文件

@@ -318,7 +318,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
refute token_record.used

Swoosh.TestAssertions.assert_email_sent(
Pleroma.UserEmail.user_invitation_email(
Pleroma.Emails.UserEmail.user_invitation_email(
user,
token_record,
recipient_email,


+ 4
- 2
test/web/twitter_api/twitter_api_controller_test.exs 查看文件

@@ -1064,7 +1064,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id)

Swoosh.TestAssertions.assert_email_sent(
Pleroma.UserEmail.password_reset_email(user, token_record.token)
Pleroma.Emails.UserEmail.password_reset_email(user, token_record.token)
)
end
end
@@ -1163,7 +1163,9 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
|> assign(:user, user)
|> post("/api/account/resend_confirmation_email?email=#{user.email}")

Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
Swoosh.TestAssertions.assert_email_sent(
Pleroma.Emails.UserEmail.account_confirmation_email(user)
)
end
end



+ 3
- 1
test/web/twitter_api/twitter_api_test.exs 查看文件

@@ -325,7 +325,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do

assert user.info.confirmation_pending

Swoosh.TestAssertions.assert_email_sent(Pleroma.UserEmail.account_confirmation_email(user))
Swoosh.TestAssertions.assert_email_sent(
Pleroma.Emails.UserEmail.account_confirmation_email(user)
)
end

test "it registers a new user and parses mentions in the bio" do


Loading…
取消
儲存