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: Add new setting to force user edit last post. #6571
Conversation
You've signed the CLA, nbianca. Thank you! This pull request is ready for review. |
I am not sure this is what was discussed.. there should be a site setting for the maximum number of consecutive replies in the same topic by the same user? https://meta.discourse.org/t/allow-only-x-consecutive-replies-in-the-same-topic/69756 So the alert after reaching the threshold would be
|
441c145
to
c5be9b2
Compare
584a9f3
to
c846c16
Compare
You can fast exit if the most recent reply was not from the current user.
Maybe that would be a good first check before proceeding further, to use a
cheap query up front and then only go with the second more expensive query
if it is needed?
…On Fri, Nov 9, 2018 at 9:01 AM Bianca Nenciu ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/validators/post_validator.rb
<#6571 (comment)>:
> @@ -141,6 +142,25 @@ def unique_post_validator(post)
end
end
+ def force_edit_last_validator(post)
+ return if SiteSetting.max_consecutive_replies == 0 || post.id #|| acting_user_is_trusted?(post) || private_message?(post)
+
+ posts = post.topic&.posts.order('post_number desc').where('not hidden AND posts.deleted_at IS NULL')
It's definitely do-able, but I have a feeling it's going to get ugly. 😨
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6571 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABc7VfR7n8K4Uf4CY_R2kG3JWB1zlHdqks5utbTxgaJpZM4YRUx_>
.
|
954a6e0
to
40ee76e
Compare
I do not think it's possible to write a query that is doing this and is also readable. In theory, the best query should check if the last X posts are all made by the same user AND then fetch only the last one. What I do now is:
If we consider that in most communities users will not post many consecutive replies, in that case this validator is going to query the database only once and the result will usually be small (few integers). |
No, that's not what I meant. I meant you could do one query to "check whether the last poster has made X consecutive replies" ;) |
Yes, I understand that. That would be the "gaps and islands" problem and I believe the query will be way too complicated and the benefit will be very small. I will look into it. |
I am not following. How can there be gaps when you are only checking the
last post equals to the current poster? There is no "gap" at the end of a
topic..?
It seems to me the current poster is the only one we care about, and only
the last post in the topic (and possibly last x posts in topic)?
…On Tue, Nov 13, 2018 at 3:00 AM Bianca Nenciu ***@***.***> wrote:
No, that's not what I meant. I meant you could do one query to "check
whether the last poster has made X consecutive replies" ;)
Yes, I understand that. That would be the "gaps and islands" problem and I
believe the query will be way too complicated and the benefit will be very
small. I will look into it.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6571 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABc7VVdHVxZnbqwecn0KZSifpjnJqo-dks5uuqZEgaJpZM4YRUx_>
.
|
Exactly, we only care about knowing whether the last X posts in a topic were done by the current user. Hence, me recommending we can do this in one SQL query ;) |
40ee76e
to
2024c26
Compare
I was considering current user's posts as "islands" and other posts as "gaps" and it kind of made sense. Since the maximum length of an island is known ( I believe it should be good. |
6212a2e
to
328f2b4
Compare
328f2b4
to
fa6e4bb
Compare
No description provided.