mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
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:
22
plugins/chat/lib/validators/chat_allow_uploads_validator.rb
Normal file
22
plugins/chat/lib/validators/chat_allow_uploads_validator.rb
Normal 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
|
@ -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
|
@ -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
|
Reference in New Issue
Block a user