-
Notifications
You must be signed in to change notification settings - Fork 86
Add new message emails #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new message emails #1321
Conversation
conversation_url: project |> conversation_url(conversation), | ||
name: user.first_name, | ||
project_title: project.title, | ||
subject: "#{user.first_name} has posted a reply on #{project.title}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different from the user email primarily because this could be a reply by any participant, including another admin/owner.
Feel free to word it differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might change some language here but need to think on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
"#{user.first_name} replied to a message in #{project.title}"
lib/code_corps/messages/emails.ex
Outdated
""" | ||
@spec notify_of_new_message(Message.t) :: :ok | ||
def notify_of_new_message(%Message{initiated_by: "admin"} = message) do | ||
message = message |> Repo.preload(@message_preloads) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These explicit preloads are ugly, but it's an "internal" module, so it would be a matter of doing them here, or up higher, within the main messages context.
[message: [:author, [project: :organization]]], | ||
:user | ||
] | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, ugly, same as above.
In this case, I might actually prefer doing an explicit sql query instead.
lib/code_corps/messages/emails.ex
Outdated
# we match against admin initiated only, because it's unclear who | ||
# message.author is for user-initiated messages, or who the email recipient | ||
# would be, assuming the message.author is the user who initiated the message | ||
@spec send_message_for_project_emails(ConversationPart.t) :: :ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the comment says
- who gets notified of an email sent by a user to a project? I know we don't have it yet, but still
- who gets assigned as the message.author. Having it be identical to conversation.user seems redundant/confusing. Should we allow it blank in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think our conversation earlier got it right. Can you comment here what we said?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the idea was
When a user messages a project, all project admins and owners receive an email.
When a project admin/owner replies to the conversation, from that point on, only participating users receive emails. That means whoever send it initially, whoever replied, and whoever decided to join in at a later time.
@joshsmith The logic is in, but I'm hoping it could be done a bit better. Does post mark allow specifying a separate template "submodel" for each recipient? That would allow us to just fetch a list of recipients and send the project email to all of them in one request. Sparkpost allows something like that, so I was hoping Postmark would to. |
@joshsmith Also, I'm not sure if only participants of the conversation should be notified of new replies, or if all project members of admin or higher should be. If we want to change that, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs the template ids to be added to the config.
This is also generally confusing to me. It looks like we're missing an email for a message from a user to a project (which admittedly we don't have in the front-end yet, so perhaps can come later). But I think the naming conventions here no longer match up with the original intention or the current usage.
It seems like we need three email types:
- conversation replies, which go to all participants in a conversation
- new message to a project (i.e. initiated_by user), which goes to all a project's admins
- new message to some unknown number of
n
users (i.e. initiated_by admin), which goes to all the conversation'sn
users
Given that, we should maybe have emails that are:
ReplyToConversationEmail
- currentlyMessageForProjectEmail
MessageInitiatedByProjectEmail
- currentlyMessageForUserEmail
MessageInitiatedByUserEmail
- currently not implemented
conversation_url: project |> conversation_url(conversation), | ||
name: user.first_name, | ||
project_title: project.title, | ||
subject: "#{user.first_name} has posted a reply on #{project.title}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe:
"#{user.first_name} replied to a message in #{project.title}"
I think the 3 new types would make sense. In this case, that would mean
Then we add The logic would have to change a bit to. The Also note that with conversation part types, we might have to name it differently and word it a bit differently to. |
I’ll get to work making the modifications then and create an issue to do the |
I think the For sending a notification for the conversation part, we need to:
That should be everyone who's participating. |
59a8674
to
33fc482
Compare
33fc482
to
98e1ea0
Compare
@joshsmith I figured it would be simpler with the new email types. Agree with the logic 👍 |
What's in this PR?
Adds emails for messages.
References
Fixes #1311