This issue is a part of project #3331
Create a new mailer as following:
Name the method as notify_comment_moderators and also use same name for file.
Refer the method https://github.com/publiclab/plots2/blob/master/app/mailers/admin_mailer.rb#L6-L17 .
Hi, this issue has been opened as a task on GCI dashboard. If you are Google Code-In participant and want to solve this issue, please claim it from Google Code-In website . Thanks!
Hi @gauravano! I have a question. I've looked the code and I can't find where call the function to requesting review for nodes. I saw the method that you referred in the issue

After that, I searched where the app 's using it

And I thought 'okay, that makes sense' but now... There are any place where it uses, not when a new node is created at least.. so, Can you clear this for me? because, if I understand how works with nodes, I can implement it in the comments.
Thank you so much!
I thought that the mail was sent when the node is created but I couldn't find where is the code, maybe I'm wrong and the implementation is so different
Hi @ValentinaTironi, we currently have moderation system only for nodes.
How it works?
If a new user try to post a note to PL website, we check in our db whether user is have contributed before or not. For new user, after their note is submitted, we change it's status depending upon the new or old user. At that time, a mail is send to all moderators to review the note.
After the moderator, review the note, two emails were sent, first one to the moderators notifying them whether note has be approved or marked as spam and second email to the user notifying the same.
Now, we want to create the same system for comments. Please see #3331 for all the subparts. Currently, do not add any calling statement as we have make whole system first and in last we would connect all the functions.
Although, each sub-part need to be tested after it's creation, we can add some temporary code if necessary.
If you have any questions then, leave them below or in #3331. I would answer them tomorrow.
Sorry for grammar, I am in hurry :sweat_smile: .
CC @jywarren
Hello @gauravano, thank you so much to answer my questions. I understand how it works. I'v seen the create method in notes_controller, and it's great! but I can't find where you say 'Okay, we send the mail to all moderators' in the code. If you could tell me what I'm doing wrong would be amazing!
Thank you for your time ๐ฏ
Hi! I believe that is actually done in the node.rb model, on these lines:
Awesome to see progress on this! :-)
On Thu, Nov 29, 2018 at 10:07 AM Valentina Tironi notifications@github.com
wrote:
Hello @gauravano https://github.com/gauravano, thank you so much to
answer my questions. I understand how it works. I'v seen the create method
in notes_controller, and it's great! but I can't find where you say
'Okay, we send the mail to all moderators' in the code. If you could tell
me what I'm doing wrong would be amazing!
Thank you for your time ๐ฏโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/4050#issuecomment-442866844,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ2Cd4NnIdEfrDDUzurUlTS1qb_-lks5uz_gPgaJpZM4YzTx1
.
Currently, there is no method from where mailer can be called so you can
make a temporary method which can be called for functional testing. I would
write the remaining details by tomorrow. Thanks!
On Fri, Nov 30, 2018 at 1:26 AM Jeffrey Warren notifications@github.com
wrote:
Hi! I believe that is actually done in the node.rb model, on these lines:
Awesome to see progress on this! :-)
On Thu, Nov 29, 2018 at 10:07 AM Valentina Tironi <
[email protected]>
wrote:Hello @gauravano https://github.com/gauravano, thank you so much to
answer my questions. I understand how it works. I'v seen the create
method
in notes_controller, and it's great! but I can't find where you say
'Okay, we send the mail to all moderators' in the code. If you could tell
me what I'm doing wrong would be amazing!
Thank you for your time ๐ฏโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/publiclab/plots2/issues/4050#issuecomment-442866844
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AABfJ2Cd4NnIdEfrDDUzurUlTS1qb_-lks5uz_gPgaJpZM4YzTx1.
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/4050#issuecomment-442971642,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AT6S9s4BF49G2Sd_57EmmEJICiHg2F0lks5u0DvigaJpZM4YzTx1
.
Thanks Gaurav and again good luck with your exams!!!
On Thu, Nov 29, 2018 at 3:30 PM Gaurav Sachdeva notifications@github.com
wrote:
Currently, there is no method from where mailer can be called so you can
make a temporary method which can be called for functional testing. I would
write the remaining details by tomorrow. Thanks!On Fri, Nov 30, 2018 at 1:26 AM Jeffrey Warren notifications@github.com
wrote:Hi! I believe that is actually done in the node.rb model, on these lines:
Awesome to see progress on this! :-)
On Thu, Nov 29, 2018 at 10:07 AM Valentina Tironi <
[email protected]>
wrote:Hello @gauravano https://github.com/gauravano, thank you so much to
answer my questions. I understand how it works. I'v seen the create
method
in notes_controller, and it's great! but I can't find where you say
'Okay, we send the mail to all moderators' in the code. If you could
tell
me what I'm doing wrong would be amazing!
Thank you for your time ๐ฏโ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
https://github.com/publiclab/plots2/issues/4050#issuecomment-442866844
,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AABfJ2Cd4NnIdEfrDDUzurUlTS1qb_-lks5uz_gPgaJpZM4YzTx1
>.
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/publiclab/plots2/issues/4050#issuecomment-442971642
,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AT6S9s4BF49G2Sd_57EmmEJICiHg2F0lks5u0DvigaJpZM4YzTx1.
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/4050#issuecomment-442981921,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AABfJ69SrZUIh7P5e91rUWg8RFpNf8blks5u0EOqgaJpZM4YzTx1
.
I don't understand. How do you send the mail if there isn't method where mailer can be called? I'm talking about the nodes system, not comment, maybe you got confused. I just wanna know where you call the mailer to send the mail to moderator when a node is created.
Sorry if I wasn't clear, my bad! Thank you so much for your time! I really want to understand this to do the task ๐ฏ
@gauravano @jywarren
No problem and sorry i didn't have a moment to read through more carefully! I'll take a closer look right now: ๐ต๏ธ ๐
OK, so the trigger of sending the moderator notifications is here: https://github.com/publiclab/plots2/blob/ccfd39c5c833d1337ba5fb484a4e459a989aeaf6/app/models/node.rb#L208-L214
It's triggered here, upon creating a new node: https://github.com/publiclab/plots2/blob/ccfd39c5c833d1337ba5fb484a4e459a989aeaf6/app/models/node.rb#L649
So it's basically built into the model, instead of the controller. This does mean we could do a unit test instead of a functional test -- or we could do both!
I think some folks have been moving tests of mailers from unit tests into integration tests, probably because it really does test across a lot of systems, instead of just testing the inner functions of a model (which is the narrower kind of test usually called unit test). But you can see a lot of notification unit tests here that would be a good model: https://github.com/publiclab/plots2/blob/master/test/unit/comment_mailer_test.rb
Does that help? Thank you!
Yes, thanks! I'm gonna try to complete this issue when I have approved my current task
Just some more questions:
@jywarren @gauravano
Comment status:
1 - Normal comment
4 - Moderated comment
0 - Spammed comment
The mail has to be sent when the a comment is created?
Yes, mail would be sent at time of comment creation if the user has not created any normal node or comment before. A function for condition checking is currently a GCI basic task - https://github.com/publiclab/plots2/issues/4047
@ValentinaTironi
So, I'm gonna to do that task (#4047) first to, after, complete this! Are you agree?
I can't find the task (#4047) in Google Code In dashboard :/ Can you give the link? Thank you!
As task #4047 is simple so I created that as beginner task, so it would be invisible to you I guess. Directly add the condition and I would replace it with the function call whenever it would be ready. How does it sound?
Sounds great! I just have a question: first_time_commenter method verify if the user's created comments before already. Do I have to add the same verification for node in this function? Something like adding in the first_time_commenter function to that thefirst_time_poster method does?
You assumed it right valentina. The check would be the combination of
first_time_poster and first_time_commenter(currently present) in user.rb .
Great! I'm gonna start. I'll verify that locally and before do push, replace it for the function name. Thanks ๐ฏ
Hi! me again :) I saw that there is already a notify method in comment model that notifies to all people involved in the thread and I thought 'Great, I can add the notify_comment_moderators mailer here', but I was wondering if I have to send notification to the other people even though when the user who commented never has commented before.

What do you think? @gauravano
Hi, the email should be sent to moderators only. So, add according at a
suitable place. Thanks!
On Sun, Dec 2, 2018 at 12:58 AM Valentina Tironi notifications@github.com
wrote:
Hi! me again :) I saw that there is already a notify method in comment
model that notifies to all people involved in the thread and I thought
'Great, I can add the notify_comment_moderators mailer here', but I was
wondering if I have to send notification to the other people even though
when the user who commented never has commented before.[image: screen shot 2018-12-01 at 4 22 53 pm]
https://user-images.githubusercontent.com/20969831/49332077-617f7a80-f585-11e8-8478-b38beab871ee.pngWhat do you think? @gauravano https://github.com/gauravano
โ
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/4050#issuecomment-443452082,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AT6S9mUGArZFSWMHKKdnlncgtWc4ScDiks5u0th5gaJpZM4YzTx1
.