Skip to content

Commit 5503856

Browse files
committed
add admin notifs
1 parent 33114f1 commit 5503856

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

lib/algora/activities/discord_views.ex

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,42 @@ defmodule Algora.Activities.DiscordViews do
4545
}
4646
end
4747

48+
def render(%{type: :transaction_succeeded, assoc: tx}) do
49+
tx = Repo.preload(tx, [:user, linked_transaction: [:user]])
50+
51+
%{
52+
embeds: [
53+
%{
54+
color: 0x6366F1,
55+
title: "#{tx.net_amount} paid!",
56+
author: %{
57+
name: tx.linked_transaction.user.name,
58+
icon_url: tx.linked_transaction.user.avatar_url,
59+
url: "#{AlgoraWeb.Endpoint.url()}/org/#{tx.linked_transaction.user.handle}"
60+
},
61+
footer: %{
62+
text: tx.user.name,
63+
icon_url: tx.user.avatar_url
64+
},
65+
thumbnail: %{url: tx.user.avatar_url},
66+
fields: [
67+
%{
68+
name: "Sender",
69+
value: tx.linked_transaction.user.name,
70+
inline: false
71+
},
72+
%{
73+
name: "Recipient",
74+
value: tx.user.name,
75+
inline: false
76+
}
77+
],
78+
url: "#{AlgoraWeb.Endpoint.url()}/org/#{tx.linked_transaction.user.handle}",
79+
timestamp: tx.succeeded_at
80+
}
81+
]
82+
}
83+
end
84+
4885
def render(_activity), do: nil
4986
end

test/algora_web/controllers/webhooks/stripe_controller_test.exs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,7 @@ defmodule AlgoraWeb.Webhooks.StripeControllerTest do
9595
assert_enqueued(worker: Notifier, args: %{"activity_id" => tip_tx.id})
9696
assert_enqueued(worker: Notifier, args: %{"activity_id" => contract_tx.id})
9797

98-
refute_enqueued(worker: SendEmail, args: %{"activity_id" => bounty_tx.id})
99-
refute_enqueued(worker: SendEmail, args: %{"activity_id" => tip_tx.id})
100-
refute_enqueued(worker: SendEmail, args: %{"activity_id" => contract_tx.id})
101-
102-
Enum.map(all_enqueued(worker: Notifier), fn job ->
103-
perform_job(Notifier, job.args)
104-
end)
98+
Enum.map(all_enqueued(worker: Notifier), fn job -> perform_job(Notifier, job.args) end)
10599

106100
assert_enqueued(worker: SendEmail, args: %{"activity_id" => bounty_tx.id})
107101
assert_enqueued(worker: SendEmail, args: %{"activity_id" => tip_tx.id})

0 commit comments

Comments
 (0)