Commit Graph
60 Commits
Author SHA1 Message Date
Alan Guo Xiang Tan 35f660e3a1 DEV: Remove unused transition_to and transition_to_id from reviewable serializer (#37135)
What is the problem?

The `ReviewablePerformResultSerializer` includes `transition_to` and
`transition_to_id` attributes in API responses, but these values are
not consumed by any frontend code. The frontend only uses
`remove_reviewable_ids`, `reviewable_count`, `unseen_reviewable_count`,
and `completed_message` from the perform result.

What is the solution?

Remove the unused `transition_to` and `transition_to_id` attributes
from `ReviewablePerformResultSerializer`, along with the
`transition_to_id` method. Update corresponding test expectations.
2026-01-15 15:04:53 +08:00
Kris fd8f5a9ceb UX: refactor review queue buttons for more consistent language (#36812)
This is an effort to make our existing review queue actions more
consistently follow the pattern of question/response.

For example, instead of the existing state of: 

<img width="250" alt="image"
src="https://github.com/user-attachments/assets/7dba3937-b25a-4cf1-9a03-16b2ddb3f3f0"
/>

This PR updates things to "Approve this post?"

<img width="500" alt="image"
src="https://github.com/user-attachments/assets/1f3a693e-63f7-43d5-beba-8179cc52a63d"
/>

This is to gain more consistency around all flag types. Currently we
have a mix of generic "Moderator Actions" and question based actions
like "Is there something wrong with this post?"

Here's a series of screenshots covering different flag types covered
here:

<img width="299" alt="image"
src="https://github.com/user-attachments/assets/4910531f-2bed-4c5d-8b0a-76c5166f3db0"
/>
<img width="601" alt="image"
src="https://github.com/user-attachments/assets/b98d7067-ada2-4b26-89a2-7d25073f3680"
/>
<img width="619" alt="image"
src="https://github.com/user-attachments/assets/332b6f0c-6893-4aef-b30c-41bf297f53f7"
/>
<img width="287" alt="image"
src="https://github.com/user-attachments/assets/39bee5ee-6486-4342-b39d-29aa6e0b0b2a"
/>
<img width="562" alt="image"
src="https://github.com/user-attachments/assets/57f5ccb9-4353-4ecb-b478-5e6c324f1d38"
/>
<img width="505" alt="image"
src="https://github.com/user-attachments/assets/33967f1c-7b63-440c-9595-0e05d2c52a78"
/>
<img width="328" alt="image"
src="https://github.com/user-attachments/assets/c36dec5d-adbf-4c61-86b4-b074070c75cf"
/>
<img width="448" alt="image"
src="https://github.com/user-attachments/assets/959d1355-6568-4a5a-bc8a-d61b278d6a67"
/>
<img width="528" alt="image"
src="https://github.com/user-attachments/assets/6098a098-a5c3-496a-9ec3-67839067692e"
/>
<img width="454" alt="image"
src="https://github.com/user-attachments/assets/723b584e-74ff-4828-b92c-ae5361bc757c"
/>
<img width="429" alt="image"
src="https://github.com/user-attachments/assets/9a3e8f53-f62e-4df2-b3a1-668373e03d53"
/>
<img width="532" alt="image"
src="https://github.com/user-attachments/assets/e4aed6e8-bb33-4d17-a863-cb3d94bcbf00"
/>
<img width="390" alt="image"
src="https://github.com/user-attachments/assets/54a4af77-b16b-4add-925f-f648caf09432"
/>
<img width="651" alt="image"
src="https://github.com/user-attachments/assets/edb10140-69e7-4795-813f-b51875d104cf"
/>
<img width="406" alt="image"
src="https://github.com/user-attachments/assets/9f4dbcee-e0a7-4404-9e22-04630286e2e9"
/>
<img width="375" alt="image"
src="https://github.com/user-attachments/assets/3901215f-a752-4ad0-94e7-8924d069302f"
/>
<img width="538" alt="image"
src="https://github.com/user-attachments/assets/f3d2c3cc-bc64-4445-a6fc-7c550077cb31"
/>
<img width="404" alt="image"
src="https://github.com/user-attachments/assets/8ca1b7a9-a4bc-48d4-9c0e-0dd162367398"
/>
<img width="421" alt="image"
src="https://github.com/user-attachments/assets/bffcb595-0581-4526-943b-04e6792b62f1"
/>
<img width="529" alt="image"
src="https://github.com/user-attachments/assets/10e4381f-f662-49bd-9604-79ca8a75dca2"
/>
<img width="363" alt="image"
src="https://github.com/user-attachments/assets/64276d2b-4c47-4f1d-aabc-b9125a8026ef"
/>
<img width="527" alt="image"
src="https://github.com/user-attachments/assets/9533e22f-fe29-456c-a10b-dfda28319199"
/>
<img width="393" alt="image"
src="https://github.com/user-attachments/assets/d9479c85-0c44-4742-9680-68a79ebaf4d4"
/>
<img width="321" alt="image"
src="https://github.com/user-attachments/assets/33cedd6d-3a40-43f2-bde2-0903567d6c40"
/>
<img width="465" alt="image"
src="https://github.com/user-attachments/assets/cb73016a-1e37-4273-b5f2-0834405b349f"
/>
<img width="531" alt="image"
src="https://github.com/user-attachments/assets/b01f3ab8-ce4b-448d-9c4f-a6a8149486a6"
/>
2026-01-13 10:17:29 -05:00
Gary Pendergast 57f2f5a5ea DEV: Log Reviewable actions (#36076)
With reviewables now being able to have multiple actions performed on
them, we don't want to update the final reviewable state until an action
from every action bundle has been performed.

This change makes use of the new `ReviewableActionLog`, logging actions
when they occur, then checking to see if a reviewable has had all
actions performed before finalising it.
2025-11-20 13:41:40 +11:00
Ted Johansson de93ccbade DEV: Touch-ups and test coverage for Reviewable#perform (#34950) 2025-09-25 15:17:24 +08:00
Sérgio Saquetim 301f27caaa DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
Gary Pendergast 599404de31 DEV: Add a ReviewableNote model, and tie it into the Reviewable model. (#33047)
As part of the review queue refresh, we'll be adding the ability for moderators to make notes on individual reviewable items. As a first step, this change adds the new model and associated backend code.
2025-06-04 09:33:02 +10:00
Gary Pendergast b77d0f7589 FEATURE: Sync Reviewable Status (#31901)
When multiple admins are working in the review queue, it's quite easy for two people to try and handle the same reviewable at the same time. This change addresses the two major situations where this can occur.

The `ReviewableClaimedTopic` model has been extended to allow the system to mark a reviewable as claimed as soon as the first moderator starts handling the reviewable, even when the `reviewable_claiming` setting is disabled. This ensures that reviewable actions with client-site activity (for example, `agree_and_suspend`) will lock the reviewable before another moderator starts working on it.

When someone handles handles a reviewable, we now use `MessageBus` to inform other moderators that it's changed. If any of the other moderator have that reviewable open (either individually, or on the list screen), it will automatically refresh that data.
2025-03-24 14:27:18 +11:00
Gary Pendergast 29a8c6ee49 DEV: Add a new type_source field to the Reviewable model. (#31325)
This change adds a new `type_source` field to the `Reviewable` model, indicating whether the Reviewable type was registered by `core`, a plugin, or an `unknown` source.

When a plugin that registered a Reviewable type is disabled, this allows us to tell the user which plugin they need to re-enable to handle any orphan reviewable items.
2025-02-20 09:09:47 +11:00
Loïc Guitaut 140775d505 DEV: Enable RSpec/InstanceVariable rule for models 2025-02-17 10:00:08 +01:00
Krzysztof Kotlarek 5eb7d6d9c0 FEATURE: Gracefully handle unhandled reviewables (#31118)
Plugins like for example AI or Akismet create reviewable items. When the
plugin is disabled, then we cannot properly handle those items.

In that situation, we should display warnings about unhandled types.
Instruct admin to reenable plugins. In addition, we should allow the
admin to delete all pending reviews from disabled plugins.
2025-02-05 14:38:45 +11:00
Martin Brennan 8a89a77248 FIX: Discard empty bundles for reviewables (#30121)
Followup c7e471d35a

It is currently possible to add a bundle (which is a collection
of actions used for a dropdown on the client) for a reviewable
via actions.add_bundle and then never add any actions to it.

This causes the client to explode, as seen in the referenced
commit, because of the way our store expects to resolve objects
referenced by ID that are passed down by the serializer, which
then causes Ember to have an unrecoverable render error.

Fixing this on the serializer level is not really possible because
of all the ActiveModel::Serializer magic that serializes
objects by ID reference when doing things like has_many.
`Reviewable#actions_for` is a better place to do this anyway,
because this is the main location where the bundles and actions
are built for every action via the serializer.
2024-12-05 15:41:13 +10:00
Osama Sayegh 280adda09c FEATURE: Support designating multiple groups as mods on category (#28655)
Currently, categories support designating only 1 group as a moderation group on the category. This commit removes the one group limitation and makes it possible to designate multiple groups as mods on a category.

Internal topic: t/124648.
2024-09-04 04:38:46 +03:00
Martin Brennan 6b872c4c53 FIX: Bump reject_reason limit for reviewables to 2000 characters (#27507)
Followup 783c935dcb

Some admins were finding that the limit introduced above was
too short especially when sending an email to rejected users.
This commit bumps the limit from 500 to 2000 and also fixes
an issue where the friendly error message was not shown in
the browser.

c.f. https://meta.discourse.org/t/500-character-reject-reason-is-too-small-a-limit/291884
2024-06-18 15:49:58 +10:00
Ted Johansson 57ea56ee05 DEV: Remove full group refreshes from tests (#25414)
We have all these calls to Group.refresh_automatic_groups! littered throughout the tests. Including tests that are seemingly unrelated to groups. This is because automatic group memberships aren't fabricated when making a vanilla user. There are two places where you'd want to use this:

You have fabricated a user that needs a certain trust level (which is now based on group membership.)
You need the system user to have a certain trust level.
In the first case, we can pass refresh_auto_groups: true to the fabricator instead. This is a more lightweight operation that only considers a single user, instead of all users in all groups.

The second case is no longer a thing after #25400.
2024-01-25 14:28:26 +08:00
Ted Johansson 294febf3c4 DEV: Convert min_trust_to_flag_posts setting to groups (#24864)
We're changing the implementation of trust levels to use groups. Part of this is to have site settings that reference trust levels use groups instead. It converts the min_trust_to_flag_posts site setting to flag_post_allowed_groups.

Note: In the original setting, "posts" is plural. I have changed this to "post" singular in the new setting to match others.
2023-12-13 17:18:42 +08:00
Daniel Waterworth 6e161d3e75 DEV: Allow fab! without block (#24314)
The most common thing that we do with fab! is:

    fab!(:thing) { Fabricate(:thing) }

This commit adds a shorthand for this which is just simply:

    fab!(:thing)

i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
2023-11-09 16:47:59 -06:00
Loïc Guitaut 783c935dcb DEV: Set limits for text fields in reviewables 2023-05-03 09:54:54 +02:00
e52bbc1230 UX/DEV: Review queue redesign fixes (#20239)
* UX: add type tag and design update

* UX: clarify status copy in reviewQ

* DEV: switch to selectKit

* UX: color approve/reject buttons in RQ

* DEV: regroup actions

* UX: add type tag and design update

* UX: clarify status copy in reviewQ

* Join questions for flagged post with "or" with new I18n function
* Move ReviewableScores component out of context
* Add CSS classes to reviewable-item based on human type

* UX: add table header for scoring

* UX: don't display % score

* UX: prefix modifier class with dash

* UX: reviewQ flag table styling

* UX: consistent use of ignore icon

* DEV: only show context question on pending status

* UX: only show table headers on pending status

* DEV: reviewQ regroup actions for hidden posts

* UX: reviewQ > approve/reject buttons

* UX: reviewQ add fadeout

* UX: reviewQ styling

* DEV: move scores back into component

* UX: reviewQ mobile styling

* UX: score table on mobile

* UX: reviewQ > move meta info outside table

* UX: reviewQ > score layout fixes

* DEV: readd `agree_and_keep` and fix the spec tests.

* Fix the spec tests

* fix the quint test

* DEV: readd deleting replies

* UX: reviewQ copy tweaks

* DEV: readd test for ignore + delete replies

* Remove old

* FIX: Add perform_ignore back in for backwards compat

* DEV: add an action alias `ignore` for `ignore_and_do_nothing`.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
Co-authored-by: Vinoth Kannan <svkn.87@gmail.com>
2023-03-02 16:40:53 +01:00
Blake Erickson c540167982 FIX: Remove action buttons if post has already been reviewed (#20126)
* FIX: Remove action buttons if post has already been reviewed

* Change the approve to reject test to expect an error

* Adds a controller spec to ensure you can't edit a non-pending review item

* Remove unnessary conditional
2023-02-06 11:55:52 -07:00
David Taylor cb932d6ee1 DEV: Apply syntax_tree formatting to spec/* 2023-01-09 11:49:28 +00:00
Osama Sayegh 3ff6f6a5e1 FIX: Exclude claimed reviewables from user menu (#19179)
Users who can access the review queue can claim a pending reviewable(s) which means that the claimed reviewable(s) can only be handled by the user who claimed it. Currently, we show claimed reviewables in the user menu, but this can be annoying for other reviewers because they can't do anything about a reviewable claimed by someone. So this PR makes sure that we only show in the user menu reviewables that are claimed by nobody or claimed by the current user.

Internal topic: t/77235.
2022-12-01 07:09:57 +08:00
Roman Rizzi 94aba90c56 DEV: Delete reviewable associations when deleting (#18472) 2022-10-05 13:38:41 -03:00
Osama Sayegh 079450c9e4 DEV: Do not show handled reviewables in the user menu (#18402)
Currently, the reviewables tab in the user menu shows pending reviewables at the top of the menu and fills the remaining space in the menu with old/handled reviewables. This PR makes the revieables tab show only pending reviewables and hides the tab altogether from the menu if there are no pending reviewables. We're going to follow-up with another change soon that will show pending reviewables in the main tab of the user menu.

Internal topic: t/73220.
2022-09-30 06:10:07 +03:00
Loïc Guitaut 26fe047724 DEV: Use AR enums in reviewables related code
This is the first patch of many to replace our custom enums in Ruby by
the ones provided by `ActiveRecord`.
2022-09-22 14:44:27 +02:00
Loïc Guitaut 3eaac56797 DEV: Use proper wording for contexts in specs 2022-08-04 11:05:02 +02:00
Osama Sayegh ce9eec8606 DEV: Combine all header notification bubbles into one in the new user menu (#17718)
Extracted from https://github.com/discourse/discourse/pull/17379.
2022-08-03 08:57:59 +03:00
Osama Sayegh 988a175e94 DEV: Add reviewables tab to the new user menu (#17630)
This commit is a subset of the changes proposed in https://github.com/discourse/discourse/pull/17379.
2022-07-28 11:16:33 +03:00
Loïc Guitaut 296aad430a DEV: Use describe for methods in specs 2022-07-27 16:35:27 +02:00
David Taylor c9dab6fd08 DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00
Mark VanLandingham 14a13dc192 FIX: Check type of existing reviewables when new reviewable is created (#13662) 2021-07-07 11:45:00 -05:00
Roman Rizzi 4dc8c3c409 FEATURE: Blocking is optional when deleting a user from the review queue. (#13375)
Subclasses must call #delete_user_actions inside build_actions to support user deletion. The method adds a delete user bundle, which has a delete and a delete + block option. Every subclass is responsible for implementing these actions.
2021-06-15 12:35:45 -03:00
Dan Ungureanu 197e3f24ce FEATURE: Show stale reviewable to other clients (#13114)
The previous commits removed reviewables leading to a bad user
experience. This commit updates the status, replaces actions with a
message and greys out the reviewable.
2021-05-26 09:47:35 +10:00
Roman Rizzi 4d9686c494 FEATURE: Reviewed by filter. (#11405)
New reviewable filter to only display reviewables handled by a specific user.
2020-12-04 14:09:05 -03:00
Roman Rizzi f2bef7ea8f FIX: Store Reviewable's force_review as a boolean. (#11219)
* FIX: Store Reviewable's force_review as a boolean.

Using the `force_review` flag raises the score to hit the minimum visibility threshold. This strategy turned out to be ineffective on sites with a high number of flags, where these values could rapidly fluctuate.

This change adds a `force_review` column on the reviewables table and modifies the `Reviewable#list_for` method to show these items when passing the `status: :pending` option, even if the score is not high enough. ReviewableQueuedPosts and ReviewableUsers are always created using this option.
2020-11-13 08:19:01 -03:00
jbrw 06073fe8c6 FEATURE: Allow group moderators to close/archive topics
* FEATURE: Allow group moderators to close/archive topics
2020-07-14 12:36:19 -04:00
Roman Rizzi 461df7d050 UX: Rename Priority to score for sorting. (#9846) 2020-05-27 12:50:28 -03:00
Martin Brennan 9981fa4466 FIX: Prevent column name conflicts in reviewable code (#9753)
We were getting errors like this in Reviewables in some cases:

```
ActiveRecord::StatementInvalid (PG::AmbiguousColumn: ERROR:  column reference "category_id" is ambiguous
LINE 4: ...TRUE) OR (reviewable_by_group_id IN (NULL))) AND (category_i...
```

The problem that was making everything go boom is that plugins can add their own custom filters for Reviewables. If one is doing an INNER JOIN on topics, which has its own category_id column, we would get the above AmbiguousColumn error. The solution here is to just make all references to the reviewable columns in the list_for and viewable_by code prefixed by the table name e.g. reviewables.category_id.
2020-05-13 09:05:56 +10:00
Roman Rizzi e52e7f6e75 FIX: Include pending queued users regardless of their score (#9372) 2020-04-07 11:42:12 -03:00
romanrizzi cfec10a568 FIX: Moderators should be able to review flagged PMs since this has always been like this 2020-03-20 12:28:36 -03:00
Roman Rizzi 080960a15e FIX: Show the envelope icon when the flagged post is a PM. Flagged PM must be exclusively reviewed by admins (#9232) 2020-03-19 15:12:42 -03:00
Roman Rizzi fadb2b7157 FEATURE: Users cannot reflag recently handled items using the same reason unless the post was edited, or it was reviewed more than 24 hours ago. (#8969) 2020-02-14 13:43:48 -03:00
Roman Rizzi 3413ec0a5c FEATURE: Pending queued posts are included even if they don't pass the minimum priority threshold (#8925) 2020-02-11 15:29:22 -03:00
Roman Rizzi c751291769 FIX: The 'reviewed' status filter should include deleted elements (#8630) 2019-12-30 14:56:17 -03:00
Roman Rizzi c92f0b8775 FEATURE: New API to apply custom filters to the review queue (#8392) 2019-11-22 16:33:10 -03:00
Robin Ward 3c6a5836c2 FIX: Sensitivity did not work by default
Forums without previously calculated scores would return the same values
for low/medium/high sensitivity. Now those are scaled based on the
default value.

The default value has also been changed from 10.0 to 12.5 based on
observing data from live discourse forums.
2019-09-19 13:26:17 -04:00
Dan Ungureanu 3008ecccbd FIX: Notify on Reviewable update. (#7980)
If a post is flagged after an action was already performed on it, it
will update the previous Reviable instance and not create a new one.
The notification logic was implemented in the :create callback which was
completely skipped in this case.
2019-08-08 16:04:34 +02:00
Guo Xiang Tan 32b4bdaccd DEV: Remove mocks from tests. 2019-08-08 15:17:45 +08:00
Robin Ward f1b3e72581 FIX: Don't hide/close topics if they don't meet minimum visibility
There are situations where depending on site settings, actions could be
taken due to flags (for example, hiding a post) but those actions were
not visibile in the review queue due to visibility settings.

This patch makes sure that the minimum score required for an action such
as hiding a post needs to meet the visibility for a moderator to see it.
2019-08-06 15:36:39 -04:00
Robin Ward d902c4eb9f FEATURE: Can sort reviewable queue
Choices are Priority / Created At (and desc versions.)
2019-06-05 13:21:05 -04:00
Robin Ward 89b84651c3 Migrate score settings to use sensitivities
We hide scores so these settings no longer made sense.
2019-05-24 15:44:24 -04:00