-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Digest for Unmoderated Notes #7987
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7987 +/- ##
==========================================
- Coverage 82.17% 80.15% -2.03%
==========================================
Files 97 98 +1
Lines 5643 5698 +55
==========================================
- Hits 4637 4567 -70
- Misses 1006 1131 +125
|
@keshavsethi could you please have a look at the codeclimate problems? thanks. |
@@ -371,6 +371,11 @@ def queue | |||
end | |||
end | |||
|
|||
def test_digest_email_spam | |||
DigestSpamJob.perform_async(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does perform_async
do here? Does it send the email in the background?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, It is just for testing. It performs Job and creates Digest on daily basis. perform_async gets pushed to the Queue right away. 0 is for daily digest and 1 is for a weekly digest
@@ -0,0 +1,15 @@ | |||
class DigestSpamJob | |||
include Sidekiq::Worker | |||
def perform(frequency_digest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later on we could maybe add a way for moderators to customize the frequency of their digest so that only those who want it will receive theirs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it just checks for tags digest:daily, digest:weekly, and if any of them is present then digest is sent. rn it tasks whatever is the settings of the moderator in the notification settings page. I will add more customization for moderators specifically for spam digest like frequency, type, and status (By tagging different tag like spam_digest:daily)
I was thinking of doing this on /spam2 and make the settings page there. But as of now, it is not merged. Should I add it to the current notification settings page for moderators??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work @keshavsethi
Wow, this is really cool! Thanks @keshavsethi !! A couple questions - how does a user sign up for this, and/or change their settings? And, would it be possible to write tests for this feature as part of this PR? Thank you, very exciting! |
Right now it automatically gets subscribed to all the moderators and admins as per their normal digest settings(like if they are opting of the weekly digest for following posts then they will get unmoderated posts as well in separate digest). I was thinking of adding more customization in spam2. Here It justs checks for digest:daily or digest:weekly tag. I can make a different tag for moderation digest like spam:digest weekly etc. I am working on tests, should I push it in the same PR?? |
@@ -356,6 +373,19 @@ def send_digest_email | |||
end | |||
end | |||
|
|||
def send_digest_email_spam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests for these model methods?
Everything else looks good...great job 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will add it soon. Thanks!!
app/views/admin/spam.html.erb
Outdated
@@ -10,6 +10,11 @@ | |||
<li class="nav-item"><a class="nav-link <% if params[:action] == "spam_revisions" %> active <% end %>" href="/spam/revisions"><i class="fa fa-list"></i><span class="d-xs-inline d-md-none d-lg-inline"> Revisions</span></a></li> | |||
<li class="nav-item"><a class="nav-link <% if params[:action] == "spam_comments" %> active <% end %>" href="/spam/comments"><i class="fa fa-comment"></i><span class="d-xs-inline d-md-none d-lg-inline"> Comments</span></a></li> | |||
<li class="nav-item"><a class="nav-link" href="/people"><i class="fa fa-user"></i><span class="d-xs-inline d-md-none d-lg-inline"> Active Users</span></a></li> | |||
<li class="nav-item"> | |||
<%= form_tag "/admin/test_digest_email_spam", method: :post do %> | |||
<%= submit_tag "Test Spam Digest Email", class: "btn btn-sm btn-info", style: "width: 100%;" %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the name Test Spam Digest Email
?
Also, please add corresponding tests in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a testing button just to test digest for 1-day unmoderated nodes. I have changed its position on the profile page where it is visible only to moderators. Name is Test Spam Digest Email because it is for tests and was in /spam and it creates email digest. I have added some tests. Please review. Thanks!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🎉
@jywarren @SidharthBansal @pydevsg @ananyaarun @VladimirMikulic @cesswairimu @emilyashley @Uzay-G If this fine, Can we please merge this?? 🙏 |
@@ -305,4 +305,7 @@ class UserTest < ActiveSupport::TestCase | |||
end | |||
end | |||
|
|||
test 'Send digest email for unmoderated posts' do | |||
assert users(:bob).send_digest_email_spam |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, or in our functional tests, i wonder if we can check the content of the email itself to confirm? There are some other examples of this in our tests. It would help secure this feature against future issues!
OK, so currently those tags are set in https://publiclab.org/settings - and I think we're OK to rely on that for this setting as well. But let's anticipate that people might in the future want to separate out moderation digest settings from regular content digests. As long as that isn't too much extra work, i think we could modify the text shown here (just for moderators/admins) to say:
What do you think? Or would it be easier to just make a unique user tag like Thank you, this is so great! Fantastic work!!! 🎉 🎉 🎉 |
@jywarren As mentioned in comment #7987 (comment) |
OK, yes, let's move to |
Sure, I will work on its settings and tags, Thanks! |
Great, closing this one! |
Fixes #7986



This is a digest for unmoderated posts that go to admin and moderators and scheduled on a daily and weekly basis. For unmoderated posts status is "4" and it is taken as an argument in content_followed_in_period.
Please refer to following Screenshots and gif
For testing, spam digest button is added in /spam for daily digest.
Tests for this are left, I am working on that.
Please review @jywarren @SidharthBansal @pydevsg @ananyaarun @VladimirMikulic @cesswairimu @emilyashley @Uzay-G
Thanks!! ❤️ ✌️