-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Features/1349 improve comment moderation possibilities #1526
base: master
Are you sure you want to change the base?
Features/1349 improve comment moderation possibilities #1526
Conversation
core/Piranha/Models/Comment.cs
Outdated
/// </summary> | ||
public bool IsApproved { get; set; } = true; | ||
[Obsolete("IsApproved is obsolete and has been replaced with CommentStatus", true)] |
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.
Shouldn't the second parameter be set to false
as you've added a fallback implementation? Setting the boolean to true
will render compilation errors when using the property instead of giving a compiler warning.
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.
I was not sure on the decision but noted it (things to revise/left to consider) since it made sense to set it to true.
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.
Note that I removed the IsValid
-property completely from Data
layer, replaced by the Status
. I considered to be more clean to replace it "under the hood" rather than having both properties present in DB until the old one is eventually removed.
So I've checked out the branch and looked at the manager. My initial thought is that the three-way enum doesn't give that much extra in functionality. It works much like a Also by having a single field in the data-layer, manually approving a comment that has been marked as been rejected by a moderation plugin as spam effectively removes the historical information that it was rejected. Also, if the status message is set by the moderation plugin and not updated when being manually approved it will say different things to the user. When we discussed having multiple fields I was thinking about maybe have multiple fields for approving and validating in the database as well, then a moderation plugin would set However it would be fully possible for the manager to reject a comment that has passed moderation or the other way around without loosing history of how the moderation plugin worked. Only the approved column would be possible to set from the manager interface. Then again, maybe this is overkill, I haven't worked that much with Wordpress and their comment moderation system to know what users expect from this kind of functionality :) Note: The name |
@tidyui - very good points and I can confirm I've went through similar thoughts. :)
Yes. My initial thought was to go for an additional In the latter case there's a fourth state that is illogical and that's the primary reason for going with the enum tbh. Felt more clear to have three possible values for the three possible states. What then became apparent is that the naming in the UI of the manager and in the code does make a good name and representation a little hard: In current implementation (not the PR) we have no distinction between pending comments and comments rejected by a moderator or module. That's what I wanted to achieve to have. Looking at the comment filter in the Manager there's the term If history is desired, I'd say that there's an even more "overkill" solution that would allow for true history: to have a separate moderation table. I was considering this, since I felt the 'ValidationReason
That's why I toyed with having the manager to set a reason (and implemented it - I removed it). The manager added a reason like
Yeah. That's why I tried
I have to check, since I don't remember myself. I have a couple of WP installs I manage occationally for friends! Steps forward/things to decide/discuss further (a suggestion):
As for one, I actually favor the nullable bool. I mean, that's the most clean solution that most accurately represent what we have: a comment state is primarly not evaluated at all first. It's pending. Submitted. Not validated at all. Makes sense to have this a null as in "no validation has been made" (neither by config or by manual approval or module approval). At some stage validation is made and the only two reasonable states to go between is being approved or not. I am fond of the idea of having a reason but I am not convinced that it should be part of the comment. I am also not sure how to solve the localization issue but maybe that's a no brainer? |
So by the looks of it Wordpress has four distinct states? |
Or maybe it's just three states with an extra field marking the comment as "spam"? |
Yeah. The fourth being "waste bin". Whether to call it I believe Trash can be emptied both explicit or by a setting after n days. Lemme check. Question is why they distinguish between spam and trash and what transitions/actions can be made on them. |
From the looks of it it's A quick look in the database of the WP install I get: that they actually store the comment status in one single column that is a In addition they have a meta data table for comments with akismet data and the moderation actions (somewhat like the one I proposed in my previous comment above). For instance, one can trace moderations like these:
Here one can see I just put comment no 329 in trash. |
@tidyui If you have any preferences let me know but I believe an update is rather quick to do as far as I'm concerned. |
@jensbrak I've started sketching on the next major release in the branch Also the services are built around the native CLR content-types and does not use the dynamic models which also means that we will finally be able to remove these in I'm thinking we should revisit this PR and start looking into merging it into the The new functionality is not 100% complete atm, for example it's not possible to add new pages, posts or content through the manager yet, only editing of existing items. If you want you can always take a look at the current state of things in this branch and maybe send a PR towards that branch. Regards |
I have been thinking of revisiting this PR. Have been awaiting your response: to me it really doesn't matter how the functionality is implemented more precisely but your input is crucial since you have the best knowledge about what works best for Piranha in general. |
So @jensbrak, should we start looking at this again for the |
Sounds like a plan ! I'll dig into it asap and will get back with either a new proposal or questions 😉 |
I'll go ahead and merge 10 branch into my fork and try to revise the code as discussed above. It shouldn't be that much hazzle I hope. Question is how the design should be but as for now I'll focus on getting up to speed with the 10 version here. |
@jensbrak Heads up! The branch |
@tidyui - As for the design choice of this I've come to change my mind. Your suggestion to have an additional field to indicate spam status seems to be a better choice. The obvious choice would be a Another thing would be to add a text field (like I did in my first PR) to allow for adding details about moderation or status change. I didn't quite follow your reasoning about keeping history intact - part from it's a good idea. Do we want status changes in a separate table? Ie, add Either way we do it, it seems to be rather straight forward - so it's more of a design preference on your part. The main thing here is that only two states seems inadequate for comment moderation. When you have the time, let me know your thoughts and I'll do a new PR reflecting our ideas and choices. |
First draft of the code trying to implement some of the features in #1349 .
Choices made:
CommentStatus
replacing theIsApproved
property ofComment
modelCommentStatus.Pending
only once until moderated by/from some part of the system.CommentStatus.Approved
effectively replaces theIsApproved = true
.StatusReason
toCommentModel
to hold an optional reason for status change. The framework does NOT set this value (I played around with it but felt it would complicate things with respect to localization)CommentStatus.Rejected
is the state of the comment. In other words: comments with Approved off and Rejected off is pending (ie submitted but not reviewed). Comments with Approved on and Rejected off is as before - approved. Comments with Approved off and Rejected on has been toggled to rejected by user in the Manager interface or a module/hook.At a minimum - things to revise/left to consider:
Comment.StatusReason
in comment list of Manager. Remove for now? Add a separate line as suggested?StatusReason
?Status
property ofComment
. Is this inconsistant with respect toContentState
in the Manager? Both with respect to naming and enum vs class. State vs Status seems to be used inconsistant already? And the use of a class in Manager for Page/Posts seems not the same as an enum within Core for Comments. Still a question that popped up for me.IsApproved
is removed from data/ef and migration will convert it toStatus
for comments. It is kept inComment
class in core though but marked obsolete. Perhaps not force exceptions initially?I've tested a migration with MySql as well and it worked ok after som tweaks. Also tested the feature with the SpamDetector module with success.