@@ -8,6 +8,7 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
8
8
alias Algora.Github
9
9
alias Algora.Payments.Transaction
10
10
alias Algora.Repo
11
+ alias Algora.Workspace.Installation
11
12
alias Algora.Workspace.Ticket
12
13
13
14
require Logger
@@ -41,7 +42,7 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
41
42
where: tx . type == :transfer ,
42
43
select_merge: % { user: user }
43
44
) 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 )
45
46
body = "🎉🎈 @#{ transaction . user . provider_login } has been awarded **#{ transaction . net_amount } **! 🎈🎊"
46
47
47
48
do_perform ( ticket_ref , body , installation )
@@ -50,15 +51,16 @@ defmodule Algora.Bounties.Jobs.NotifyTransfer do
50
51
51
52
defp do_perform ( ticket_ref , body , nil ) do
52
53
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 ,
56
57
body
57
58
] )
58
59
end
59
60
60
61
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
63
65
end
64
66
end
0 commit comments