File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ defmodule Algora.Bounties do
2020 alias Algora.Repo
2121 alias Algora.Util
2222 alias Algora.Workspace
23+ alias Algora.Workspace.Installation
2324 alias Algora.Workspace.Ticket
2425
2526 require Logger
@@ -523,13 +524,20 @@ defmodule Algora.Bounties do
523524 "Please specify an amount to tip (e.g. `/tip $100 @#{ recipient } `)"
524525
525526 true ->
527+ installation =
528+ case opts [ :installation_id ] do
529+ nil -> nil
530+ installation_id -> Repo . get_by ( Installation , provider: "github" , provider_id: to_string ( installation_id ) )
531+ end
532+
526533 query =
527534 URI . encode_query (
528535 amount: Money . to_decimal ( amount ) ,
529536 recipient: recipient ,
530537 owner: owner ,
531538 repo: repo ,
532- number: number
539+ number: number ,
540+ org_id: if ( installation , do: installation . connected_user_id )
533541 )
534542
535543 url = AlgoraWeb.Endpoint . url ( ) <> "/tip" <> "?" <> query
Original file line number Diff line number Diff line change @@ -2,22 +2,31 @@ defmodule AlgoraWeb.TipController do
22 use AlgoraWeb , :controller
33
44 alias Algora.Accounts
5+ alias Algora.Accounts.User
56 alias Algora.Bounties
7+ alias Algora.Repo
68 alias Algora.Workspace
79 alias AlgoraWeb.UserAuth
810
911 def create ( conn , % { "amount" => amount , "recipient" => recipient } = params ) do
1012 ticket_ref = extract_ticket_ref ( params )
1113
14+ owner_res =
15+ case params [ "org_id" ] do
16+ nil -> get_current_user ( conn )
17+ org_id -> Repo . fetch ( User , org_id )
18+ end
19+
1220 with { :ok , current_user } <- get_current_user ( conn ) ,
1321 % Money { } = amount <- Money . new ( :USD , amount ) ,
1422 { :ok , token } <- Accounts . get_access_token ( current_user ) ,
1523 { :ok , recipient_user } <- Workspace . ensure_user ( token , recipient ) ,
24+ { :ok , owner } <- owner_res ,
1625 { :ok , checkout_url } <-
1726 Bounties . create_tip (
1827 % {
1928 creator: current_user ,
20- owner: current_user ,
29+ owner: owner ,
2130 recipient: recipient_user ,
2231 amount: amount
2332 } ,
You can’t perform that action at this time.
0 commit comments