From bfed7dd5f3127f08ece3070bd67f5737933bac1a Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 15 Jul 2020 21:07:53 +0200 Subject: Fix error when closing a playing audio or video modal (#14310) --- app/javascript/mastodon/features/audio/index.js | 2 ++ app/javascript/mastodon/features/video/index.js | 2 ++ 2 files changed, 4 insertions(+) (limited to 'app') diff --git a/app/javascript/mastodon/features/audio/index.js b/app/javascript/mastodon/features/audio/index.js index 2f85ebb7e..1ab1c3117 100644 --- a/app/javascript/mastodon/features/audio/index.js +++ b/app/javascript/mastodon/features/audio/index.js @@ -298,6 +298,8 @@ class Audio extends React.PureComponent { _renderCanvas () { requestAnimationFrame(() => { + if (!this.audio) return; + this.handleTimeUpdate(); this._clear(); this._draw(); diff --git a/app/javascript/mastodon/features/video/index.js b/app/javascript/mastodon/features/video/index.js index fb12567f0..99dcdca22 100644 --- a/app/javascript/mastodon/features/video/index.js +++ b/app/javascript/mastodon/features/video/index.js @@ -182,6 +182,8 @@ class Video extends React.PureComponent { _updateTime () { requestAnimationFrame(() => { + if (!this.video) return; + this.handleTimeUpdate(); if (!this.state.paused) { -- cgit From d658af7ff8893d332f1509082a9d919f70af99af Mon Sep 17 00:00:00 2001 From: ThibG Date: Wed, 15 Jul 2020 21:08:19 +0200 Subject: Fix removing allowed domains being done synchronously (#14302) * Fix removing allowed domains being done synchronously * Add tests --- app/services/after_unallow_domain_service.rb | 9 ++++ app/services/unallow_domain_service.rb | 5 +-- app/workers/after_unallow_domain_worker.rb | 9 ++++ spec/services/unallow_domain_service_spec.rb | 64 ++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 app/services/after_unallow_domain_service.rb create mode 100644 app/workers/after_unallow_domain_worker.rb create mode 100644 spec/services/unallow_domain_service_spec.rb (limited to 'app') diff --git a/app/services/after_unallow_domain_service.rb b/app/services/after_unallow_domain_service.rb new file mode 100644 index 000000000..ccd0b8ae9 --- /dev/null +++ b/app/services/after_unallow_domain_service.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AfterUnallowDomainService < BaseService + def call(domain) + Account.where(domain: domain).find_each do |account| + SuspendAccountService.new.call(account, reserve_username: false) + end + end +end diff --git a/app/services/unallow_domain_service.rb b/app/services/unallow_domain_service.rb index 870c79951..fc5260761 100644 --- a/app/services/unallow_domain_service.rb +++ b/app/services/unallow_domain_service.rb @@ -12,8 +12,7 @@ class UnallowDomainService < BaseService private def suspend_accounts!(domain) - Account.where(domain: domain).find_each do |account| - SuspendAccountService.new.call(account, reserve_username: false) - end + Account.where(domain: domain).in_batches.update_all(suspended_at: Time.now.utc) + AfterUnallowDomainWorker.perform_async(domain) end end diff --git a/app/workers/after_unallow_domain_worker.rb b/app/workers/after_unallow_domain_worker.rb new file mode 100644 index 000000000..46049cbb2 --- /dev/null +++ b/app/workers/after_unallow_domain_worker.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class AfterUnallowDomainWorker + include Sidekiq::Worker + + def perform(domain) + AfterUnallowDomainService.new.call(domain) + end +end diff --git a/spec/services/unallow_domain_service_spec.rb b/spec/services/unallow_domain_service_spec.rb new file mode 100644 index 000000000..559e152fb --- /dev/null +++ b/spec/services/unallow_domain_service_spec.rb @@ -0,0 +1,64 @@ +require 'rails_helper' + +RSpec.describe UnallowDomainService, type: :service do + let!(:bad_account) { Fabricate(:account, username: 'badguy666', domain: 'evil.org') } + let!(:bad_status1) { Fabricate(:status, account: bad_account, text: 'You suck') } + let!(:bad_status2) { Fabricate(:status, account: bad_account, text: 'Hahaha') } + let!(:bad_attachment) { Fabricate(:media_attachment, account: bad_account, status: bad_status2, file: attachment_fixture('attachment.jpg')) } + let!(:already_banned_account) { Fabricate(:account, username: 'badguy', domain: 'evil.org', suspended: true, silenced: true) } + let!(:domain_allow) { Fabricate(:domain_allow, domain: 'evil.org') } + + subject { UnallowDomainService.new } + + context 'in limited federation mode' do + before do + allow(subject).to receive(:whitelist_mode?).and_return(true) + end + + describe '#call' do + before do + subject.call(domain_allow) + end + + it 'removes the allowed domain' do + expect(DomainAllow.allowed?('evil.org')).to be false + end + + it 'removes remote accounts from that domain' do + expect(Account.where(domain: 'evil.org').exists?).to be false + end + + it 'removes the remote accounts\'s statuses and media attachments' do + expect { bad_status1.reload }.to raise_exception ActiveRecord::RecordNotFound + expect { bad_status2.reload }.to raise_exception ActiveRecord::RecordNotFound + expect { bad_attachment.reload }.to raise_exception ActiveRecord::RecordNotFound + end + end + end + + context 'without limited federation mode' do + before do + allow(subject).to receive(:whitelist_mode?).and_return(false) + end + + describe '#call' do + before do + subject.call(domain_allow) + end + + it 'removes the allowed domain' do + expect(DomainAllow.allowed?('evil.org')).to be false + end + + it 'does not remove accounts from that domain' do + expect(Account.where(domain: 'evil.org').exists?).to be true + end + + it 'removes the remote accounts\'s statuses and media attachments' do + expect { bad_status1.reload }.to_not raise_exception ActiveRecord::RecordNotFound + expect { bad_status2.reload }.to_not raise_exception ActiveRecord::RecordNotFound + expect { bad_attachment.reload }.to_not raise_exception ActiveRecord::RecordNotFound + end + end + end +end -- cgit From 71e85a506d540d77d0795dfba0a66a55f2a1d3d9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 15 Jul 2020 21:11:21 +0200 Subject: New Crowdin updates (#14311) * New translations en.json (Vietnamese) [ci skip] * New translations en.yml (Vietnamese) [ci skip] * New translations en.yml (Vietnamese) [ci skip] * New translations en.yml (Vietnamese) [ci skip] * New translations en.yml (Vietnamese) [ci skip] * i18n-tasks normalize --- app/javascript/mastodon/locales/vi.json | 4 ++-- config/locales/vi.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/locales/vi.json b/app/javascript/mastodon/locales/vi.json index 7d4c1c45e..17c4302c2 100644 --- a/app/javascript/mastodon/locales/vi.json +++ b/app/javascript/mastodon/locales/vi.json @@ -23,7 +23,7 @@ "account.last_status": "Hoạt động gần đây", "account.link_verified_on": "Liên kết này đã được xác thực vào {date}", "account.locked_info": "Người dùng này thiết lập trạng thái ẩn. Họ sẽ tự mình xét duyệt các yêu cầu theo dõi.", - "account.media": "Đa phương tiện", + "account.media": "Bộ sưu tập", "account.mention": "Nhắc đến @{name}", "account.moved_to": "{name} đã dời sang:", "account.mute": "Ẩn @{name}", @@ -43,7 +43,7 @@ "account.unfollow": "Ngưng theo dõi", "account.unmute": "Bỏ ẩn @{name}", "account.unmute_notifications": "Hiển lại thông báo từ @{name}", - "account_note.placeholder": "Không nói gì thêm", + "account_note.placeholder": "Nhấn để thêm ghi chú", "alert.rate_limited.message": "Vui lòng thử lại sau {retry_time, time, medium}.", "alert.rate_limited.title": "Vượt giới hạn", "alert.unexpected.message": "Đã xảy ra lỗi không mong muốn.", diff --git a/config/locales/vi.yml b/config/locales/vi.yml index d952f05c9..7acd38ff5 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -60,7 +60,7 @@ vi: joined: Đã tham gia %{date} last_active: hoạt động gần đây link_verified_on: Liên kết này đã được xác thực quyền sở hữu vào %{date} - media: Đa phương tiện + media: Bộ sưu tập moved_html: "%{name} đã dời sang %{new_profile_link}:" network_hidden: Thông tin này không còn tồn tại never_active: Chưa có @@ -587,7 +587,7 @@ vi: deleted: Đã xóa failed_to_execute: Không thể thực thi media: - title: Đa phương tiện + title: Bộ sưu tập no_media: Không có ảnh hoặc video no_status_selected: Không có tút nào thay đổi vì không có tút nào được chọn title: Trạng thái tài khoản @@ -723,7 +723,7 @@ vi: invalid_signature: không phải là chữ ký số Ed25519 đúng date: formats: - default: "%d.%m.%Y" + default: "%b.%-m.%Y" datetime: distance_in_words: about_x_hours: "%{count}h" @@ -1161,7 +1161,7 @@ vi: mastodon-light: Mastodon (Sáng) time: formats: - default: "%b %d, %Y, %H:%M" + default: lúc %H:%M %b %d năm%_Y month: "%B %Y" two_factor_authentication: code_hint: Nhập mã được tạo bởi ứng dụng xác thực của bạn để xác nhận -- cgit