code_corps v0.0.1 CodeCorps.GitHub.Sync.User.RecordLinker View Source
In charge of finding a user to link with a given record given a GitHub API payload containing the user.
The only entry point is link_to/2.
Link to this section Summary
Functions
Finds or creates a user using information in the resource and the GitHub API payload
Link to this section Types
Link to this type
result()
View Source
result() :: {:ok, CodeCorps.User.t()} | {:error, Ecto.Changeset.t()} | {:error, :multiple_users}
Link to this section Functions
Link to this function
find_or_create_disassociated_user(attrs)
View Source
find_or_create_disassociated_user(map()) :: {:ok, CodeCorps.User.t()}
Link to this function
link_to(comment, map)
View Source
link_to(CodeCorps.GithubComment.t() | CodeCorps.GithubIssue.t(), map()) :: result()
Finds or creates a user using information in the resource and the GitHub API payload.
The process is as follows:
- Find all affected records and extract their user data.
Search for the user in our database.
- If we match a single user, then the resource should be related to that user.
- If there are no matching users, then the resource was created on GitHub by someone who does not have a matching GitHub-connected Code Corps account. We create a placeholder user account until that GitHub user is claimed by a Code Corps user.
- If there are multiple matching users, this is an unexpected scenario and should error out.