diff --git a/lib/cambiatus/workers/contribution_paypal_worker.ex b/lib/cambiatus/workers/contribution_paypal_worker.ex index 8cfad403..53ce3a92 100644 --- a/lib/cambiatus/workers/contribution_paypal_worker.ex +++ b/lib/cambiatus/workers/contribution_paypal_worker.ex @@ -24,7 +24,7 @@ defmodule Cambiatus.Workers.ContributionPaypalWorker do {:error, _} = error -> error - {:error, _, %{valid?: false}} -> + {:error, _, %{valid?: false}, _} -> {:error, :invalid_changeset} end end diff --git a/lib/cambiatus/workers/monthly_digest_worker.ex b/lib/cambiatus/workers/monthly_digest_worker.ex index d7ced497..8e415921 100644 --- a/lib/cambiatus/workers/monthly_digest_worker.ex +++ b/lib/cambiatus/workers/monthly_digest_worker.ex @@ -12,26 +12,28 @@ defmodule Cambiatus.Workers.MonthlyDigestWorker do alias Ecto.Multi def perform(_) do - transaction = - Community - |> Community.with_news_enabled() - |> Repo.all() - |> Repo.preload([ - [news: News.last_thirty_days()], - [members: User.accept_digest()], - :subdomain - ]) - |> Enum.filter(&Enum.any?(&1.news)) - |> Enum.reduce(Multi.new(), fn community, multi -> - Enum.reduce(community.members, multi, fn member, multi -> - Oban.insert( - multi, - "#{community.symbol}-#{member.account}", - DigestEmailWorker.new(%{community_id: community.symbol, account: member.account}) - ) - end) + Community + |> Community.with_news_enabled() + |> Repo.all() + |> Repo.preload([ + [news: News.last_thirty_days()], + [members: User.accept_digest()], + :subdomain + ]) + |> Enum.filter(&Enum.any?(&1.news)) + |> Enum.reduce(Multi.new(), fn community, multi -> + Enum.reduce(community.members, multi, fn member, multi -> + Oban.insert( + multi, + "#{community.symbol}-#{member.account}", + DigestEmailWorker.new(%{community_id: community.symbol, account: member.account}) + ) end) - - Repo.transaction(transaction) + end) + |> Repo.transaction() + |> case do + {:ok, _} = success -> success + {:error, stage, _, _} -> {:error, stage} + end end end