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

Option to not receive email notifications for topics you follow #6867

Closed
jywarren opened this issue Nov 27, 2019 · 14 comments
Closed

Option to not receive email notifications for topics you follow #6867

jywarren opened this issue Nov 27, 2019 · 14 comments
Labels
break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration discussion feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute

Comments

@jywarren
Copy link
Member

Similarly to #4543, and in relation to #6787, we should make an option in https://publiclab.org/settings to turn off email notifications for topics you follow. You might still get notified via the Notifications API (like, smartphone notifications, etc), and you'd still see topics you follow listed on your dashboard (new dashboard at #6072).

New note email notifications are generated from this segment of code:

def notify_node_creation(node)
subject = '[PublicLab] ' +
(node.has_power_tag('question') ? 'Question: ' : '') +
node.title +
" (##{node.id}) "
@node = node
@tags = node.tags.collect(&:name).join(',')
@footer = feature('email-footer')
recipients = Tag.subscribers(node.tags).values
.map { |obj| obj[:user] }
.collect(&:email)
recipients += node.author.followers.collect(&:email)
recipients.uniq!
mail(
to: "notifications@#{ActionMailer::Base.default_url_options[:host]}",
bcc: recipients,
subject: subject
)
end

We need to modify this line, to make an exception for a) people who have a user tag showing they don't want to get email notifications for things they follow, so notifications:none perhaps? (we need to discuss/disambiguate this vs. the existing tags we use on the /settings page...)

recipients = Tag.subscribers(node.tags).values

You can determine if a user has a tag like this:

UserTag.exists?(user.id, 'digest:weekly')

https://github.com/publiclab/plots2/blob/master/app/views/users/settings.html.erb

(Possibly useful links: The settings were previously worked on in #2985 and #3119 and digests are sent from https://github.com/publiclab/plots2/blob/7e20e413e94925a4f021f14e61a36b7ebb270e25/app/jobs/digest_mail_job.rb)

@jywarren jywarren added feature explains that the issue is to add a new feature break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration discussion help wanted requires help by anyone willing to contribute labels Nov 27, 2019
@jywarren
Copy link
Member Author

jywarren commented Nov 27, 2019

Existing tags for this kind of thing are formatted like: notifications:mentioned so perhaps notifications:noemail (just so it specifically means no emails, as opposed to turning off other kinds of notifications)?

Then we'll need a UI on this page, https://publiclab.org/settings :

image

Noting we have to add an exemption for digest:daily and digest:weekly as well, while we're at it.

Basic switch for this purpose might be labeled:

Do you want to receive email notifications for topics you follow? [ ]

@steviepubliclab
Copy link
Contributor

Screen Shot 2019-11-27 at 1 01 13 PM

@jywarren
Copy link
Member Author

jywarren commented Nov 27, 2019

So the switch we'd have to add to the subscription_mailer.rb file would be:

recipients += node.author.followers.collect(&:email) 
recipients -= UserTag.where(value: 'digest:weekly').collect(&:user).collect(&:email) # exclude anyone who uses weekly digests
recipients -= UserTag.where(value: 'digest:daily').collect(&:user).collect(&:email) # exclude anyone who uses daily digests
recipients -= UserTag.where(value: 'notifications:noemail').collect(&:user).collect(&:email) # exclude anyone who doesn't want email notifications for topics they follow

Then we'd need to modify the tests to ensure this is working!

And here's a good guide to the UI changes that'd have to happen, based on the last time we added settings to this page!

https://github.com/publiclab/plots2/pull/6105/files

@jywarren jywarren added this to the Tagging and topics milestone Nov 27, 2019
@steviepubliclab
Copy link
Contributor

steviepubliclab commented Nov 27, 2019

Text edit suggestions:

Email Notifications
I want to receive an email:

  • Whenever there are new posts on topics I follow
  • In a daily digest
  • In a weekly digest
  • Never

I want to be notified by email for:

  • Likes on my posts
  • Comments on my posts
  • Comments on posts I’ve commented on
  • Comments on posts I've liked

Browser Notifications
I want to receive browser notifications:

  • When I’m mentioned
  • When someone likes my work
  • Never

@jywarren
Copy link
Member Author

OK awesome; the only thing is that "Never" wouldn't be an option that can have an "on/off" status, so I think for now we'll leave that off? If you'd like we can follow up with something where you click that and it automatically turns off the others, but it's a little more involved. Thanks!

@ebarry
Copy link
Member

ebarry commented Jan 7, 2020

Regarding the "never" option, while the text Stevie suggested may not work for "never" in that way, does the graphic she drew up work?

@jywarren
Copy link
Member Author

jywarren commented Jan 7, 2020

Yes, but ONLY for the first "All topics" row, so for now we will probably keep the page layout as it is.

If in the future we set out to do a per-topic notifications settings system, we could adopt the table style view. Thanks!

@jywarren
Copy link
Member Author

jywarren commented Jan 7, 2020

Is this otherwise ready to go? Thanks!

@jywarren
Copy link
Member Author

Noting this is ready pending @publiclab/community-reps 👍 to be taken up; it will be very similar to #6282, which was fixed by #7183 and #7191. Thanks!

@Srija616
Copy link
Contributor

@jywarren Hey! I am an Outreachy applicant. I would like to work on this, can you help me get started on this issue?

@ebarry
Copy link
Member

ebarry commented Jul 16, 2020

Yes, speaking as a @publiclab/community-reps, this is ready to go 👍.

@jywarren
Copy link
Member Author

jywarren commented Apr 9, 2021

I believe this is complete!

image

@jywarren
Copy link
Member Author

jywarren commented Apr 9, 2021

The only thing we could consider re-opening this for is to reorganize this into radio buttons (i.e. choose between them, rather than toggle each one on or off):

image

And to add an extra option for "NEVER". However that would involve the ability to add the tag notifications:noemail which as of #9269 is evolving into a blanket policy of no emails (but is not there yet).

Closing but we can re-open a narrower project!

@jywarren jywarren closed this as completed Apr 9, 2021
@ebarry
Copy link
Member

ebarry commented Apr 19, 2021

Thank you! /Settings is looking really great and fresh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration discussion feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute
Projects
None yet
Development

No branches or pull requests

4 participants