From acaa7c5419759dfb9ed253fce864e7fbd29cfe5e Mon Sep 17 00:00:00 2001 From: The BEAM Bot <157067248+thebeambot@users.noreply.github.com> Date: Thu, 24 Oct 2024 15:47:54 -0400 Subject: [PATCH 1/2] chore: sync files with beam-community/common-config (#681) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/common-config.yaml | 2 +- .github/workflows/pr.yaml | 3 +++ .github/workflows/release.yaml | 3 +-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/common-config.yaml b/.github/workflows/common-config.yaml index fa20cb90..d98d0246 100644 --- a/.github/workflows/common-config.yaml +++ b/.github/workflows/common-config.yaml @@ -38,7 +38,7 @@ jobs: uses: stordco/actions-elixir/setup@v1 with: github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} - elixir-version: "1.15" + elixir-version: "1.16" otp-version: "26.0" - name: Sync diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index a176a040..1b07ab71 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -13,6 +13,9 @@ on: jobs: Title: + permissions: + pull-requests: read + if: ${{ github.event_name == 'pull_request' }} name: Check Title runs-on: ubuntu-latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 674f5c2c..335c8a96 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -14,9 +14,8 @@ jobs: steps: - id: release name: Release - uses: google-github-actions/release-please-action@v4 + uses: googleapis/release-please-action@v4 with: - command: manifest config-file: .github/release-please-config.json manifest-file: .github/release-please-manifest.json release-type: elixir From 37f420c5ecad799fbf3c3b3449e4c59d1bc55c80 Mon Sep 17 00:00:00 2001 From: Maarten Jacobs Date: Tue, 15 Oct 2024 18:09:11 +0200 Subject: [PATCH 2/2] interceptor before normalizing so we can use the rich user info before it gets stripped by the formatter --- lib/bamboo/mailer.ex | 8 ++++---- test/support/deny_list_interceptor.ex | 12 ++++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/bamboo/mailer.ex b/lib/bamboo/mailer.ex index 7f44effa..2307dd1f 100644 --- a/lib/bamboo/mailer.ex +++ b/lib/bamboo/mailer.ex @@ -203,8 +203,8 @@ defmodule Bamboo.Mailer do @doc false def deliver_now(adapter, email, config, opts) do - with {:ok, email} <- validate_and_normalize(email, adapter), - %Bamboo.Email{blocked: false} = email <- apply_interceptors(email, config) do + with %Bamboo.Email{blocked: false} = email <- apply_interceptors(email, config), + {:ok, email} <- validate_and_normalize(email, adapter) do if empty_recipients?(email) do debug_unsent(email) @@ -244,8 +244,8 @@ defmodule Bamboo.Mailer do @doc false def deliver_later(adapter, email, config) do - with {:ok, email} <- validate_and_normalize(email, adapter), - %Bamboo.Email{blocked: false} = email <- apply_interceptors(email, config) do + with %Bamboo.Email{blocked: false} = email <- apply_interceptors(email, config), + {:ok, email} <- validate_and_normalize(email, adapter) do if empty_recipients?(email) do debug_unsent(email) else diff --git a/test/support/deny_list_interceptor.ex b/test/support/deny_list_interceptor.ex index 9750657e..bc2b001a 100644 --- a/test/support/deny_list_interceptor.ex +++ b/test/support/deny_list_interceptor.ex @@ -3,11 +3,19 @@ defmodule Bamboo.DenyListInterceptor do @deny_list ["blocked@blocked.com"] - def call(email) do - if Enum.any?(email.to, &(elem(&1, 1) in @deny_list)) do + def call(%{to: recipients} = email) when is_list(recipients) do + if Enum.any?(recipients, &(&1 in @deny_list)) do Bamboo.Email.block(email) else email end end + + def call(%{to: recipient} = email) when recipient in @deny_list do + Bamboo.Email.block(email) + end + + def call(email) do + email + end end