DEV: Remove experimental site setting for chat threads (#22720)

We are removing the experimental site setting. Admins can now decide on a per channel basis to enable/disable threading. It's disabled by default.
This commit is contained in:
Jan Cernik
2023-07-26 07:46:23 -03:00
committed by GitHub
parent d06431ba9b
commit a2eb2b0490
67 changed files with 287 additions and 653 deletions

View File

@@ -6,7 +6,6 @@ module Jobs
sidekiq_options queue: "critical"
def execute(args = {})
return if !SiteSetting.enable_experimental_chat_threaded_discussions
channel = ::Chat::Channel.find_by(id: args[:channel_id])
return if channel.blank?
channel.mark_all_threads_as_read

View File

@@ -4,8 +4,6 @@ module Jobs
module Chat
class UpdateThreadReplyCount < Jobs::Base
def execute(args = {})
return if !SiteSetting.enable_experimental_chat_threaded_discussions
thread = ::Chat::Thread.find_by(id: args[:thread_id])
return if thread.blank?
return if thread.replies_count_cache_recently_updated?

View File

@@ -188,9 +188,7 @@ module Chat
end
def mark_all_threads_as_read(user: nil)
if !(self.threading_enabled || SiteSetting.enable_experimental_chat_threaded_discussions)
return
end
return if !self.threading_enabled
DB.exec(<<~SQL, channel_id: self.id)
UPDATE user_chat_thread_memberships

View File

@@ -108,7 +108,6 @@ module Chat
end
def self.ensure_consistency!
return if !SiteSetting.enable_experimental_chat_threaded_discussions
update_counts
end

View File

@@ -25,10 +25,6 @@ module Chat
has_one :last_message, serializer: Chat::LastMessageSerializer, embed: :objects
def threading_enabled
SiteSetting.enable_experimental_chat_threaded_discussions && object.threading_enabled
end
def initialize(object, opts)
super(object, opts)

View File

@@ -177,7 +177,7 @@ module Chat
end
def include_threading_data?
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
channel.threading_enabled
end
def include_thread_id?

View File

@@ -8,10 +8,6 @@ module Chat
object[:tracking]
end
def include_unread_thread_overview?
SiteSetting.enable_experimental_chat_threaded_discussions
end
def unread_thread_overview
object[:unread_thread_overview]
end

View File

@@ -36,7 +36,7 @@ module Chat
end
def include_thread_data?
channel.threading_enabled && SiteSetting.enable_experimental_chat_threaded_discussions
channel.threading_enabled
end
def channel

View File

@@ -112,8 +112,7 @@ module Chat
end
def determine_threads_enabled(channel:, **)
context.threads_enabled =
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
context.threads_enabled = channel.threading_enabled
end
def determine_include_thread_messages(contract:, threads_enabled:, **)

View File

@@ -24,7 +24,6 @@ module Chat
# @param [Integer] offset
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
step :set_limit
step :set_offset
@@ -55,10 +54,6 @@ module Chat
context.offset = [contract.offset || 0, 0].max
end
def threaded_discussions_enabled
::SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_channel(contract:, **)
::Chat::Channel.strict_loading.includes(:chatable).find_by(id: contract.channel_id)
end

View File

@@ -2,10 +2,7 @@
module Chat
# Finds a thread within a channel. The thread_id and channel_id must
# match. For now we do not want to allow fetching threads if the
# enable_experimental_chat_threaded_discussions hidden site setting
# is not turned on, and the channel must specifically have threading
# enabled.
# match, and the channel must specifically have threading enabled.
#
# @example
# Chat::LookupThread.call(thread_id: 88, channel_id: 2, guardian: guardian)
@@ -19,7 +16,6 @@ module Chat
# @param [Guardian] guardian
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
model :thread, :fetch_thread
policy :invalid_access
@@ -37,10 +33,6 @@ module Chat
private
def threaded_discussions_enabled
SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_thread(contract:, **)
Chat::Thread.includes(
:channel,

View File

@@ -32,7 +32,7 @@ module Chat
end
def self.allow_publish_to_thread?(channel)
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
channel.threading_enabled
end
def self.publish_new!(chat_channel, chat_message, staged_id, staged_thread_id: nil)
@@ -161,8 +161,7 @@ module Chat
def self.publish_delete!(chat_channel, chat_message)
message_bus_targets = calculate_publish_targets(chat_channel, chat_message)
latest_not_deleted_message_id =
if chat_message.thread_reply? && chat_channel.threading_enabled &&
SiteSetting.enable_experimental_chat_threaded_discussions
if chat_message.thread_reply? && chat_channel.threading_enabled
chat_message.thread.latest_not_deleted_message_id(anchor_message_id: chat_message.id)
else
chat_channel.latest_not_deleted_message_id(anchor_message_id: chat_message.id)

View File

@@ -34,7 +34,6 @@ module Chat
# @return [Service::Base::Context]
contract
policy :threaded_discussions_settings_ok
step :cast_thread_and_channel_ids_to_integer
model :report
@@ -49,11 +48,6 @@ module Chat
private
def threaded_discussions_settings_ok(contract:, **)
return true if !contract.include_threads
SiteSetting.enable_experimental_chat_threaded_discussions
end
def cast_thread_and_channel_ids_to_integer(contract:, **)
contract.thread_ids = contract.thread_ids.map(&:to_i)
contract.channel_ids = contract.channel_ids.map(&:to_i)

View File

@@ -2,10 +2,7 @@
module Chat
# Updates a thread. The thread_id and channel_id must
# match. For now we do not want to allow updating threads if the
# enable_experimental_chat_threaded_discussions hidden site setting
# is not turned on, and the channel must specifically have threading
# enabled.
# match, and the channel must specifically have threading enabled.
#
# Only the thread title can be updated.
#
@@ -22,7 +19,6 @@ module Chat
# @option params_to_edit [String,nil] title
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
model :thread, :fetch_thread
policy :can_view_channel
@@ -43,10 +39,6 @@ module Chat
private
def threaded_discussions_enabled
SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_thread(contract:, **)
Chat::Thread.find_by(id: contract.thread_id, channel_id: contract.channel_id)
end