@@ -4,7 +4,6 @@ defmodule Algora.Github.Poller.CommentConsumer do
4
4
5
5
alias Algora.Accounts
6
6
alias Algora.Bounties
7
- alias Algora.Github
8
7
alias Algora.Util
9
8
10
9
require Logger
@@ -25,40 +24,23 @@ defmodule Algora.Github.Poller.CommentConsumer do
25
24
end
26
25
27
26
defp run_command ( { :tip , args } , ticket_ref , _comment ) do
28
- amount = Keyword . get ( args , :amount )
29
- recipient = Keyword . get ( args , :recipient )
30
- owner = Keyword . get ( ticket_ref , :owner )
31
- repo = Keyword . get ( ticket_ref , :repo )
32
- number = Keyword . get ( ticket_ref , :number )
33
-
34
- query = URI . encode_query ( amount: Money . to_decimal ( amount ) , recipient: recipient )
35
- url = AlgoraWeb.Endpoint . url ( ) <> "/tip" <> "?" <> query
36
- body = "Please visit [Algora](#{ url } ) to complete your tip via Stripe."
37
-
38
- if Github . pat_enabled ( ) do
39
- Github . create_issue_comment ( Github . pat ( ) , owner , repo , number , body )
40
- else
41
- Logger . info ( """
42
- Github.create_issue_comment(Github.pat(), "#{ owner } ", "#{ repo } ", #{ number } ,
43
- \" \" \"
44
- #{ body }
45
- \" \" \" )
46
- """ )
47
-
48
- :ok
49
- end
27
+ Bounties . create_tip_intent ( % {
28
+ recipient: args [ :recipient ] ,
29
+ amount: args [ :amount ] ,
30
+ ticket_ref: % { owner: ticket_ref [ :owner ] , repo: ticket_ref [ :repo ] , number: ticket_ref [ :number ] }
31
+ } )
50
32
end
51
33
52
34
defp run_command ( { :bounty , args } , ticket_ref , comment ) do
53
- with { :ok , user } <- Accounts . fetch_user_by ( provider_id: to_string ( comment [ "user" ] [ "id" ] ) ) ,
54
- { :ok , amount } <- Keyword . fetch ( args , :amount ) do
55
- Bounties . create_bounty ( % {
56
- creator: user ,
57
- owner: user ,
58
- amount: amount ,
59
- ticket_ref: % { owner: ticket_ref [ :owner ] , repo: ticket_ref [ :repo ] , number: ticket_ref [ :number ] }
60
- } )
61
- else
35
+ case Accounts . fetch_user_by ( provider_id: to_string ( comment [ "user" ] [ "id" ] ) ) do
36
+ { :ok , user } ->
37
+ Bounties . create_bounty ( % {
38
+ creator: user ,
39
+ owner: user ,
40
+ amount: args [ : amount] ,
41
+ ticket_ref: % { owner: ticket_ref [ :owner ] , repo: ticket_ref [ :repo ] , number: ticket_ref [ :number ] }
42
+ } )
43
+
62
44
{ :error , _reason } = error ->
63
45
Logger . error ( "Failed to create bounty: #{ inspect ( error ) } " )
64
46
error
0 commit comments