User should be able to opt-out of sending their posts in emails to other users
Currently, if users have set to receive email notifications, the full text of other users' comments and posts are sent to them via email. This can be a privacy concern to some. It would be better if each user can choose whether or not his/her posts and comments are allowed to show up in other users' emails.
I've basically got the code to do this. Do I need to write an rspec or cucumber for it?
I think the convenience of being able to respond via email to an email notification is huge, so we should retain the ability to do that. An option that allows a user to keep his private messages out of the mailboxes of others could be possible. You definitely need to test that thoroughly, it's exactly the sort of thing that will be broken by future code. It would also have to federate, so it's not totally simple.
@fermionic: Where's your code? I'll try to help you out with the specs or whatnot. This is an important issue.
The code for my pod is at: https://github.com/fermionic/diaspora
The code specifically for hiding ones own text in email notifications involves modifications to the following files:
app/mailers/notification_mailers/also_commented.rb app/mailers/notification_mailers/comment_on_post.rb app/mailers/notification_mailers/liked.rb app/mailers/notification_mailers/mentioned.rb app/mailers/notification_mailers/private_message.rb app/mailers/notification_mailers/reshared.rb app/models/user_preference.rb
In summary: a new email_type of "silent" is added in user_preference.rb. Each notification mailer class then creates an object "text_owner" that allows the view code to check if a "silent" email_type for the owner of the text exists. If it exists, then an alternate message is displayed in the email. The notification mailer classes for comments also check if the owner of the post wants his text hidden, if so, the subject line of the email is replaced with alternate text.
The following views were modified to check if the text owner has a "silent" email_type:
app/views/notifier/also_commented.html.haml app/views/notifier/also_commented.text.haml app/views/notifier/comment_on_post.html.haml app/views/notifier/comment_on_post.text.haml app/views/notifier/liked.html.haml app/views/notifier/liked.text.haml app/views/notifier/mentioned.html.haml app/views/notifier/mentioned.text.haml app/views/notifier/private_message.html.haml app/views/notifier/private_message.text.haml app/views/notifier/reshared.html.haml app/views/notifier/reshared.text.haml
And the following was modified to allow the user to check a box to hide text in email notifications and update the database with a "silent" email_type:
app/views/users/edit.html.haml
Finally, the text of the alternate messages for the email notifications are found in:
config/locales/diaspora/en.yml
I believe this code works, to the best of my ability to test (I don't currently have the ability to make sure it federates). The main thing that needs to be done is to write rspec tests for the different scenarios. I don't really know how to write rspec tests, but I think that if someone could help write an example test for one scenario, I could probably figure out how to do the rest.
What branch is this code in?
Ah, right, sorry. The branch is fermionicdiaspora-deployed
Should I put the changes into their own branch?
I wish I knew what to tell you fermionic, or that someone who does would. I appreciate you coders out there working on Diaspora. I'm anxious to see this feature implemented so I can be more candid with what I write in instant messages and also in comments on restricted posts
As I posted in #2271, this is very technically difficult at the moment because user preferences don't federate. So if you opt-out, you prevent your own pod from including your text in emails, but other pods will still include it in emails they send. Each pod sends email for its own users, so when you comment on something, email is being sent individually by every pod who has a user who should be notified. In that case, if you opt-out, users on your pod will get the empty email. All the other users will get the full text.
Let's revisit this once we've had a chance to think about federating user prefs.
A slightly different approach has been proposed, which avoids the problem of needing to federate the user's Settings/Preferences. Please see this "diaspora-discuss" Google Group "Feature Discussion":
https://groups.google.com/forum/?fromgroups=#!topic/diaspora-discuss/yABCCleZ62I (...and please click "Display Images in this post" for the second posting, to see a "mockup" picture of the proposed features)
sarahmei, hopefully you might reconsider the merit of this feature, with this alternative approach.