A while ago the `accept_all_solutions_allowed_groups` setting was introduced to replace the `accept_all_solutions_trust_level` setting and to make the plugin more flexible by allowing admins to choose groups that are allowed to accept solutions instead of trust levels.
The new group-based setting includes the TL4 group by default. However, removing the TL4 group from the setting doesn't actually remove TL4 users permission to accept solution.
The reason for this bug is that the `can_accept_answer?` guardian method calls `can_perform_action_available_to_group_moderators?` which always allows TL4 users to perform category moderator actions:
56524f4bdf/lib/guardian/topic_guardian.rb (L342-L348)
This commit fixes the bug by checking if the user is a moderator on the topic's category (by calling the `is_category_group_moderator?` guardian method) instead of checking if the user can perform category moderator actions. In our case, `is_category_group_moderator?` is equivalent to `can_perform_action_available_to_group_moderators?` except for the TL4 check which is what we need.
Internal topic: t/134675.
it would raise an error because we delete the topic before and we need the topic record to update various meta data.
This ensures we load the "deleted" version in such cases.
Internal ref - t/130797
* FEATURE: change status on unsolve & fix assign changes
When a topic is unsolved, it should have an option,
defined in the settings, to change its status to that state.
Fix assign changes when a topic was solved, previously it was
changing the assignee.
* DEV: Change names in tests and remove comments
* DEV: Update change status on solve implementation
Update tests to verify that the change status on solve feature is working as expected.
Change the implementation to loop throught the topic assignments and update the status.
* DEV: address review feedback
* FEATURE: Prevents assign notification & change status on solved
Relates to this [topic](https://meta.discourse.org/t/assign-plugin-for-informatica/256974/94)
Add an event listener to `accepted_solution` event
Add `assigns_reminder_assigned_topics_query` modifier to not notify if
`prevent_assign_notification` setting is on.
Add settings to prevent assign notification and change status on solved
* DEV: Address review comments
Update SiteSettings names.
* DEV(WIP): Add tests for integration with discourse-assign
Add test for integration with discourse-assign plugin
checks if the assignment status is moved to `Done`
* DEV: lint solved_spec.rb
* DEV: Update test where it updates all assignments
Change `on(:accepted_solution)` is defined
Update test to use acting_user instead of admin
* DEV: lint & add tests for assigns_reminder_assigned_topics_query
Linted and added tests for `assigns_reminder_assigned_topics_query` modifier.
* DEV: Update tests based on review feedback
change plugin_initializer location
update spec with new tests to test integration with discourse-assign
* DEV: Add describe to spec for discourse-assign integration tests
* DEV: update describe name for discourse-assing spec integration
* DEV: Add more tests to spec for discourse-assign integration
* DEV: Lint solved_spec
* DEV: Lint and update spec to not have `p1` topic inside
* FEATURE: add new custom status filters
Those can be used in /filter route.
Depends on https://github.com/discourse/discourse/pull/26770
Internal ref. /t/127278
* DEV: pin plugin for Discourse 3.3.0.beta2-dev
When using the `status:unsolved` search filter, the plugin was only
returning results from topics in categories where solved was enabled.
This commit changes the search query to also include topics with tags
that have solved enabled via the `enable_solved_tags` site setting.
This fixes the `status:unsolved tags:tag1` search query.
This refactor makes for easier testing and makes things
more organised, the guardian extensions had no testing
whatsoever and I need some to make the TL -> group change.
We're updating core to change TL based access settings to be group based. This requires some updates of tests to work correctly. (The existing test setup gives false positives.)
In https://github.com/discourse/discourse/pull/24740, `min_trust_to_create_topic` site setting was replaced by `create_topic_allowed_groups`. This PR replaces the former, deprecated one, with the latter.
c.f. de983796e1b66aa2ab039a4fb6e32cec8a65a098
There will soon be additional login_required checks
for Guardian, and the intent of many checks by automated
systems is better fulfilled by using BasicUser, which
simulates a logged in TL0 forum user, rather than an
anon user.
Ensures we remove the solution when the post marked as the solution is deleted.
DEV: Added `IS_ACCEPTED_ANSWER_CUSTOM_FIELD` constant.
DEV: Refactored the `PostSerializer` for better readability.
PERF: Improved the `TopicViewSerializer`'s performance by looking up the `accepted_answer_post_info` from the stream first.
Internal ref. dev/112251
Many consumers of Discourse solved may want solved topics to show up more
prominently in search. New setting `prioritize_solved_topics_in_search` (default off) allows
bumping these topics to the top.
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
* FEATURE: solved topic auto close setting per category
This commit adds per category "solved topics auto close hours" setting. The plugin would use the existing "solved topics auto close hours" setting, except if there was a setting for the relevant category in which case that would take precedence.
* minor changes per feedback
See https://github.com/discourse/discourse/pull/18437,
we are removing any references to enable_personal_messages
in core and using only personal_message_enabled_groups,
which requires auto groups to be assigned in certain specs
for them to keep working.
This PR adds a site setting called `enable_solved_tags`. Solved will be enabled for topics containing these tags, just like we do for specific categories.
* FEATURE: Publish WebHook event when solving/unsolving
This feature will publish a post edit webhook event whenever a solution
is accepted or unaccepted.
I went ahead and used the existing post-edit webhook because all the
post custom fields for the solved plugin are already included in the
post-edit serializer.
* Create Solved Event Webhook
This commit adds a solved event webhook that will only trigger when an
answer has been marked as accepted or unaccepted.
It uses 100 as the webhook ID. This way any new webhooks in core can
keep using lower numbers like 11, 12, 13, but plugins can use 101, 102,
etc.
* Removed functionality that was added to core
This [PR][1] to discourse core adds what what removed in this commit.
It is better to have this logic in core so that it is discoverable and
future webhooks won't end up accidentally using the same ID.
[1]: https://github.com/discourse/discourse/pull/9110
* UX: Add "solved" status filter in advanced search page.
And rename `in:solved` to `status:solved`.
* FEATURE: Publish WebHook event when solving/unsolving
This feature will publish a post edit webhook event whenever a solution
is accepted or unaccepted.
I went ahead and used the existing post-edit webhook because all the
post custom fields for the solved plugin are already included in the
post-edit serializer.
* Create Solved Event Webhook
This commit adds a solved event webhook that will only trigger when an
answer has been marked as accepted or unaccepted.
It uses 100 as the webhook ID. This way any new webhooks in core can
keep using lower numbers like 11, 12, 13, but plugins can use 101, 102,
etc.
* Removed functionality that was added to core
This [PR][1] to discourse core adds what what removed in this commit.
It is better to have this logic in core so that it is discoverable and
future webhooks won't end up accidentally using the same ID.
[1]: https://github.com/discourse/discourse/pull/9110
Co-authored-by: Vinoth Kannan <vinothkannan@vinkas.com>