forked from treehouse/mastodon
Merge remote-tracking branch 'origin/master' into gs-master
commit
b28b405b97
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -571,7 +571,19 @@
|
|||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
font-weight: 500;
|
||||
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: 1px solid rgba($success-green, 0.5);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
end
|
||||
|
||||
def language_from_content
|
||||
return nil unless language_map?
|
||||
return LanguageDetector.instance.detect(text_from_content, @account) unless language_map?
|
||||
@object['contentMap'].keys.first
|
||||
end
|
||||
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -38,12 +38,31 @@ class LanguageDetector
|
|||
end
|
||||
|
||||
def simplify_text(text)
|
||||
text.dup.tap do |new_text|
|
||||
new_text = remove_html(text)
|
||||
new_text.gsub!(FetchLinkCardService::URL_PATTERN, '')
|
||||
new_text.gsub!(Account::MENTION_RE, '')
|
||||
new_text.gsub!(Tag::HASHTAG_RE, '')
|
||||
new_text.gsub!(/:#{CustomEmoji::SHORTCODE_RE_FRAGMENT}:/, '')
|
||||
new_text.gsub!(/\s+/, ' ')
|
||||
new_text
|
||||
end
|
||||
|
||||
def new_scrubber
|
||||
scrubber = Rails::Html::PermitScrubber.new
|
||||
scrubber.tags = %w(br p)
|
||||
scrubber
|
||||
end
|
||||
|
||||
def scrubber
|
||||
@scrubber ||= new_scrubber
|
||||
end
|
||||
|
||||
def remove_html(text)
|
||||
text = Loofah.fragment(text).scrub!(scrubber).to_s
|
||||
text.gsub!('<br>', "\n")
|
||||
text.gsub!('</p><p>', "\n\n")
|
||||
text.gsub!(/(^<p>|<\/p>$)/, '')
|
||||
text
|
||||
end
|
||||
|
||||
def default_locale(account)
|
||||
|
|
|
@ -117,6 +117,8 @@ class Account < ApplicationRecord
|
|||
:current_sign_in_at,
|
||||
:confirmed?,
|
||||
:admin?,
|
||||
:moderator?,
|
||||
:staff?,
|
||||
:locale,
|
||||
to: :user,
|
||||
prefix: true,
|
||||
|
|
|
@ -44,7 +44,7 @@ module AccountFinderConcern
|
|||
end
|
||||
|
||||
def with_usernames
|
||||
Account.where.not(username: [nil, ''])
|
||||
Account.where.not(username: '')
|
||||
end
|
||||
|
||||
def matching_username
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -30,8 +30,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!=processed_bio[:text]
|
||||
- if processed_bio[:metadata].length > 0
|
||||
|
|
|
@ -48,6 +48,7 @@ en:
|
|||
reserved_username: The username is reserved
|
||||
roles:
|
||||
admin: Admin
|
||||
moderator: Mod
|
||||
unfollow: Unfollow
|
||||
admin:
|
||||
account_moderation_notes:
|
||||
|
|
|
@ -168,7 +168,13 @@ Rails.application.routes.draw do
|
|||
resources :account_moderation_notes, only: [:create, :destroy]
|
||||
end
|
||||
|
||||
authenticate :user, lambda { |u| u.admin? } do
|
||||
get '/admin', to: redirect('/admin/settings/edit', status: 302)
|
||||
end
|
||||
|
||||
authenticate :user, lambda { |u| u.moderator? } do
|
||||
get '/admin', to: redirect('/admin/reports', status: 302)
|
||||
end
|
||||
|
||||
namespace :api do
|
||||
# PubSubHubbub outgoing subscriptions
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -47,10 +47,29 @@ RSpec.describe Status, type: :model do
|
|||
end
|
||||
|
||||
describe '#verb' do
|
||||
it 'is always post' do
|
||||
context 'if destroyed?' do
|
||||
it 'returns :delete' do
|
||||
subject.destroy!
|
||||
expect(subject.verb).to be :delete
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless destroyed?' do
|
||||
context 'if reblog?' do
|
||||
it 'returns :share' do
|
||||
subject.reblog = other
|
||||
expect(subject.verb).to be :share
|
||||
end
|
||||
end
|
||||
|
||||
context 'unless reblog?' do
|
||||
it 'returns :post' do
|
||||
subject.reblog = nil
|
||||
expect(subject.verb).to be :post
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#object_type' do
|
||||
it 'is note when the status is self-contained' do
|
||||
|
|
Loading…
Reference in New Issue