@@ -2,6 +2,7 @@ defmodule Algora.Github.Poller.CommentConsumer do
22 @ moduledoc false
33 use Oban.Worker , queue: :comment_consumers
44
5+ alias Algora.Accounts
56 alias Algora.Bounties
67 alias Algora.Github
78 alias Algora.Util
@@ -50,15 +51,13 @@ defmodule Algora.Github.Poller.CommentConsumer do
5051 end
5152
5253 defp run_command ( { :bounty , args } , ticket_ref , comment ) do
53- # TODO: use user's own token if available
54- token = Github.TokenPool . get_token ( )
55-
5654 owner = Keyword . get ( ticket_ref , :owner )
5755 repo = Keyword . get ( ticket_ref , :repo )
5856 number = Keyword . get ( ticket_ref , :number )
5957
60- with { :ok , amount } <- Keyword . fetch ( args , :amount ) ,
61- { :ok , user } <- Workspace . ensure_user ( token , extract_actor ( comment ) ) ,
58+ with { :ok , user } <- Accounts . fetch_user_by ( provider_id: to_string ( comment [ "user" ] [ "id" ] ) ) ,
59+ { :ok , token } <- Accounts . get_access_token ( user ) ,
60+ { :ok , amount } <- Keyword . fetch ( args , :amount ) ,
6261 { :ok , ticket } <- Workspace . ensure_ticket ( token , owner , repo , number ) ,
6362 { :ok , _bounty } <-
6463 Bounties . create_bounty ( % {
@@ -94,6 +93,4 @@ defmodule Algora.Github.Poller.CommentConsumer do
9493 error
9594 end
9695 end
97-
98- defp extract_actor ( % { "user" => % { "login" => login } } ) , do: login
9996end
0 commit comments