mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:21:18 +08:00
DEV: Update rubocop-discourse to latest version
The lastest version of rubocop-discourse enables rules regarding plugins.
This commit is contained in:

committed by
Loïc Guitaut

parent
7a6ba47e7b
commit
f7d7092a7a
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Chat::Api::CategoryChatablesController < ApplicationController
|
||||
requires_plugin Chat::PLUGIN_NAME
|
||||
|
||||
def permissions
|
||||
category = Category.find(params[:id])
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
CHANNEL_EDITABLE_PARAMS ||= %i[name description slug]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS ||= %i[
|
||||
auto_join_users
|
||||
allow_channel_wide_mentions
|
||||
threading_enabled
|
||||
]
|
||||
|
||||
class Chat::Api::ChannelsController < Chat::ApiController
|
||||
CHANNEL_EDITABLE_PARAMS ||= %i[name description slug]
|
||||
CATEGORY_CHANNEL_EDITABLE_PARAMS ||= %i[
|
||||
auto_join_users
|
||||
allow_channel_wide_mentions
|
||||
threading_enabled
|
||||
]
|
||||
|
||||
def index
|
||||
permitted = params.permit(:filter, :limit, :offset, :status)
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
MEMBERSHIP_EDITABLE_PARAMS = %i[muted desktop_notification_level mobile_notification_level]
|
||||
|
||||
class Chat::Api::ChannelsCurrentUserNotificationsSettingsController < Chat::Api::ChannelsController
|
||||
MEMBERSHIP_EDITABLE_PARAMS = %i[muted desktop_notification_level mobile_notification_level]
|
||||
|
||||
def update
|
||||
settings_params = params.require(:notifications_settings).permit(MEMBERSHIP_EDITABLE_PARAMS)
|
||||
membership_from_params.update!(settings_params.to_h)
|
||||
|
@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Chat::Api::HintsController < ApplicationController
|
||||
requires_plugin Chat::PLUGIN_NAME
|
||||
|
||||
before_action :ensure_logged_in
|
||||
|
||||
def check_group_mentions
|
||||
|
@ -2,18 +2,10 @@
|
||||
|
||||
module Chat
|
||||
class ApiController < ::Chat::BaseController
|
||||
before_action :ensure_logged_in
|
||||
before_action :ensure_can_chat
|
||||
|
||||
include Chat::WithServiceHelper
|
||||
|
||||
private
|
||||
|
||||
def ensure_can_chat
|
||||
raise Discourse::NotFound unless SiteSetting.chat_enabled
|
||||
guardian.ensure_can_chat!
|
||||
end
|
||||
|
||||
def default_actions_for_service
|
||||
proc do
|
||||
on_success { render(json: success_json) }
|
||||
|
@ -2,13 +2,14 @@
|
||||
|
||||
module Chat
|
||||
class BaseController < ::ApplicationController
|
||||
requires_plugin Chat::PLUGIN_NAME
|
||||
|
||||
before_action :ensure_logged_in
|
||||
before_action :ensure_can_chat
|
||||
|
||||
private
|
||||
|
||||
def ensure_can_chat
|
||||
raise Discourse::NotFound unless SiteSetting.chat_enabled
|
||||
guardian.ensure_can_chat!
|
||||
end
|
||||
|
||||
|
@ -33,6 +33,10 @@ GlobalSetting.add_default(:allow_unsecure_chat_uploads, false)
|
||||
|
||||
module ::Chat
|
||||
PLUGIN_NAME = "chat"
|
||||
RETENTION_SETTINGS_TO_USER_OPTION_FIELDS = {
|
||||
chat_channel_retention_days: :dismissed_channel_retention_reminder,
|
||||
chat_dm_retention_days: :dismissed_dm_retention_reminder,
|
||||
}
|
||||
end
|
||||
|
||||
require_relative "lib/chat/engine"
|
||||
@ -70,7 +74,7 @@ after_initialize do
|
||||
Group.prepend Chat::GroupExtension
|
||||
Jobs::UserEmail.prepend Chat::UserEmailExtension
|
||||
Plugin::Instance.prepend Chat::PluginInstanceExtension
|
||||
Jobs::ExportCsvFile.class_eval { prepend Chat::MessagesExporter }
|
||||
Jobs::ExportCsvFile.prepend Chat::MessagesExporter
|
||||
WebHook.prepend Chat::OutgoingWebHookExtension
|
||||
end
|
||||
|
||||
@ -270,12 +274,8 @@ after_initialize do
|
||||
include_condition: -> { SiteSetting.chat_enabled && SiteSetting.create_thumbnails },
|
||||
) { object.thumbnail }
|
||||
|
||||
RETENTION_SETTINGS_TO_USER_OPTION_FIELDS = {
|
||||
chat_channel_retention_days: :dismissed_channel_retention_reminder,
|
||||
chat_dm_retention_days: :dismissed_dm_retention_reminder,
|
||||
}
|
||||
on(:site_setting_changed) do |name, old_value, new_value|
|
||||
user_option_field = RETENTION_SETTINGS_TO_USER_OPTION_FIELDS[name.to_sym]
|
||||
user_option_field = Chat::RETENTION_SETTINGS_TO_USER_OPTION_FIELDS[name.to_sym]
|
||||
begin
|
||||
if user_option_field && old_value != new_value && !new_value.zero?
|
||||
UserOption.where(user_option_field => true).update_all(user_option_field => false)
|
||||
@ -342,10 +342,9 @@ after_initialize do
|
||||
nil
|
||||
end
|
||||
|
||||
CHAT_NOTIFICATION_TYPES = [Notification.types[:chat_mention], Notification.types[:chat_message]]
|
||||
register_push_notification_filter do |user, payload|
|
||||
if user.user_option.only_chat_push_notifications && user.user_option.chat_enabled
|
||||
CHAT_NOTIFICATION_TYPES.include?(payload[:notification_type])
|
||||
payload[:notification_type].in?(::Notification.types.values_at(:chat_mention, :chat_message))
|
||||
else
|
||||
true
|
||||
end
|
||||
|
Reference in New Issue
Block a user