Skip to content
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

Emails from same research note should display in same thread #7194

Open
anthony-zhou opened this issue Jan 10, 2020 · 4 comments
Open

Emails from same research note should display in same thread #7194

anthony-zhou opened this issue Jan 10, 2020 · 4 comments

Comments

@anthony-zhou
Copy link
Member

@anthony-zhou anthony-zhou commented Jan 10, 2020

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from groups underrepresented in free and open source software!

We know that the process of creating a pull request is the biggest barrier for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new, and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Comment below. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!

  • 📝 Update the file $FILENAME in the $REPO repository (press the little pen Icon) and edit the line as shown below.

See this page for some help in taking your first steps!

The issue

As noted in #6230, comments and like messages from multiple people on the same research note show up as separate threads in an email inbox. Instead, they should show up in the same thread. In order to achieve this, we have to make sure the titles of the emails match exactly.

The fix

In the files subscription_mailer.rb and comment_mailer.rb, there are different methods for each type of event (e.g., when a note is updated, liked, or initially created. To make all the messages show up in the same email thread, we need to make all the subject lines look the same.

Changes to make in subscription_mailer.rb

Let's make all the subject lines look like this one, on line 7:

subject = '[PublicLab] ' + (node.has_power_tag('question') ? 'Question: ' : '') + node.title + " (##{node.id}) "

First, replace the following three lines with the exact text from line 7 (above):

subject = "[PublicLab] #{user.username} liked your " +
(node.has_power_tag('question') ? 'question' : 'research note') +
" (##{node.id})"

Then, in the notify_tag_added method, paste the exact text from line 7 right below the method header (i.e., right before the line saying @tag = tag):

def notify_tag_added(node, tag, tagging_user)
@tag = tag
@node = node
@tags = node.tags.collect(&:name).join(',')
@tagging_user = tagging_user
given_tags = node.tags.reject { |t| t == tag }
users_to_email = tag.followers_who_dont_follow_tags(given_tags)
users_with_everything_tag = Tag.followers('everything')
final_users_ids = nil
if !users_to_email.nil? && !users_with_everything_tag.nil?
final_users_ids = users_to_email.collect(&:id) - users_with_everything_tag.collect(&:uid)
elsif !users_to_email.nil?
final_users_ids = users_to_email.collect(&:id)
end
final_users_to_email = User.find(final_users_ids)
recipients = []
final_users_to_email.each do |user|
unless user.id == tagging_user.id
recipients << user.email
end
end
@footer = feature('email-footer')
mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients,
subject: "#{node.title} (##{node.id})"
)
end

Finally, on this line:

subject: "#{node.title} (##{node.id})"

Replace "#{node.title} (##{node.id})" with subject.

Changes to make in comment_mailer.rb

Change line 11 of the file:

mail(to: user.email, subject: "New comment on #{comment.parent.title} (##{comment.parent.id}) - #c#{comment.id} ")

to match line 18:

mail(to: user.email, subject: "New comment on #{comment.node.title} (##{comment.node.id}) - #c#{comment.id}")

  • 💾 Commit your changes

  • 🔀 Start a Pull Request. There are two ways how you can start a pull request:

  1. If you are familiar with the terminal or would like to learn it, here is a great tutorial on how to send a pull request using the terminal.

  2. You can also edit files directly in your browser and open a pull request from there.

  • 🏁 Done Ask in comments for a review :)

Please keep us updated

💬 - We encourage contributors to be respectful to the community and provide an update within a week of claiming a first-timers-only issue. We're happy to keep it assigned to you as long as you need if you update us with a request for more time or help, but if we don't see any activity a week after you claim it we may reassign it to give someone else a chance. Thank you in advance!

If this happens to you, don't sweat it! Grab another open issue.

Is someone else already working on this?

🔗- We encourage contributors to link to the original issue in their pull request so all users can easily see if someone's already started on it.

👥- If someone seems stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!

🤔 Questions?

Leave a comment below!

@anthony-zhou

This comment has been minimized.

Copy link
Member Author

@anthony-zhou anthony-zhou commented Jan 10, 2020

@publiclab/reviewers As for the changes requested in #6230 for comment_mailer.rb, I'm not sure if we want the two statements to use comment.node or comment.parent, so I haven't added them to this FTO yet.

Match each other, and making this one:

mail(to: user.email, subject: "New comment on #{comment.parent.title} (##{comment.parent.id}) - #c#{comment.id} ")

and this one:

mail(to: user.email, subject: "New comment on #{comment.node.title} (##{comment.node.id}) - #c#{comment.id}")

also identical... that is, the email subjects should all be the same for this set of emails!

Which of these two statements would we like to use, what's the difference, and should those changes be part of the same issue or a separate one?

@cesswairimu

This comment has been minimized.

Copy link
Collaborator

@cesswairimu cesswairimu commented Jan 11, 2020

hey @anthony-zhou, thanks for opening this.
.parent will check if there is an answer associated with the comment then return the node that belongs to the answer, if not, just return the node(which ideally should be the same node as calling .node.....I believe the two methods returns the same node furthermore answers model might be deprecated soon so we can just call .node..makes sense? Thanks

@developer22-university

This comment has been minimized.

Copy link

@developer22-university developer22-university commented Jan 12, 2020

I AM CLAIMING THIS ISSUE @anthony-zhou

@anthony-zhou

This comment has been minimized.

Copy link
Member Author

@anthony-zhou anthony-zhou commented Jan 13, 2020

@cesswairimu Thanks for the info. I updated the issue with your answer. @developer22-university Please see the updated issue for one additional change to make in comment_mailer.rb. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.