mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
12a18d4d55
This commit main goal was to comply with Zeitwerk and properly rely on autoloading. To achieve this, most resources have been namespaced under the `Chat` module. - Given all models are now namespaced with `Chat::` and would change the stored types in DB when using polymorphism or STI (single table inheritance), this commit uses various Rails methods to ensure proper class is loaded and the stored name in DB is unchanged, eg: `Chat::Message` model will be stored as `"ChatMessage"`, and `"ChatMessage"` will correctly load `Chat::Message` model. - Jobs are now using constants only, eg: `Jobs::Chat::Foo` and should only be enqueued this way Notes: - This commit also used this opportunity to limit the number of registered css files in plugin.rb - `discourse_dev` support has been removed within this commit and will be reintroduced later <!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
26 lines
843 B
Ruby
26 lines
843 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Chat
|
|
class SecureUploadsCompatibility
|
|
##
|
|
# At this point in time, secure uploads is not compatible with chat,
|
|
# so if it is enabled then chat uploads must be disabled to avoid undesirable
|
|
# behaviour.
|
|
#
|
|
# The env var DISCOURSE_ALLOW_UNSECURE_CHAT_UPLOADS can be set to keep
|
|
# it enabled, but this is strongly advised against.
|
|
def self.update_settings
|
|
if SiteSetting.secure_uploads && SiteSetting.chat_allow_uploads &&
|
|
!GlobalSetting.allow_unsecure_chat_uploads
|
|
SiteSetting.chat_allow_uploads = false
|
|
StaffActionLogger.new(Discourse.system_user).log_site_setting_change(
|
|
"chat_allow_uploads",
|
|
true,
|
|
false,
|
|
context: "Disabled because secure_uploads is enabled",
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|