diff --git a/lib/code_corps/emails/emails.ex b/lib/code_corps/emails/emails.ex index 4ed0b32f5..529d06324 100644 --- a/lib/code_corps/emails/emails.ex +++ b/lib/code_corps/emails/emails.ex @@ -1,46 +1,66 @@ defmodule CodeCorps.Emails do - alias CodeCorps.Emails.{API, Tasks, Transmissions} + alias CodeCorps.{ + Conversation, + ConversationPart, + Emails.API, + Emails.Tasks, + Emails.Transmissions, + Message, + OrganizationInvite, + Project, + ProjectUser, + StripeConnectCharge, + User + } defdelegate create_templates, to: Tasks defdelegate update_templates, to: Tasks + @spec send_forgot_password_email(User.t, String.t) :: API.transmission_result def send_forgot_password_email(user, token) do user |> Transmissions.ForgotPassword.build(token) |> API.send_transmission end - def send_message_initiated_by_project_email(message, conversation) do + @spec send_message_initiated_by_project_email(Message.t, Conversation.t) :: API.transmission_result + def send_message_initiated_by_project_email(%Message{} = message, %Conversation{} = conversation) do message |> Transmissions.MessageInitiatedByProject.build(conversation) |> API.send_transmission end - def send_organization_invite_email(invite) do + @spec send_organization_invite_email(OrganizationInvite.t) :: API.transmission_result + def send_organization_invite_email(%OrganizationInvite{} = invite) do invite |> Transmissions.OrganizationInvite.build |> API.send_transmission end - def send_project_approval_request_email(project) do + @spec send_project_approval_request_email(Project.t) :: API.transmission_result + def send_project_approval_request_email(%Project{} = project) do project |> Transmissions.ProjectApprovalRequest.build |> API.send_transmission end - def send_project_approved_email(project) do + @spec send_project_approved_email(Project.t) :: API.transmission_result + def send_project_approved_email(%Project{} = project) do project |> Transmissions.ProjectApproved.build |> API.send_transmission end - def send_project_user_acceptance_email(project_user) do + @spec send_project_user_acceptance_email(ProjectUser.t) :: API.transmission_result + def send_project_user_acceptance_email(%ProjectUser{} = project_user) do project_user |> Transmissions.ProjectUserAcceptance.build |> API.send_transmission end - def send_project_user_request_email(project_user) do + @spec send_project_user_request_email(ProjectUser.t) :: API.transmission_result + def send_project_user_request_email(%ProjectUser{} = project_user) do project_user |> Transmissions.ProjectUserRequest.build |> API.send_transmission end - def send_receipt_email(charge, invoice) do + @spec send_receipt_email(StripeConnectCharge.t, Stripe.Invoice.t) :: API.transmission_result + def send_receipt_email(%StripeConnectCharge{} = charge, %Stripe.Invoice{} = invoice) do case charge |> Transmissions.Receipt.build(invoice) do %SparkPost.Transmission{} = transmission -> transmission |> API.send_transmission @@ -48,7 +68,8 @@ defmodule CodeCorps.Emails do end end - def send_reply_to_conversation_email(part, user) do + @spec send_reply_to_conversation_email(ConversationPart.t, User.t) :: API.transmission_result + def send_reply_to_conversation_email(%ConversationPart{} = part, %User{} = user) do part |> Transmissions.ReplyToConversation.build(user) |> API.send_transmission diff --git a/lib/code_corps/messages/messages.ex b/lib/code_corps/messages/messages.ex index 23353a98e..a6e3c01ee 100644 --- a/lib/code_corps/messages/messages.ex +++ b/lib/code_corps/messages/messages.ex @@ -47,7 +47,7 @@ defmodule CodeCorps.Messages do @doc ~S""" Gets a `CodeCorps.Conversation` record """ - @spec get_conversation(integer) :: Conversation.t + @spec get_conversation(integer) :: Conversation.t | nil def get_conversation(id) do Conversation |> Repo.get(id) end @@ -59,7 +59,7 @@ defmodule CodeCorps.Messages do @doc ~S""" Gets a `CodeCorps.ConversationPart` record """ - @spec get_part(integer) :: Conversation.t + @spec get_part(integer) :: ConversationPart.t | nil def get_part(id) do ConversationPart |> Repo.get(id) end