Skip to content

Commit 11ed661

Browse files
committed
Merge branch 'develop' of https://github.com/code-corps/code-corps-api into develop
2 parents b2585e7 + 6463cd6 commit 11ed661

File tree

62 files changed

+1532
-890
lines changed

Some content is hidden

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

62 files changed

+1532
-890
lines changed

config/test.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ config :code_corps, site_url: "http://localhost:4200"
2222

2323
# speed up password hashing
2424
config :comeonin, :bcrypt_log_rounds, 4
25-
config :comeonin, :pbkdf2_rounds, 1
2625

2726
# CORS allowed origins
2827
config :code_corps, allowed_origins: ["http://localhost:4200"]

lib/code_corps/analytics/segment_data_extractor.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ defmodule CodeCorps.Analytics.SegmentDataExtractor do
77
def get_action(%Plug.Conn{private: %{phoenix_action: action}}), do: action
88
def get_action(_), do: nil
99

10+
@doc """
11+
Tries to extract project id from given resource.
12+
Returns `nil` if project id can't be extracted.
13+
"""
14+
@spec get_project_id(CodeCorps.ProjectUser.t) :: String.t | nil
15+
def get_project_id(%CodeCorps.ProjectUser{project_id: id}), do: "project_#{id}"
16+
def get_project_id(_), do: nil
17+
1018
@spec get_resource(Plug.Conn.t) :: struct
1119
def get_resource(%Plug.Conn{assigns: %{data: data}}), do: data
1220
# these are used for delete actions on records that support it

lib/code_corps/analytics/segment_event_name_builder.ex

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ defmodule CodeCorps.Analytics.SegmentEventNameBuilder do
1414
defp get_event_name(:update, %CodeCorps.DonationGoal{}) do
1515
"Updated Donation Goal"
1616
end
17-
defp get_event_name(:create, %CodeCorps.ProjectUser{}) do
18-
"Requested Project Membership"
19-
end
20-
defp get_event_name(:update, %CodeCorps.ProjectUser{}) do
21-
"Approved Project Membership"
22-
end
2317
defp get_event_name(:payment_succeeded, %CodeCorps.StripeInvoice{}) do
2418
"Processed Subscription Payment"
2519
end

lib/code_corps/analytics/segment_tracking_support.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ defmodule CodeCorps.Analytics.SegmentTrackingSupport do
1111
def includes?(:update, %CodeCorps.Comment{}), do: true
1212
def includes?(:create, %CodeCorps.DonationGoal{}), do: true
1313
def includes?(:update, %CodeCorps.DonationGoal{}), do: true
14-
def includes?(:create, %CodeCorps.ProjectUser{}), do: true
15-
def includes?(:update, %CodeCorps.ProjectUser{}), do: true
1614
def includes?(:create, %CodeCorps.StripeConnectAccount{}), do: true
1715
def includes?(:create, %CodeCorps.StripeConnectCharge{}), do: true
1816
def includes?(:create, %CodeCorps.StripeConnectPlan{}), do: true

lib/code_corps/analytics/segment_traits_builder.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,9 @@ defmodule CodeCorps.Analytics.SegmentTraitsBuilder do
225225
}
226226
end
227227
defp traits(%{token: _, user_id: _}), do: %{}
228+
defp traits(%{acceptor: user, project_user: project_user}) do
229+
project_user
230+
|> traits()
231+
|> Map.merge(%{acceptor_id: user.id, acceptor: user.username})
232+
end
228233
end

lib/code_corps/comment/service.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ defmodule CodeCorps.Comment.Service do
8484
defp create_on_github(%Comment{task: %Task{github_issue: github_issue}} = comment) do
8585
with {:ok, payload} <- comment |> GitHub.API.Comment.create(),
8686
{:ok, %GithubComment{} = github_comment} <-
87-
Sync.Comment.GithubComment.create_or_update_comment(github_issue, payload) do
87+
Sync.GithubComment.create_or_update_comment(github_issue, payload) do
8888
comment |> link_with_github_changeset(github_comment) |> Repo.update()
8989
else
9090
{:error, error} -> {:error, error}
@@ -103,7 +103,7 @@ defmodule CodeCorps.Comment.Service do
103103
) do
104104
with {:ok, payload} <- comment |> GitHub.API.Comment.update(),
105105
{:ok, %GithubComment{}} <-
106-
Sync.Comment.GithubComment.create_or_update_comment(github_issue, payload) do
106+
Sync.GithubComment.create_or_update_comment(github_issue, payload) do
107107
{:ok, comment}
108108
else
109109
{:error, error} -> {:error, error}

lib/code_corps/emails/message_initiated_by_project_email.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defmodule CodeCorps.Emails.MessageInitiatedByProjectEmail do
1111
WebClient
1212
}
1313

14-
@spec create(User.t, String.t) :: Bamboo.Email.t
14+
@spec create(Message.t, Conversation.t) :: Bamboo.Email.t
1515
def create(
1616
%Message{project: %Project{} = project},
1717
%Conversation{user: %User{} = user} = conversation) do

lib/code_corps/github/event/installation/installation.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ defmodule CodeCorps.GitHub.Event.Installation do
66

77
@behaviour CodeCorps.GitHub.Event.Handler
88

9-
alias CodeCorps.{GitHub.Sync, GitHub.Event.Installation}
9+
alias CodeCorps.{
10+
GitHub.Sync,
11+
GitHub.Event.Installation
12+
}
1013

1114

1215
@doc """
@@ -17,6 +20,7 @@ defmodule CodeCorps.GitHub.Event.Installation do
1720
1821
`CodeCorps.GitHub.Sync.installation_event/1`
1922
"""
23+
@impl CodeCorps.GitHub.Event.Handler
2024
@spec handle(map) ::
2125
Sync.installation_event_outcome() | {:error, :unexpected_payload}
2226
def handle(payload) do

lib/code_corps/github/event/installation_repositories/installation_repositories.ex

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ defmodule CodeCorps.GitHub.Event.InstallationRepositories do
1010

1111
alias CodeCorps.{
1212
GitHub.Sync,
13-
GithubRepo,
1413
GitHub.Event.InstallationRepositories
1514
}
1615

17-
@type outcome :: {:ok, list(GithubRepo.t())} |
18-
{:error, :unmatched_installation} |
19-
{:error, :unexpected_payload} |
20-
{:error, :validation_error_on_syncing_repos} |
21-
{:error, :unexpected_transaction_outcome}
22-
2316
@doc """
2417
Handles an "InstallationRepositories" GitHub Webhook event. The event could be
2518
of subtype "added" or "removed" and is handled differently based on that.
@@ -34,7 +27,10 @@ defmodule CodeCorps.GitHub.Event.InstallationRepositories do
3427
- if the GitHub payload for a repo is not matched with a record in our
3528
database, just skip deleting it
3629
"""
37-
@spec handle(map) :: outcome
30+
@impl CodeCorps.GitHub.Event.Handler
31+
@spec handle(map) ::
32+
Sync.installation_repositories_event_outcome() |
33+
{:error, :unexpected_payload}
3834
def handle(payload) do
3935
with {:ok, :valid} <- payload |> validate_payload() do
4036
Sync.installation_repositories_event(payload)

lib/code_corps/github/event/issue_comment/issue_comment.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ defmodule CodeCorps.GitHub.Event.IssueComment do
88
@behaviour CodeCorps.GitHub.Event.Handler
99

1010
alias CodeCorps.{
11-
GitHub,
11+
GitHub.Sync,
1212
GitHub.Event.IssueComment.Validator
1313
}
14-
alias GitHub.Sync
1514

1615
@doc ~S"""
1716
Handles the "IssueComment" GitHub webhook
@@ -23,7 +22,8 @@ defmodule CodeCorps.GitHub.Event.IssueComment do
2322
- sync the comment using `CodeCorps.GitHub.Sync.Comment`
2423
"""
2524
@impl CodeCorps.GitHub.Event.Handler
26-
@spec handle(map) :: {:ok, any} | {:error, atom}
25+
@spec handle(map) ::
26+
Sync.issue_comment_event_outcome() | {:error, :unexpected_payload}
2727
def handle(payload) do
2828
with {:ok, :valid} <- validate_payload(payload) do
2929
Sync.issue_comment_event(payload)

0 commit comments

Comments
 (0)