Skip to content

Commit 35e197f

Browse files
committed
fix: skip PR merge notif on autopay
1 parent 8d274bc commit 35e197f

File tree

1 file changed

+31
-27
lines changed

1 file changed

+31
-27
lines changed

lib/algora_web/controllers/webhooks/github_controller.ex

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,34 +244,38 @@ defmodule AlgoraWeb.Webhooks.GithubController do
244244
end
245245
end
246246

247-
unpaid_bounties =
248-
Enum.filter(
249-
bounties,
250-
&case autopay_result do
251-
:ok -> &1.id != autopayable_bounty.id
252-
_ -> true
253-
end
254-
)
247+
if autopay_result do
248+
autopay_result
249+
else
250+
unpaid_bounties =
251+
Enum.filter(
252+
bounties,
253+
&case autopay_result do
254+
:ok -> &1.id != autopayable_bounty.id
255+
_ -> true
256+
end
257+
)
255258

256-
sponsors_to_notify =
257-
unpaid_bounties
258-
|> Enum.map(&(&1.creator || &1.owner))
259-
|> Enum.map_join(", ", &"@#{&1.provider_login}")
260-
261-
if unpaid_bounties != [] do
262-
names =
263-
claims
264-
|> Enum.map(fn c -> "@#{c.user.provider_login}" end)
265-
|> Algora.Util.format_name_list()
266-
267-
Github.create_issue_comment(
268-
token,
269-
primary_claim.target.repository.user.provider_login,
270-
primary_claim.target.repository.name,
271-
primary_claim.target.number,
272-
"🎉 The pull request of #{names} has been merged. The bounty can be rewarded [here](#{Claim.reward_url(primary_claim)})" <>
273-
if(sponsors_to_notify == "", do: "", else: "\n\ncc #{sponsors_to_notify}")
274-
)
259+
sponsors_to_notify =
260+
unpaid_bounties
261+
|> Enum.map(&(&1.creator || &1.owner))
262+
|> Enum.map_join(", ", &"@#{&1.provider_login}")
263+
264+
if unpaid_bounties != [] do
265+
names =
266+
claims
267+
|> Enum.map(fn c -> "@#{c.user.provider_login}" end)
268+
|> Algora.Util.format_name_list()
269+
270+
Github.create_issue_comment(
271+
token,
272+
primary_claim.target.repository.user.provider_login,
273+
primary_claim.target.repository.name,
274+
primary_claim.target.number,
275+
"🎉 The pull request of #{names} has been merged. The bounty can be rewarded [here](#{Claim.reward_url(primary_claim)})" <>
276+
if(sponsors_to_notify == "", do: "", else: "\n\ncc #{sponsors_to_notify}")
277+
)
278+
end
275279
end
276280

277281
:ok

0 commit comments

Comments
 (0)