DEV: Move discourse-chat to the core repo. (#18776)

As part of this move, we are also renaming `discourse-chat` to `chat`.
This commit is contained in:
Roman Rizzi
2022-11-02 10:41:30 -03:00
committed by GitHub
parent e7e24843dc
commit 0a5f548635
697 changed files with 61642 additions and 40 deletions

View File

@ -0,0 +1,22 @@
# frozen_string_literal: true
class ChatAllowUploadsValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(value)
return false if value == "t" && prevent_enabling_chat_uploads?
true
end
def error_message
if prevent_enabling_chat_uploads?
I18n.t("site_settings.errors.chat_upload_not_allowed_secure_uploads")
end
end
def prevent_enabling_chat_uploads?
SiteSetting.secure_uploads && !GlobalSetting.allow_unsecure_chat_uploads
end
end

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
class ChatDefaultChannelValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(value)
!!(value == "" || ChatChannel.find_by(id: value.to_i)&.public_channel?)
end
def error_message
I18n.t("site_settings.errors.chat_default_channel")
end
end

View File

@ -0,0 +1,15 @@
# frozen_string_literal: true
class DirectMessageEnabledGroupsValidator
def initialize(opts = {})
@opts = opts
end
def valid_value?(val)
val.present? && val != ""
end
def error_message
I18n.t("site_settings.errors.direct_message_enabled_groups_invalid")
end
end