FIX: generates automatic slug for trashed channels (#19908)

Prior to this fix trashed channels would still prevent a channel with the same slug to be created. This commit generates a new slug on trash and frees the slug for future usage.

The format used for the slug is: `YYYYMMDD-HHMM-OLD_SLUG-deleted` truncated to the max length of a channel name.
This commit is contained in:
Joffrey JAFFEUX
2023-01-23 15:05:47 +01:00
committed by GitHub
parent b26e0dcf35
commit 34d158c4aa
2 changed files with 28 additions and 0 deletions

View File

@ -38,6 +38,13 @@ class Chat::Api::ChatChannelsController < Chat::Api
begin
ChatChannel.transaction do
channel_from_params.update!(
slug:
"#{Time.now.strftime("%Y%m%d-%H%M")}-#{channel_from_params.slug}-deleted".truncate(
SiteSetting.max_topic_title_length,
omission: "",
),
)
channel_from_params.trash!(current_user)
StaffActionLogger.new(current_user).log_custom(
"chat_channel_delete",