Skip to content

Commit 2b348f3

Browse files
committed
fix miscellanea
1 parent 402f5c6 commit 2b348f3

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

lib/algora/bounties/jobs/notify_transfer.ex

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6466
end

lib/algora/integrations/github/github.ex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ defmodule Algora.Github do
4949
if pat_enabled() do
5050
apply(function, [pat() | args])
5151
else
52-
{module, name} = Function.info(function, :name)
53-
function_name = "#{module}.#{name}"
52+
{_, module} = Function.info(function, :module)
53+
{_, name} = Function.info(function, :name)
54+
function_name = String.trim_leading("#{module}.#{name}", "Elixir.")
5455

5556
formatted_args =
5657
Enum.map_join(args, ", ", fn

lib/algora/payments/payments.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,10 @@ defmodule Algora.Payments do
418418
provider: "stripe",
419419
type: :transfer,
420420
status: :initialized,
421+
tip_id: credit.tip_id,
422+
bounty_id: credit.bounty_id,
423+
contract_id: credit.contract_id,
424+
claim_id: credit.claim_id,
421425
user_id: credit.user_id,
422426
gross_amount: credit.net_amount,
423427
net_amount: credit.net_amount,
@@ -427,6 +431,10 @@ defmodule Algora.Payments do
427431
|> Algora.Validations.validate_positive(:gross_amount)
428432
|> Algora.Validations.validate_positive(:net_amount)
429433
|> foreign_key_constraint(:user_id)
434+
|> foreign_key_constraint(:tip_id)
435+
|> foreign_key_constraint(:bounty_id)
436+
|> foreign_key_constraint(:contract_id)
437+
|> foreign_key_constraint(:claim_id)
430438
|> Repo.insert()
431439
end
432440

0 commit comments

Comments
 (0)