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

Feature request: delay moderation emails for first time posters or commenters until 24 hours have passed #6246

Closed
2 tasks
ebarry opened this issue Sep 5, 2019 · 19 comments · Fixed by #6409 or #7187
Closed
2 tasks
Labels
break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute
Milestone

Comments

@ebarry
Copy link
Member

ebarry commented Sep 5, 2019

The desired behavior.

The Moderators group convened last week to review the features available for moderators reviewing spam.

Working with @jywarren, we identified that people holding "moderator" roles on the website get a lot of notifications. The following two types of notifications generate the bulk of the notifications to moderators roles:

  • moderator roles: When a First Time Poster posts a note or a comment
  • moderator roles: When another moderator takes action on a note or comment

Analysis:

  • These type of notifications are completely redundant with the listing of spam on the dashboard.
  • responding to the request to approve or spam the new submission still requires clicking through to the website, so these emails do not streamline the activities of performing moderation duties.
  • For the past couple years, it has become reliable that there are daily submissions by new posters, making even a daily digest email notification redundant.

Based on that conversation, @bronwen9 and I have the following feature request:

  • Eliminate the email titled “[New Public Lab poster needs moderation]”
  • Eliminate the email titled "[New Public Lab commenter needs moderation]"

Additional context

Thank you. Does anyone have any other ideas or questions?

@ebarry ebarry added the feature explains that the issue is to add a new feature label Sep 5, 2019
@ebarry ebarry added this to the Spam! milestone Sep 5, 2019
@jywarren
Copy link
Member

jywarren commented Sep 5, 2019

Hi, this should be pretty straightforward to change; the code segments can be found here:

Notes

Initial needs moderation email:

AdminMailer.notify_node_moderators(self).deliver_now

Did you also want the "this was marked as spam" email removed? That is here:

AdminMailer.notify_moderators_of_spam(@node, current_user).deliver_later

And notification of approval of node is here:

AdminMailer.notify_moderators_of_approval(@node, current_user).deliver_later

Comments

Initial comment moderation email is here:

AdminMailer.notify_comment_moderators(self).deliver_now

Notification of comment marked as spam:

AdminMailer.notify_moderators_of_comment_spam(@comment, current_user).deliver_later

Notification of comment approval:

AdminMailer.notify_moderators_of_comment_approval(@comment, current_user).deliver_later

The actual mailers can be found in this file; EVERYTHING EXCEPT the 2 highlighted functions would be removed; we still want to notify node and comment authors of approval:

def notify_author_of_approval(node, moderator)
subject = '[Public Lab] Your post was approved!'
@author = node.author
@moderator = moderator
@node = node
@footer = feature('email-footer')
mail(to: @author.email, subject: subject)
end
def notify_author_of_comment_approval(comment, moderator)
subject = '[Public Lab] Your comment was approved!'
@author_mail = comment.author.email
@moderator = moderator
@comment = comment
@footer = feature('email-footer')
mail(to: @author_mail, subject: subject)
end

Then, all mailer templates for moderators would be removed: https://github.com/publiclab/plots2/tree/master/app/views/admin_mailer

And finally, this will break a lot of tests which protect the mailer functions, so those will need to be removed. There are quite a few; i'll list some here but we'll be able to see them fail and can remove them afterwards:

test 'should send mail to moderator if comment has status 4' do
UserSession.create(users(:moderator))
post :create, params: { id: nodes(:one).nid, body: 'example', status: 4 }, xhr: true
assert ActionMailer::Base.deliveries.collect(&:to).include?([users(:moderator).email])
end

Actually i think all the others can be found here, so the entire file could be removed:

https://github.com/publiclab/plots2/blob/master/test/unit/admin_mailer_test.rb

This is a lot of code; we should probably do it all in a single PR and carefully check it.

@jywarren jywarren added the help wanted requires help by anyone willing to contribute label Sep 5, 2019
@ebarry
Copy link
Member Author

ebarry commented Sep 5, 2019

Wow thank you!!!! Yes, thanks for pointing out the "Notification of comment marked as spam" and "Notification of post marked as spam" emails -- they should also be discontinued. Sorry for breaking tests and making extra work on that!

@bronwen9
Copy link

bronwen9 commented Sep 5, 2019 via email

@jywarren
Copy link
Member

jywarren commented Sep 5, 2019

Sorry, you're not breaking the tests! was typing a lot quickly... i just meant that we've protected these features with tests, so removing the features will cause the tests to report failures, so we need to remove the tests too. Just trying to be thorough and warn anyone attempting this in advance, thanks!

@grvsachdeva
Copy link
Member

I believe we should only remove the mailer calls and not the mailer as we may need them in future. Also, we should try to make all emails async and send them via sidekiq as that'll free up main thread. What do you think @jywarren?

@jywarren
Copy link
Member

jywarren commented Sep 6, 2019 via email

@grvsachdeva
Copy link
Member

  • could such emails be used as part of integration with another system,
    like IFTTT or anything?

Don't know.

  • could such emails be useful for someone else running the PL codebase for
    another community, and do we want to preserve such capability?

Yes, they can be useful.

  • could such emails be useful for authors to be notified of spam comments
    on their posts so they can moderate them themselves, or

yes, we can extend this privilege to post author and create a mailer

  • could such emails be useful for topic groups to do their own moderation,
    rather than having a central moderators group?
    yes.

Another idea is to setup a cron job which will send a mail about the # of new posts pending for moderation as a reminder to moderators group.

@ebarry
Copy link
Member Author

ebarry commented Sep 9, 2019

This sounds like several good reasons to "turn off" the mailer instead of deleting it. Cool! I especially like the idea that, in the future, topic groups may do their own moderation. I could see that people would be eager to help curate the areas they care about.

Does this also mean that we should "turn off" the tests instead of deleting them?

@ebarry
Copy link
Member Author

ebarry commented Sep 9, 2019

@bronwen9 proposes, and I support, to send a notification email if a post or comment has been waiting in the queue for 24 hours.

@ebarry ebarry changed the title Feature request: eliminate moderation emails for first time posters or commenters Feature request: delay moderation emails for first time posters or commenters until 24 hours have passed Sep 9, 2019
@jywarren
Copy link
Member

jywarren commented Sep 9, 2019 via email

@ebarry
Copy link
Member Author

ebarry commented Sep 12, 2019

Recapping the revised plan:

  • email notifications on 24 hour delay, on a conditional that email not be sent if content has been approved
  • confirmations off

@jywarren
Copy link
Member

jywarren commented Sep 12, 2019

Thanks @ebarry, just adding detail here:

  • change initial moderator email notifications for comments and nodes to send after a 24 hour delay (using DelayedJob as described above), on the condition that the content has not yet been approved or spammed
  • turn confirmations (has been approved and has been spammed) and their corresponding tests off, but don't yet delete them

👍

@jywarren
Copy link
Member

jywarren commented Sep 12, 2019

Those two tasks can be done as two separate PRs! And in theory, we could do them separately for comments and nodes, so potentially 4 PRs.

@jywarren jywarren added the break-me-up break up for cleaner code separation, discrete tests, and, easier and iterative collaboration label Sep 12, 2019
@jywarren
Copy link
Member

jywarren commented Sep 12, 2019

Actually, it looks like mailers are already Jobs, in Rails, so we can do:

AdminMailer.notify_node_moderators(node).deliver_later!(wait_until: 24.hours.from_now)

And, we could wrap this line in the conditional:

mail(
to: "moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)

So, like:

if node.status == 4 # only if it remains unmoderated
  mail(
      to: "moderators@#{ActionMailer::Base.default_url_options[:host]}",
      bcc: moderators,
      subject: subject
    )
end

@jywarren
Copy link
Member

jywarren commented Oct 7, 2019

Initial implementation here: #6409, but will take some test corrections and debugging to get right, and also will require some manual testing in production.

@ebarry
Copy link
Member Author

ebarry commented Oct 31, 2019

Would this also resolve this earlier issue about allowing moderators to control their own email settings where their other email settings are controlled? #4543

@jywarren
Copy link
Member

No, this does not affect that issue, thanks!

@jywarren
Copy link
Member

Just noting that we turned off initial, confirm (spam and not-spam) for nodes, and spam/not-spam for comments, but this #6409 did NOT turn off initial notifications for comments. Will do this next.

@jywarren jywarren reopened this Jan 10, 2020
@jywarren
Copy link
Member

test 'should send email to comment author when it is approved (first time commenter)' do
user = users(:admin)
UserSession.create(user)
comment = comments(:comment_status_4)
node = comment.node
post :publish_comment, params: { id: comment.id }
email = AdminMailer.notify_author_of_comment_approval(comment, user)
assert_emails 1 do
email.deliver_now
end
assert email.body.include?("Hi! Your comment was approved by <a href='https://#{request_host}/profile/#{user.username}'>#{user.username}</a> (a <a href='https://#{request_host}/wiki/moderation'>community moderator</a>) and is now visible in the <a href='https://#{request_host}/dashboard'>Public Lab research feed</a>. Thanks for contributing to open research!")
comment = assigns(:comment)
assert_equal 1, comment.status
assert_redirected_to node.path
end

Should comment notifications also be held 24 hours?

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 feature explains that the issue is to add a new feature help wanted requires help by anyone willing to contribute
Projects
None yet
4 participants