plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Email notify all followers of a tag if a new comment includes #tagname

Open jywarren opened this issue 9 years ago • 12 comments

Needs some fleshing out, but the comment notify code is here:

https://github.com/publiclab/plots2/blob/master/app/models/comment.rb#L97-L112

  1. 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
  2. We should make a method like def notify_tag_followers, where we collect those tags
  3. we'd want to search for followers of that tag, which I believe is the TagSelection model
  4. we'd want to de-duplicate as has been done elsewhere in the notify method, so nobody gets two emails
  5. 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)

jywarren avatar Feb 01 '17 17:02 jywarren

I would like to try with this issue.

drfigs avatar Feb 01 '17 18:02 drfigs

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 .

jywarren avatar Feb 01 '17 19:02 jywarren

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:

  1. where should I call the method CommentMailer.notify_tag_followers?
  2. 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,

drfigs avatar Feb 06 '17 23:02 drfigs

@jywarren any feedback on this?

drfigs avatar Feb 08 '17 19:02 drfigs

I'm sorry i was slow responding! I'll take a look at the pull request now. Thank you!!!

jywarren avatar Feb 09 '17 17:02 jywarren

Just for reference, I left comments over in the pull request at #1245

jywarren avatar Feb 15 '17 19:02 jywarren

@drfigs What is the status on this? Just making sure you're not stuck or anything.

ryzokuken avatar Mar 05 '17 06:03 ryzokuken

@jywarren I would also like to give this a try

aspriya avatar Mar 11 '17 17:03 aspriya

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 .

jywarren avatar Mar 11 '17 23:03 jywarren

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.

saurabh-sikchi avatar Mar 12 '17 07:03 saurabh-sikchi

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:

  1. 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
  2. we may want to clearly document this policy, perhaps near the tests for this behavior, so future developers know what we've decided

Thanks!

jywarren avatar Mar 13 '17 16:03 jywarren

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.

drfigs avatar Mar 13 '17 22:03 drfigs