Skip to content
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: Prevents assign notification & change status on solved #285

Merged
merged 12 commits into from Apr 26, 2024
Merged
31 changes: 31 additions & 0 deletions app/lib/plugin_initializer.rb
@@ -0,0 +1,31 @@
# frozen_string_literal: true

module DiscourseSolved
class PluginInitializer
attr_reader :plugin

def initialize(plugin)
@plugin = plugin
end

def apply_plugin_api
# this method should be overridden by subclasses
raise NotImplementedError
end
end

class AssignsRemainderForTopicsQuery < PluginInitializer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this remainder or reminder ?

def apply_plugin_api
plugin.register_modifier(:assigns_reminder_assigned_topics_query) do |query|
next query if !SiteSetting.prevent_assign_notification
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need this site setting to be more specific, something like ignore_solved_topics_in_assigned_reminder

query.where(
"topics.id NOT IN (
SELECT topic_id
FROM topic_custom_fields
WHERE name = 'accepted_answer_post_id'
)",
)
end
end
end
end
3 changes: 3 additions & 0 deletions config/locales/server.en.yml
Expand Up @@ -11,6 +11,9 @@ en:
solved_topics_auto_close_hours: "Auto close topic (n) hours after the last reply once the topic has been marked as solved. Set to 0 to disable auto closing."
show_filter_by_solved_status: "Show a dropdown to filter a topic list by solved status."
notify_on_staff_accept_solved: "Send notification to the topic creator when a post is marked as solution by a staff."
prevent_assign_notification: "Prevent notification from discourse-assign for solved topics."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here maybe "Prevent assigned reminder from including solved topics. only relevant when discourse-assign"

assign_to_status_on_solved: "Enable assigning a status when a topic is solved. Requires discourse-assign plugin."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe - "When a topic is solved update all assignments to this status"

status_to_assign_on_solved: "The status to assign when a topic is solved."
disable_solved_education_message: "Disable education message for solved topics."
accept_solutions_topic_author: "Allow the topic author to accept a solution."
solved_add_schema_markup: "Add QAPage schema markup to HTML."
Expand Down
7 changes: 7 additions & 0 deletions config/settings.yml
Expand Up @@ -32,6 +32,13 @@ discourse_solved:
client: true
notify_on_staff_accept_solved:
default: false
prevent_assign_notification:
default: false
assign_to_status_on_solved:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think we don't need this site setting. You can default status_to_assign_on_solved to an empty string rather than Done and use a present? or blank? check in plugin.rb. If a string is present we basically know that this is enabled.

default: false
status_to_assign_on_solved:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assignment_status_on_solve maybe? Since it's not the status to assign, it's the status that assignments get updated to 🤷

type: string
default: "Done"
disable_solved_education_message:
default: false
accept_solutions_topic_author:
Expand Down
9 changes: 9 additions & 0 deletions plugin.rb
Expand Up @@ -622,4 +622,13 @@ def self.skip_db?
end
end
end

if defined?(DiscourseAssign) && SiteSetting.assign_to_status_on_solved
on(:accepted_solution) do |post|
Assigner.new(post.topic, post.acting_user).assign(
post.acting_user,
status: SiteSetting.status_to_assign_on_solved,
)
end
end
end