Email notify all followers of a tag if a new comment includes #tagname
Needs some fleshing out, but the comment notify code is here:
https://github.com/publiclab/plots2/blob/master/app/models/comment.rb#L97-L112
- We'd want to scan for tags, which we already do when displaying, here: https://github.com/publiclab/plots2/blob/master/app/models/comment.rb#L43
- We should make a method like
def notify_tag_followers, where we collect those tags - we'd want to search for followers of that tag, which I believe is the
TagSelectionmodel - we'd want to de-duplicate as has been done elsewhere in the
notifymethod, so nobody gets two emails - we'd want to write a test to confirm that the notifications get sent even if you're not otherwise related to this note (as an author, commenter, etc)
I would like to try with this issue.
Please do! Perhaps you could start by using this followers method to
collect tag followers:
https://github.com/publiclab/plots2/blob/849d00aa4e2f057783eda90b1d1d52b64065525d/app/models/tag.rb#L134-L140
I think a test is actually the best first step; similar to this one, a test that confirms that a user who wouldn't otherwise be notified gets one if they're following the appropriate tag:
https://github.com/publiclab/plots2/blob/master/test/unit/comment_mailer_test.rb#L4-L17
This file shows (in the text fixtures data) which users are following which tags:
https://github.com/publiclab/plots2/blob/master/test/fixtures/tag_selection.yml
Is that a reasonable place to begin? Thanks for your interest!
On Wed, Feb 1, 2017 at 1:54 PM, jordi [email protected] wrote:
I would like to try with this issue.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/1230#issuecomment-276746232, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ6oKyHoHNK2ETU6BsfZXq2gXuuSRks5rYNTigaJpZM4L0LGA .
Hi, I tried to follow your steps, but I am getting little confused. first, I created a record to tags.yml and tag_selection.yml ...so user bob (uid =1) now follows the tag "Ballon" (tid = 17).
I created a test that makes sure we are calling the right mailer method CommentMailer.notify_tag_followers(user, tag)....on the test is missing to check the message body!
I am having troubles in:
- where should I call the method CommentMailer.notify_tag_followers?
- where should I identify if there are tags on the comment and look for the followers? "comment create action on the controller, or inside the comment.notify method?"
I just created a pull request(Emaill all tag folowwers #1245), and I would appreciate any help.
Thanks,
@jywarren any feedback on this?
I'm sorry i was slow responding! I'll take a look at the pull request now. Thank you!!!
Just for reference, I left comments over in the pull request at #1245
@drfigs What is the status on this? Just making sure you're not stuck or anything.
@jywarren I would also like to give this a try
That'd be great but can you look through the existing pull requests to ensure Jordi hasn't started on it?
On Mar 11, 2017 12:04 PM, "Ashan Priyadarshana" [email protected] wrote:
@jywarren https://github.com/jywarren I would also like to give this a try
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/publiclab/plots2/issues/1230#issuecomment-285881156, or mute the thread https://github.com/notifications/unsubscribe-auth/AABfJ9h8ogSJE5jr0JC7gOvyjeiORnaFks5rktQsgaJpZM4L0LGA .
Hi, I have a question about this:
Should tag followers receive an email on both node comment create and answer comment create or only one?
Thank you.
Hmm, it's a good question. I think perhaps just node comment create -- that way people are presented with the opportunity to subscribe to that question (node), but it's opt-in to hear the answers.
Two thoughts on that:
- we might want to put a "subscribe to hear answers" link in the email notification for the node creation, to present this options (that'd be a good stand-alone issue to add separate from this) and
- we may want to clearly document this policy, perhaps near the tests for this behavior, so future developers know what we've decided
Thanks!
Sorry guys, but I got slammed with other stuff. @Khamba @aspriya please go ahead. I started a pull request with some test on it that you may want to reuse it.