Skip to content

Commit f3933da

Browse files
committed
Merge branch 'main' of github.com:algora-io/console into feat/splits
2 parents 715275b + 9e6b3ac commit f3933da

File tree

95 files changed

+2077
-104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2077
-104
lines changed

config/config.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ config :algora, Oban,
3333
github_og_image: 5,
3434
notify_bounty: 1,
3535
notify_tip_intent: 1,
36-
notify_claim: 1
36+
notify_claim: 1,
37+
activity_notifier: 1,
38+
activity_mailer: 1
3739
]
3840

3941
# Configures the mailer

config/test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ config :algora,
4747
cloudflare_tunnel: System.get_env("CLOUDFLARE_TUNNEL"),
4848
swift_mode: false,
4949
auto_start_pollers: System.get_env("AUTO_START_POLLERS") == "true"
50+
51+
config :algora, :stripe,
52+
test_customer_id: System.get_env("STRIPE_TEST_CUSTOMER_ID"),
53+
test_account_id: System.get_env("STRIPE_TEST_ACCOUNT_ID")

coveralls.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"skip_files": [
3+
"lib/algora/integrations",
4+
"lib/algora/shared/*",
5+
"lib/algora/admin/admin.ex",
6+
"lib/algora_web/components",
7+
"lib/algora_web",
8+
"lib/mix/tasks",
9+
"priv/",
10+
"test/support"
11+
],
12+
"default_stop_words": [
13+
"defmodule",
14+
"defrecord",
15+
"defimpl",
16+
"def.+(.+\/\/.+).+do",
17+
"typed_schema",
18+
"use .+"
19+
],
20+
21+
"custom_stop_words": [
22+
],
23+
24+
"coverage_options": {
25+
"treat_no_relevant_lines_as_covered": true,
26+
"output_dir": "cover/",
27+
"html_filter_full_covered": true
28+
}
29+
}

lib/algora/accounts/accounts.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,16 @@ defmodule Algora.Accounts do
312312
Repo.one(query)
313313
end
314314

315+
def get_user_by_handle(handle) do
316+
query =
317+
from(u in User,
318+
where: u.handle == ^handle,
319+
select: u
320+
)
321+
322+
Repo.one(query)
323+
end
324+
315325
def get_access_token(%User{} = user) do
316326
case Repo.one(from(i in Identity, where: i.user_id == ^user.id and i.provider == "github")) do
317327
%Identity{provider_token: token} -> {:ok, token}

lib/algora/accounts/schemas/identity.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ defmodule Algora.Accounts.Identity do
44

55
alias Algora.Accounts.Identity
66
alias Algora.Accounts.User
7+
alias Algora.Activities.Activity
78

89
@derive {Inspect, except: [:provider_token, :provider_meta]}
910
typed_schema "identities" do
@@ -17,6 +18,8 @@ defmodule Algora.Accounts.Identity do
1718

1819
belongs_to :user, User
1920

21+
has_many :activities, {"identity_activities", Activity}, foreign_key: :assoc_id
22+
2023
timestamps()
2124
end
2225

@@ -40,6 +43,7 @@ defmodule Algora.Accounts.Identity do
4043
:provider_name,
4144
:provider_id
4245
])
46+
|> Activity.put_activity(%Identity{}, %{type: :identity_created})
4347
|> generate_id()
4448
|> validate_required([:provider_token, :provider_email, :provider_name, :provider_id])
4549
|> validate_length(:provider_meta, max: 10_000)
@@ -66,6 +70,7 @@ defmodule Algora.Accounts.Identity do
6670
:provider_name,
6771
:provider_id
6872
])
73+
|> Activity.put_activity(%Identity{}, %{type: :identity_created})
6974
|> generate_id()
7075
|> validate_required([:provider_token, :provider_email, :provider_name, :provider_id])
7176
|> validate_length(:provider_meta, max: 10_000)

lib/algora/accounts/schemas/user.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ defmodule Algora.Accounts.User do
44

55
alias Algora.Accounts.Identity
66
alias Algora.Accounts.User
7+
alias Algora.Activities.Activity
78
alias Algora.Bounties.Bounty
9+
alias Algora.Bounties.Tip
810
alias Algora.Contracts.Contract
911
alias Algora.MoneyUtils
1012
alias Algora.Organizations.Member
@@ -71,11 +73,16 @@ defmodule Algora.Accounts.User do
7173
field :og_title, :string
7274
field :og_image_url, :string
7375

76+
field :login_token, :string, virtual: true
77+
7478
has_many :identities, Identity
7579
has_many :memberships, Member, foreign_key: :user_id
7680
has_many :members, Member, foreign_key: :org_id
7781
has_many :owned_bounties, Bounty, foreign_key: :owner_id
7882
has_many :created_bounties, Bounty, foreign_key: :creator_id
83+
has_many :owned_tips, Tip, foreign_key: :owner_id
84+
has_many :created_tips, Tip, foreign_key: :creator_id
85+
has_many :received_tips, Tip, foreign_key: :recipient_id
7986
has_many :attempts, Algora.Bounties.Attempt
8087
has_many :claims, Algora.Bounties.Claim
8188
has_many :projects, Algora.Projects.Project
@@ -85,6 +92,7 @@ defmodule Algora.Accounts.User do
8592
has_many :connected_installations, Installation, foreign_key: :connected_user_id
8693
has_many :contractor_contracts, Contract, foreign_key: :contractor_id
8794
has_many :client_contracts, Contract, foreign_key: :client_id
95+
has_many :activities, {"user_activities", Activity}, foreign_key: :assoc_id
8896

8997
has_one :customer, Algora.Payments.Customer, foreign_key: :user_id
9098

@@ -247,6 +255,10 @@ defmodule Algora.Accounts.User do
247255
|> validate_timezone()
248256
end
249257

258+
def login_changeset(%User{} = user, params) do
259+
cast(user, params, [:email, :login_token])
260+
end
261+
250262
defp validate_email(changeset) do
251263
changeset
252264
|> validate_required([:email])
@@ -296,6 +308,10 @@ defmodule Algora.Accounts.User do
296308
|> unique_constraint([:provider, :provider_id])
297309
end
298310

311+
def is_admin_changeset(user, is_admin) do
312+
cast(user, %{is_admin: is_admin}, [:is_admin])
313+
end
314+
299315
def validate_timezone(changeset) do
300316
validate_inclusion(changeset, :timezone, Tzdata.zone_list())
301317
end

0 commit comments

Comments
 (0)