Merge remote-tracking branch 'origin/master' into gs-master
commit
b28b405b97
|
@ -104,7 +104,7 @@ class ApplicationController < ActionController::Base
|
||||||
unless uncached_ids.empty?
|
unless uncached_ids.empty?
|
||||||
uncached = klass.where(id: uncached_ids).with_includes.map { |item| [item.id, item] }.to_h
|
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)
|
Rails.cache.write(item.cache_key, item)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -62,7 +62,7 @@ class Auth::SessionsController < Devise::SessionsController
|
||||||
|
|
||||||
if user_params[:otp_attempt].present? && session[:otp_user_id]
|
if user_params[:otp_attempt].present? && session[:otp_user_id]
|
||||||
authenticate_with_two_factor_via_otp(user)
|
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)
|
prompt_for_two_factor(user)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,7 +18,7 @@ module Admin::FilterHelper
|
||||||
|
|
||||||
def selected?(more_params)
|
def selected?(more_params)
|
||||||
new_url = filtered_url_for(more_params)
|
new_url = filtered_url_for(more_params)
|
||||||
filter_link_class(new_url) == 'selected' ? true : false
|
filter_link_class(new_url) == 'selected'
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -571,7 +571,19 @@
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 12px;
|
line-height: 12px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
color: $success-green;
|
color: $ui-secondary-color;
|
||||||
background-color: rgba($success-green, 0.1);
|
background-color: rgba($ui-secondary-color, 0.1);
|
||||||
border: 1px solid rgba($success-green, 0.5);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,7 +173,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def language_from_content
|
def language_from_content
|
||||||
return nil unless language_map?
|
return LanguageDetector.instance.detect(text_from_content, @account) unless language_map?
|
||||||
@object['contentMap'].keys.first
|
@object['contentMap'].keys.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ module Extractor
|
||||||
|
|
||||||
module_function
|
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]
|
return [] unless text =~ Twitter::Regex[:at_signs]
|
||||||
|
|
||||||
possible_entries = []
|
possible_entries = []
|
||||||
|
|
|
@ -38,12 +38,31 @@ class LanguageDetector
|
||||||
end
|
end
|
||||||
|
|
||||||
def simplify_text(text)
|
def simplify_text(text)
|
||||||
text.dup.tap do |new_text|
|
new_text = remove_html(text)
|
||||||
new_text.gsub!(FetchLinkCardService::URL_PATTERN, '')
|
new_text.gsub!(FetchLinkCardService::URL_PATTERN, '')
|
||||||
new_text.gsub!(Account::MENTION_RE, '')
|
new_text.gsub!(Account::MENTION_RE, '')
|
||||||
new_text.gsub!(Tag::HASHTAG_RE, '')
|
new_text.gsub!(Tag::HASHTAG_RE, '')
|
||||||
new_text.gsub!(/\s+/, ' ')
|
new_text.gsub!(/:#{CustomEmoji::SHORTCODE_RE_FRAGMENT}:/, '')
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def default_locale(account)
|
def default_locale(account)
|
||||||
|
|
|
@ -117,6 +117,8 @@ class Account < ApplicationRecord
|
||||||
:current_sign_in_at,
|
:current_sign_in_at,
|
||||||
:confirmed?,
|
:confirmed?,
|
||||||
:admin?,
|
:admin?,
|
||||||
|
:moderator?,
|
||||||
|
:staff?,
|
||||||
:locale,
|
:locale,
|
||||||
to: :user,
|
to: :user,
|
||||||
prefix: true,
|
prefix: true,
|
||||||
|
|
|
@ -44,7 +44,7 @@ module AccountFinderConcern
|
||||||
end
|
end
|
||||||
|
|
||||||
def with_usernames
|
def with_usernames
|
||||||
Account.where.not(username: [nil, ''])
|
Account.where.not(username: '')
|
||||||
end
|
end
|
||||||
|
|
||||||
def matching_username
|
def matching_username
|
||||||
|
|
|
@ -24,12 +24,12 @@ class Web::PushSubscription < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def pushable?(notification)
|
def pushable?(notification)
|
||||||
data && data.key?('alerts') && data['alerts'][notification.type.to_s]
|
data&.key?('alerts') && data['alerts'][notification.type.to_s]
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_payload
|
def as_payload
|
||||||
payload = { id: id, endpoint: endpoint }
|
payload = { id: id, endpoint: endpoint }
|
||||||
payload[:alerts] = data['alerts'] if data && data.key?('alerts')
|
payload[:alerts] = data['alerts'] if data&.key?('alerts')
|
||||||
payload
|
payload
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class BatchedRemoveStatusService < BaseService
|
||||||
statuses.each(&:destroy)
|
statuses.each(&:destroy)
|
||||||
|
|
||||||
# Batch by source account
|
# 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
|
account = account_statuses.first.account
|
||||||
|
|
||||||
unpush_from_home_timelines(account, account_statuses)
|
unpush_from_home_timelines(account, account_statuses)
|
||||||
|
|
|
@ -124,11 +124,11 @@ class ResolveRemoteAccountService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def auto_suspend?
|
def auto_suspend?
|
||||||
domain_block && domain_block.suspend?
|
domain_block&.suspend?
|
||||||
end
|
end
|
||||||
|
|
||||||
def auto_silence?
|
def auto_silence?
|
||||||
domain_block && domain_block.silence?
|
domain_block&.silence?
|
||||||
end
|
end
|
||||||
|
|
||||||
def domain_block
|
def domain_block
|
||||||
|
|
|
@ -30,8 +30,12 @@
|
||||||
|
|
||||||
- if account.user_admin?
|
- if account.user_admin?
|
||||||
.roles
|
.roles
|
||||||
.account-role
|
.account-role.admin
|
||||||
= t 'accounts.roles.admin'
|
= t 'accounts.roles.admin'
|
||||||
|
- elsif account.user_moderator?
|
||||||
|
.roles
|
||||||
|
.account-role.moderator
|
||||||
|
= t 'accounts.roles.moderator'
|
||||||
.bio
|
.bio
|
||||||
.account__header__content.p-note.emojify!=processed_bio[:text]
|
.account__header__content.p-note.emojify!=processed_bio[:text]
|
||||||
- if processed_bio[:metadata].length > 0
|
- if processed_bio[:metadata].length > 0
|
||||||
|
|
|
@ -48,6 +48,7 @@ en:
|
||||||
reserved_username: The username is reserved
|
reserved_username: The username is reserved
|
||||||
roles:
|
roles:
|
||||||
admin: Admin
|
admin: Admin
|
||||||
|
moderator: Mod
|
||||||
unfollow: Unfollow
|
unfollow: Unfollow
|
||||||
admin:
|
admin:
|
||||||
account_moderation_notes:
|
account_moderation_notes:
|
||||||
|
|
|
@ -168,7 +168,13 @@ Rails.application.routes.draw do
|
||||||
resources :account_moderation_notes, only: [:create, :destroy]
|
resources :account_moderation_notes, only: [:create, :destroy]
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/admin', to: redirect('/admin/settings/edit', status: 302)
|
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
|
namespace :api do
|
||||||
# PubSubHubbub outgoing subscriptions
|
# PubSubHubbub outgoing subscriptions
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -47,8 +47,27 @@ RSpec.describe Status, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#verb' do
|
describe '#verb' do
|
||||||
it 'is always post' do
|
context 'if destroyed?' do
|
||||||
expect(subject.verb).to be :post
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue