mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 07:51:36 +08:00
c6764d8c74
This commit automatically ensures that category channels have slugs when they are created or updated based on the channel name, category name, or existing slug. The behaviour has been copied from the Category model. We also include a backfill here with a simplified version of Slug.for with deduplication to fill the slugs for already created Category chat channels. The channel slug is also now used for chat notifications, and for the UI and navigation for chat. `slugifyChannel` is still used, but now does the following fallback: * Uses channel.slug if it is present * Uses channel.escapedTitle if it is present * Uses channel.title if it is present In future we may want to remove this altogether and always rely on the slug being present, but this is currently not possible because we are not generating slugs for DM channels at this point.
30 lines
437 B
Ruby
30 lines
437 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DirectMessageChannel < ChatChannel
|
|
alias_attribute :direct_message, :chatable
|
|
|
|
def direct_message_channel?
|
|
true
|
|
end
|
|
|
|
def allowed_user_ids
|
|
direct_message.user_ids
|
|
end
|
|
|
|
def read_restricted?
|
|
true
|
|
end
|
|
|
|
def title(user)
|
|
direct_message.chat_channel_title_for_user(self, user)
|
|
end
|
|
|
|
def ensure_slug_ok
|
|
true
|
|
end
|
|
|
|
def generate_auto_slug
|
|
self.slug = nil
|
|
end
|
|
end
|