@@ -8,6 +8,7 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
88 alias Algora.Github
99 alias Algora.Payments.Transaction
1010 alias Algora.Repo
11+ alias Algora.Workspace.Installation
1112 alias Algora.Workspace.Ticket
1213
1314 require Logger
@@ -41,7 +42,7 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
4142 where: tx . type == :transfer ,
4243 select_merge: % { user: user }
4344 ) do
44- installation = Repo . get ( Installation , connected_user_id : ticket . repository . user . id )
45+ installation = Repo . get_by ( Installation , provider_user_id : ticket . repository . user . id )
4546 body = "🎉🎈 @#{ transaction . user . provider_login } has been awarded **#{ transaction . net_amount } **! 🎈🎊"
4647
4748 do_perform ( ticket_ref , body , installation )
@@ -50,15 +51,16 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
5051
5152 defp do_perform ( ticket_ref , body , nil ) do
5253 Github . try_without_installation ( & Github . create_issue_comment / 5 , [
53- ticket_ref [ " owner" ] ,
54- ticket_ref [ " repo" ] ,
55- ticket_ref [ " number" ] ,
54+ ticket_ref . owner ,
55+ ticket_ref . repo ,
56+ ticket_ref . number ,
5657 body
5758 ] )
5859 end
5960
6061 defp do_perform ( ticket_ref , body , installation ) do
61- { :ok , token } = Github . get_installation_token ( installation . id )
62- Github . create_issue_comment ( token , ticket_ref [ "owner" ] , ticket_ref [ "repo" ] , ticket_ref [ "number" ] , body )
62+ with { :ok , token } <- Github . get_installation_token ( installation . provider_id ) do
63+ Github . create_issue_comment ( token , ticket_ref . owner , ticket_ref . repo , ticket_ref . number , body )
64+ end
6365 end
6466end
0 commit comments