From 9e3d24a150acf118789461797735fc0e4a8a30ea Mon Sep 17 00:00:00 2001 From: ysksn Date: Thu, 16 Nov 2017 20:13:03 +0900 Subject: Fix AccountFinderConcern::AccountFinder#with_usernames (#5722) --- app/models/concerns/account_finder_concern.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/models') diff --git a/app/models/concerns/account_finder_concern.rb b/app/models/concerns/account_finder_concern.rb index 561c7ab9f..2e8a7fb37 100644 --- a/app/models/concerns/account_finder_concern.rb +++ b/app/models/concerns/account_finder_concern.rb @@ -44,7 +44,7 @@ module AccountFinderConcern end def with_usernames - Account.where.not(username: [nil, '']) + Account.where.not(username: '') end def matching_username -- cgit From 2151fd315023a7f6849c6c9a519cd01deac09aa1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 17 Nov 2017 01:22:38 +0100 Subject: Display moderator badge (green), admin badge changed to red (#5728) --- app/javascript/styles/mastodon/accounts.scss | 18 +++++++++++++++--- app/models/account.rb | 2 ++ app/views/accounts/_header.html.haml | 6 +++++- config/locales/en.yml | 1 + 4 files changed, 23 insertions(+), 4 deletions(-) (limited to 'app/models') diff --git a/app/javascript/styles/mastodon/accounts.scss b/app/javascript/styles/mastodon/accounts.scss index 30adf8cdc..ca55de28d 100644 --- a/app/javascript/styles/mastodon/accounts.scss +++ b/app/javascript/styles/mastodon/accounts.scss @@ -531,7 +531,19 @@ font-size: 12px; line-height: 12px; font-weight: 500; - color: $success-green; - background-color: rgba($success-green, 0.1); - border: 1px solid rgba($success-green, 0.5); + color: $ui-secondary-color; + background-color: rgba($ui-secondary-color, 0.1); + border: 1px solid rgba($ui-secondary-color, 0.5); + + &.moderator { + color: $success-green; + background-color: rgba($success-green, 0.1); + border-color: rgba($success-green, 0.5); + } + + &.admin { + color: $error-red; + background-color: rgba($error-red, 0.1); + border-color: rgba($error-red, 0.5); + } } diff --git a/app/models/account.rb b/app/models/account.rb index 6f6010f7a..bc01d2448 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -115,6 +115,8 @@ class Account < ApplicationRecord :current_sign_in_at, :confirmed?, :admin?, + :moderator?, + :staff?, :locale, to: :user, prefix: true, diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 5530fcc20..e4c258acd 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -29,8 +29,12 @@ - if account.user_admin? .roles - .account-role + .account-role.admin = t 'accounts.roles.admin' + - elsif account.user_moderator? + .roles + .account-role.moderator + = t 'accounts.roles.moderator' .bio .account__header__content.p-note.emojify= Formatter.instance.simplified_format(account) diff --git a/config/locales/en.yml b/config/locales/en.yml index e94165317..11c34b912 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -48,6 +48,7 @@ en: reserved_username: The username is reserved roles: admin: Admin + moderator: Mod unfollow: Unfollow admin: account_moderation_notes: -- cgit From 3e90987c8b0c620b6fc104350b8eb16d17d7e80a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 17 Nov 2017 02:06:26 +0100 Subject: Fix some rubocop style issues (#5730) --- app/controllers/application_controller.rb | 2 +- app/controllers/auth/sessions_controller.rb | 2 +- app/helpers/admin/filter_helper.rb | 2 +- app/lib/extractor.rb | 3 ++- app/models/web/push_subscription.rb | 4 ++-- app/services/batched_remove_status_service.rb | 2 +- app/services/resolve_remote_account_service.rb | 4 ++-- 7 files changed, 10 insertions(+), 9 deletions(-) (limited to 'app/models') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f41a7f9be..a213302cb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -104,7 +104,7 @@ class ApplicationController < ActionController::Base unless uncached_ids.empty? uncached = klass.where(id: uncached_ids).with_includes.map { |item| [item.id, item] }.to_h - uncached.values.each do |item| + uncached.each_value do |item| Rails.cache.write(item.cache_key, item) end end diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb index 463a183e4..a5acb6c36 100644 --- a/app/controllers/auth/sessions_controller.rb +++ b/app/controllers/auth/sessions_controller.rb @@ -62,7 +62,7 @@ class Auth::SessionsController < Devise::SessionsController if user_params[:otp_attempt].present? && session[:otp_user_id] authenticate_with_two_factor_via_otp(user) - elsif user && user.valid_password?(user_params[:password]) + elsif user&.valid_password?(user_params[:password]) prompt_for_two_factor(user) end end diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb index 6a57b3d63..e0fae9d9a 100644 --- a/app/helpers/admin/filter_helper.rb +++ b/app/helpers/admin/filter_helper.rb @@ -18,7 +18,7 @@ module Admin::FilterHelper def selected?(more_params) new_url = filtered_url_for(more_params) - filter_link_class(new_url) == 'selected' ? true : false + filter_link_class(new_url) == 'selected' end private diff --git a/app/lib/extractor.rb b/app/lib/extractor.rb index 957364293..738ec89a0 100644 --- a/app/lib/extractor.rb +++ b/app/lib/extractor.rb @@ -5,7 +5,8 @@ module Extractor module_function - def extract_mentions_or_lists_with_indices(text) # :yields: username, list_slug, start, end + # :yields: username, list_slug, start, end + def extract_mentions_or_lists_with_indices(text) return [] unless text =~ Twitter::Regex[:at_signs] possible_entries = [] diff --git a/app/models/web/push_subscription.rb b/app/models/web/push_subscription.rb index da67e7665..a41906227 100644 --- a/app/models/web/push_subscription.rb +++ b/app/models/web/push_subscription.rb @@ -24,12 +24,12 @@ class Web::PushSubscription < ApplicationRecord end def pushable?(notification) - data && data.key?('alerts') && data['alerts'][notification.type.to_s] + data&.key?('alerts') && data['alerts'][notification.type.to_s] end def as_payload payload = { id: id, endpoint: endpoint } - payload[:alerts] = data['alerts'] if data && data.key?('alerts') + payload[:alerts] = data['alerts'] if data&.key?('alerts') payload end diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb index 5d83771c9..676a5d04d 100644 --- a/app/services/batched_remove_status_service.rb +++ b/app/services/batched_remove_status_service.rb @@ -26,7 +26,7 @@ class BatchedRemoveStatusService < BaseService statuses.each(&:destroy) # Batch by source account - statuses.group_by(&:account_id).each do |_, account_statuses| + statuses.group_by(&:account_id).each_value do |account_statuses| account = account_statuses.first.account unpush_from_home_timelines(account, account_statuses) diff --git a/app/services/resolve_remote_account_service.rb b/app/services/resolve_remote_account_service.rb index 3d0a36f6c..3293fe40f 100644 --- a/app/services/resolve_remote_account_service.rb +++ b/app/services/resolve_remote_account_service.rb @@ -124,11 +124,11 @@ class ResolveRemoteAccountService < BaseService end def auto_suspend? - domain_block && domain_block.suspend? + domain_block&.suspend? end def auto_silence? - domain_block && domain_block.silence? + domain_block&.silence? end def domain_block -- cgit