From 9ef5532a7ece064ee76bb345abef03bbd6b64418 Mon Sep 17 00:00:00 2001 From: abcang Date: Tue, 1 Oct 2019 00:02:03 +0900 Subject: Fix follow requests N+1 (#12004) --- app/services/update_account_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/services/update_account_service.rb b/app/services/update_account_service.rb index ebf24be37..4172d5774 100644 --- a/app/services/update_account_service.rb +++ b/app/services/update_account_service.rb @@ -21,7 +21,7 @@ class UpdateAccountService < BaseService def authorize_all_follow_requests(account) follow_requests = FollowRequest.where(target_account: account) - follow_requests = follow_requests.select { |req| !req.account.silenced? } + follow_requests = follow_requests.preload(:account).select { |req| !req.account.silenced? } AuthorizeFollowWorker.push_bulk(follow_requests) do |req| [req.account_id, req.target_account_id] end -- cgit From 12c4ec0c83fc5d43a29b3333ab07510c87844166 Mon Sep 17 00:00:00 2001 From: Cutls Date: Tue, 1 Oct 2019 00:12:33 +0900 Subject: Fix and remove ugly css around the conversation component (#12022) --- app/javascript/styles/mastodon/components.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 64d40f824..f5dbe3f5c 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -6473,8 +6473,8 @@ noscript { overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; - flex-basis: 170px; - flex-shrink: 1000; + flex-basis: 90px; + flex-grow: 1; a { color: $primary-text-color; -- cgit From 5c42f47617d311219d06e082e4daa41e671903c8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 01:19:11 +0200 Subject: Fix records not being indexed sometimes (#12024) It's possible that after commit callbacks were not firing when exceptions occurred in the process. Also, the default Sidekiq strategy does not push indexing jobs immediately, which is not necessary and could be part of the issue too. --- app/models/account.rb | 2 +- app/models/account_stat.rb | 2 +- app/models/application_record.rb | 6 ++++++ app/models/favourite.rb | 2 +- app/models/status.rb | 2 +- app/models/tag.rb | 2 +- config/application.rb | 1 + config/initializers/chewy.rb | 5 +++-- lib/chewy/strategy/custom_sidekiq.rb | 30 ++++++++++++++++++++++++++++++ spec/rails_helper.rb | 2 +- 10 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 lib/chewy/strategy/custom_sidekiq.rb (limited to 'app') diff --git a/app/models/account.rb b/app/models/account.rb index 55fe53fae..01d45e36c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -129,7 +129,7 @@ class Account < ApplicationRecord delegate :chosen_languages, to: :user, prefix: false, allow_nil: true - update_index('accounts#account', :self) if Chewy.enabled? + update_index('accounts#account', :self) def local? domain.nil? diff --git a/app/models/account_stat.rb b/app/models/account_stat.rb index 6d1097cec..1351f7d8a 100644 --- a/app/models/account_stat.rb +++ b/app/models/account_stat.rb @@ -16,7 +16,7 @@ class AccountStat < ApplicationRecord belongs_to :account, inverse_of: :account_stat - update_index('accounts#account', :account) if Chewy.enabled? + update_index('accounts#account', :account) def increment_count!(key) update(attributes_for_increment(key)) diff --git a/app/models/application_record.rb b/app/models/application_record.rb index c1b873da6..5d7d3a096 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -5,6 +5,12 @@ class ApplicationRecord < ActiveRecord::Base include Remotable + class << self + def update_index(_type_name, *_args, &_block) + super if Chewy.enabled? + end + end + def boolean_with_default(key, default_value) value = attributes[key] diff --git a/app/models/favourite.rb b/app/models/favourite.rb index 17f8c9fa6..bf0ec4449 100644 --- a/app/models/favourite.rb +++ b/app/models/favourite.rb @@ -13,7 +13,7 @@ class Favourite < ApplicationRecord include Paginable - update_index('statuses#status', :status) if Chewy.enabled? + update_index('statuses#status', :status) belongs_to :account, inverse_of: :favourites belongs_to :status, inverse_of: :favourites diff --git a/app/models/status.rb b/app/models/status.rb index 5e7474577..078a64566 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -39,7 +39,7 @@ class Status < ApplicationRecord # will be based on current time instead of `created_at` attr_accessor :override_timestamps - update_index('statuses#status', :proper) if Chewy.enabled? + update_index('statuses#status', :proper) enum visibility: [:public, :unlisted, :private, :direct, :limited], _suffix: :visibility diff --git a/app/models/tag.rb b/app/models/tag.rb index 9aca3983f..82786daa8 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -49,7 +49,7 @@ class Tag < ApplicationRecord after_save :save_account_tag_stat - update_index('tags#tag', :self) if Chewy.enabled? + update_index('tags#tag', :self) def account_tag_stat super || build_account_tag_stat diff --git a/config/application.rb b/config/application.rb index 3ced81b8f..60f73f8bb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -15,6 +15,7 @@ require_relative '../lib/mastodon/snowflake' require_relative '../lib/mastodon/version' require_relative '../lib/devise/two_factor_ldap_authenticatable' require_relative '../lib/devise/two_factor_pam_authenticatable' +require_relative '../lib/chewy/strategy/custom_sidekiq' Dotenv::Railtie.load diff --git a/config/initializers/chewy.rb b/config/initializers/chewy.rb index d5347f2bf..9ff0dccc1 100644 --- a/config/initializers/chewy.rb +++ b/config/initializers/chewy.rb @@ -12,8 +12,9 @@ Chewy.settings = { sidekiq: { queue: 'pull' }, } -Chewy.root_strategy = enabled ? :sidekiq : :bypass -Chewy.request_strategy = enabled ? :sidekiq : :bypass +Chewy.root_strategy = :custom_sidekiq +Chewy.request_strategy = :custom_sidekiq +Chewy.use_after_commit_callbacks = false module Chewy class << self diff --git a/lib/chewy/strategy/custom_sidekiq.rb b/lib/chewy/strategy/custom_sidekiq.rb new file mode 100644 index 000000000..3e54326ba --- /dev/null +++ b/lib/chewy/strategy/custom_sidekiq.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Chewy + class Strategy + class CustomSidekiq < Base + class Worker + include ::Sidekiq::Worker + + sidekiq_options queue: 'pull' + + def perform(type, ids, options = {}) + options[:refresh] = !Chewy.disable_refresh_async if Chewy.disable_refresh_async + type.constantize.import!(ids, options) + end + end + + def update(type, objects, _options = {}) + return unless Chewy.enabled? + + ids = type.root.id ? Array.wrap(objects) : type.adapter.identify(objects) + + return if ids.empty? + + Worker.perform_async(type.name, ids) + end + + def leave; end + end + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 3a5e7491e..6fbceca53 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -12,7 +12,7 @@ require 'capybara/rspec' Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } ActiveRecord::Migration.maintain_test_schema! -WebMock.disable_net_connect! +WebMock.disable_net_connect!(allow: Chewy.settings[:host]) Redis.current = Redis::Namespace.new("mastodon_test#{ENV['TEST_ENV_NUMBER']}", redis: Redis.current) Sidekiq::Testing.inline! Sidekiq::Logging.logger = nil -- cgit From e682d3aa9e9c9219aa06f7ad5a4f1412b5ea2b4a Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 01:19:24 +0200 Subject: Fix active user count for different number of weeks using same cache (#12025) Fix #12003 --- app/presenters/instance_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/presenters/instance_presenter.rb b/app/presenters/instance_presenter.rb index c4caeaa8c..c150bf742 100644 --- a/app/presenters/instance_presenter.rb +++ b/app/presenters/instance_presenter.rb @@ -21,7 +21,7 @@ class InstancePresenter end def active_user_count(weeks = 4) - Rails.cache.fetch('active_user_count') { Redis.current.pfcount(*(0...weeks).map { |i| "activity:logins:#{i.weeks.ago.utc.to_date.cweek}" }) } + Rails.cache.fetch("active_user_count/#{weeks}") { Redis.current.pfcount(*(0...weeks).map { |i| "activity:logins:#{i.weeks.ago.utc.to_date.cweek}" }) } end def status_count -- cgit From b258583d2becfb1d1b434a2368fac627069bed0b Mon Sep 17 00:00:00 2001 From: mayaeh Date: Tue, 1 Oct 2019 08:20:22 +0900 Subject: Fix hashtag link to directory in AdminUI (#12005) * Fixed not to generate link if no user used hashtag in directory * Added missing translation for AdminUI custom emojis * run yarn manage:translations en --- .../mastodon/locales/defaultMessages.json | 104 +++++++-------------- app/javascript/mastodon/locales/en.json | 5 +- app/views/admin/tags/show.html.haml | 11 ++- config/locales/en.yml | 1 + 4 files changed, 43 insertions(+), 78 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/locales/defaultMessages.json b/app/javascript/mastodon/locales/defaultMessages.json index e2caf18d3..79ead58ec 100644 --- a/app/javascript/mastodon/locales/defaultMessages.json +++ b/app/javascript/mastodon/locales/defaultMessages.json @@ -238,6 +238,14 @@ "description": "Tooltip of the \"voted\" checkmark in polls", "id": "poll.voted" }, + { + "defaultMessage": "{count, plural, one {# person} other {# people}}", + "id": "poll.total_people" + }, + { + "defaultMessage": "{count, plural, one {# vote} other {# votes}}", + "id": "poll.total_votes" + }, { "defaultMessage": "Vote", "id": "poll.vote" @@ -245,10 +253,6 @@ { "defaultMessage": "Refresh", "id": "poll.refresh" - }, - { - "defaultMessage": "{count, plural, one {# vote} other {# votes}}", - "id": "poll.total_votes" } ], "path": "app/javascript/mastodon/components/poll.json" @@ -498,10 +502,6 @@ "defaultMessage": "Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.", "id": "confirmations.redraft.message" }, - { - "defaultMessage": "Block", - "id": "confirmations.block.confirm" - }, { "defaultMessage": "Reply", "id": "confirmations.reply.confirm" @@ -509,14 +509,6 @@ { "defaultMessage": "Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?", "id": "confirmations.reply.message" - }, - { - "defaultMessage": "Block & Report", - "id": "confirmations.block.block_and_report" - }, - { - "defaultMessage": "Are you sure you want to block {name}?", - "id": "confirmations.block.message" } ], "path": "app/javascript/mastodon/containers/status_container.json" @@ -553,26 +545,14 @@ "defaultMessage": "Unfollow", "id": "confirmations.unfollow.confirm" }, - { - "defaultMessage": "Block", - "id": "confirmations.block.confirm" - }, { "defaultMessage": "Hide entire domain", "id": "confirmations.domain_block.confirm" }, - { - "defaultMessage": "Block & Report", - "id": "confirmations.block.block_and_report" - }, { "defaultMessage": "Are you sure you want to unfollow {name}?", "id": "confirmations.unfollow.message" }, - { - "defaultMessage": "Are you sure you want to block {name}?", - "id": "confirmations.block.message" - }, { "defaultMessage": "Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.", "id": "confirmations.domain_block.message" @@ -1134,15 +1114,6 @@ ], "path": "app/javascript/mastodon/features/compose/components/upload_form.json" }, - { - "descriptors": [ - { - "defaultMessage": "Uploading...", - "id": "upload_progress.label" - } - ], - "path": "app/javascript/mastodon/features/compose/components/upload_progress.json" - }, { "descriptors": [ { @@ -1635,6 +1606,10 @@ }, { "descriptors": [ + { + "defaultMessage": "Basic", + "id": "home.column_settings.basic" + }, { "defaultMessage": "Show boosts", "id": "home.column_settings.show_reblogs" @@ -2016,14 +1991,6 @@ "defaultMessage": "Push notifications", "id": "notifications.column_settings.push" }, - { - "defaultMessage": "Basic", - "id": "home.column_settings.basic" - }, - { - "defaultMessage": "Update in real-time", - "id": "home.column_settings.update_live" - }, { "defaultMessage": "Quick filter bar", "id": "notifications.column_settings.filter_bar.category" @@ -2082,10 +2049,6 @@ }, { "descriptors": [ - { - "defaultMessage": "and {count, plural, one {# other} other {# others}}", - "id": "notification.and_n_others" - }, { "defaultMessage": "{name} followed you", "id": "notification.follow" @@ -2273,10 +2236,6 @@ "defaultMessage": "Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.", "id": "confirmations.redraft.message" }, - { - "defaultMessage": "Block", - "id": "confirmations.block.confirm" - }, { "defaultMessage": "Reply", "id": "confirmations.reply.confirm" @@ -2284,14 +2243,6 @@ { "defaultMessage": "Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?", "id": "confirmations.reply.message" - }, - { - "defaultMessage": "Block & Report", - "id": "confirmations.block.block_and_report" - }, - { - "defaultMessage": "Are you sure you want to block {name}?", - "id": "confirmations.block.message" } ], "path": "app/javascript/mastodon/features/status/containers/detailed_status_container.json" @@ -2314,10 +2265,6 @@ "defaultMessage": "Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.", "id": "confirmations.redraft.message" }, - { - "defaultMessage": "Block", - "id": "confirmations.block.confirm" - }, { "defaultMessage": "Show more for all", "id": "status.show_more_all" @@ -2337,21 +2284,30 @@ { "defaultMessage": "Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?", "id": "confirmations.reply.message" + } + ], + "path": "app/javascript/mastodon/features/status/index.json" + }, + { + "descriptors": [ + { + "defaultMessage": "Are you sure you want to block {name}?", + "id": "confirmations.block.message" }, { - "defaultMessage": "Block & Report", - "id": "confirmations.block.block_and_report" + "defaultMessage": "Cancel", + "id": "confirmation_modal.cancel" }, { - "defaultMessage": "Toot", - "id": "column.status" + "defaultMessage": "Block & Report", + "id": "confirmations.block.block_and_report" }, { - "defaultMessage": "Are you sure you want to block {name}?", - "id": "confirmations.block.message" + "defaultMessage": "Block", + "id": "confirmations.block.confirm" } ], - "path": "app/javascript/mastodon/features/status/index.json" + "path": "app/javascript/mastodon/features/ui/components/block_modal.json" }, { "descriptors": [ @@ -2569,6 +2525,10 @@ "defaultMessage": "Are you sure you want to mute {name}?", "id": "confirmations.mute.message" }, + { + "defaultMessage": "This will hide posts from them and posts mentioning them, but it will still allow them to see your posts follow you.", + "id": "confirmations.mute.explanation" + }, { "defaultMessage": "Hide notifications from this user?", "id": "mute_modal.hide_notifications" diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json index 82b2a9440..fc769a18f 100644 --- a/app/javascript/mastodon/locales/en.json +++ b/app/javascript/mastodon/locales/en.json @@ -63,7 +63,6 @@ "column.notifications": "Notifications", "column.pins": "Pinned toots", "column.public": "Federated timeline", - "column.status": "Toot", "column_back_button.label": "Back", "column_header.hide_settings": "Hide settings", "column_header.moveLeft_settings": "Move column to the left", @@ -104,6 +103,7 @@ "confirmations.logout.confirm": "Log out", "confirmations.logout.message": "Are you sure you want to log out?", "confirmations.mute.confirm": "Mute", + "confirmations.mute.explanation": "This will hide posts from them and posts mentioning them, but it will still allow them to see your posts follow you.", "confirmations.mute.message": "Are you sure you want to mute {name}?", "confirmations.redraft.confirm": "Delete & redraft", "confirmations.redraft.message": "Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.", @@ -174,7 +174,6 @@ "home.column_settings.basic": "Basic", "home.column_settings.show_reblogs": "Show boosts", "home.column_settings.show_replies": "Show replies", - "home.column_settings.update_live": "Update in real-time", "intervals.full.days": "{number, plural, one {# day} other {# days}}", "intervals.full.hours": "{number, plural, one {# hour} other {# hours}}", "intervals.full.minutes": "{number, plural, one {# minute} other {# minutes}}", @@ -268,7 +267,6 @@ "navigation_bar.preferences": "Preferences", "navigation_bar.public_timeline": "Federated timeline", "navigation_bar.security": "Security", - "notification.and_n_others": "and {count, plural, one {# other} other {# others}}", "notification.favourite": "{name} favourited your status", "notification.follow": "{name} followed you", "notification.mention": "{name} mentioned you", @@ -297,6 +295,7 @@ "notifications.group": "{count} notifications", "poll.closed": "Closed", "poll.refresh": "Refresh", + "poll.total_people": "{count, plural, one {# person} other {# people}}", "poll.total_votes": "{count, plural, one {# vote} other {# votes}}", "poll.vote": "Vote", "poll.voted": "You voted for this answer", diff --git a/app/views/admin/tags/show.html.haml b/app/views/admin/tags/show.html.haml index 1d970d637..5799e5973 100644 --- a/app/views/admin/tags/show.html.haml +++ b/app/views/admin/tags/show.html.haml @@ -11,9 +11,14 @@ .dashboard__counters__num= number_with_delimiter @accounts_week .dashboard__counters__label= t 'admin.tags.accounts_week' %div - = link_to explore_hashtag_path(@tag) do - .dashboard__counters__num= number_with_delimiter @tag.accounts_count - .dashboard__counters__label= t 'admin.tags.directory' + - if @tag.accounts_count > 0 + = link_to explore_hashtag_path(@tag) do + .dashboard__counters__num= number_with_delimiter @tag.accounts_count + .dashboard__counters__label= t 'admin.tags.directory' + - else + %div + .dashboard__counters__num= number_with_delimiter @tag.accounts_count + .dashboard__counters__label= t 'admin.tags.directory' %hr.spacer/ diff --git a/config/locales/en.yml b/config/locales/en.yml index 82e20cb1f..51b0f51d5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -240,6 +240,7 @@ en: delete: Delete destroyed_msg: Emojo successfully destroyed! disable: Disable + disabled: Disabled disabled_msg: Successfully disabled that emoji emoji: Emoji enable: Enable -- cgit From 9ba40a6bfdb65f6e48eb7de07b2d55314c54fa83 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 04:54:10 +0200 Subject: Remove HEAD request from fetching link previews (#12028) It is not really necessary and we need to reduce requests --- app/services/fetch_link_card_service.rb | 6 ------ spec/services/fetch_link_card_service_spec.rb | 13 +++---------- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'app') diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index ac5503d46..f0b1169db 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -39,12 +39,6 @@ class FetchLinkCardService < BaseService def process_url @card ||= PreviewCard.new(url: @url) - failed = Request.new(:head, @url).perform do |res| - res.code != 405 && res.code != 501 && (res.code != 200 || res.mime_type != 'text/html') - end - - return if failed - Request.new(:get, @url).perform do |res| if res.code == 200 && res.mime_type == 'text/html' @html = res.body_with_limit diff --git a/spec/services/fetch_link_card_service_spec.rb b/spec/services/fetch_link_card_service_spec.rb index 50c60aafd..9761c5f06 100644 --- a/spec/services/fetch_link_card_service_spec.rb +++ b/spec/services/fetch_link_card_service_spec.rb @@ -4,20 +4,13 @@ RSpec.describe FetchLinkCardService, type: :service do subject { FetchLinkCardService.new } before do - stub_request(:head, 'http://example.xn--fiqs8s/').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.xn--fiqs8s/').to_return(request_fixture('idn.txt')) - stub_request(:head, 'http://example.com/sjis').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/sjis').to_return(request_fixture('sjis.txt')) - stub_request(:head, 'http://example.com/sjis_with_wrong_charset').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/sjis_with_wrong_charset').to_return(request_fixture('sjis_with_wrong_charset.txt')) - stub_request(:head, 'http://example.com/koi8-r').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/koi8-r').to_return(request_fixture('koi8-r.txt')) - stub_request(:head, 'http://example.com/日本語').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/日本語').to_return(request_fixture('sjis.txt')) - stub_request(:head, 'https://github.com/qbi/WannaCry').to_return(status: 404) - stub_request(:head, 'http://example.com/test-').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) + stub_request(:get, 'https://github.com/qbi/WannaCry').to_return(status: 404) stub_request(:get, 'http://example.com/test-').to_return(request_fixture('idn.txt')) - stub_request(:head, 'http://example.com/windows-1251').to_return(status: 200, headers: { 'Content-Type' => 'text/html' }) stub_request(:get, 'http://example.com/windows-1251').to_return(request_fixture('windows-1251.txt')) subject.call(status) @@ -90,11 +83,11 @@ RSpec.describe FetchLinkCardService, type: :service do let(:status) { Fabricate(:status, account: Fabricate(:account, domain: 'example.com'), text: 'Habt ihr ein paar gute Links zu #Wannacry herumfliegen? Ich will mal unter
https://github.com/qbi/WannaCry was sammeln. !security ') } it 'parses out URLs' do - expect(a_request(:head, 'https://github.com/qbi/WannaCry')).to have_been_made.at_least_once + expect(a_request(:get, 'https://github.com/qbi/WannaCry')).to have_been_made.at_least_once end it 'ignores URLs to hashtags' do - expect(a_request(:head, 'https://quitter.se/tag/wannacry')).to_not have_been_made + expect(a_request(:get, 'https://quitter.se/tag/wannacry')).to_not have_been_made end end end -- cgit From 6faa98aee2af77466793d14a403600cc6104ba84 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 04:54:17 +0200 Subject: Fix delete conversation action not being reflected in web UI (#12030) --- app/javascript/mastodon/reducers/conversations.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/javascript/mastodon/reducers/conversations.js b/app/javascript/mastodon/reducers/conversations.js index 390658239..975418eda 100644 --- a/app/javascript/mastodon/reducers/conversations.js +++ b/app/javascript/mastodon/reducers/conversations.js @@ -7,6 +7,7 @@ import { CONVERSATIONS_FETCH_FAIL, CONVERSATIONS_UPDATE, CONVERSATIONS_READ, + CONVERSATIONS_DELETE_SUCCESS, } from '../actions/conversations'; import { ACCOUNT_BLOCK_SUCCESS, ACCOUNT_MUTE_SUCCESS } from 'mastodon/actions/accounts'; import { DOMAIN_BLOCK_SUCCESS } from 'mastodon/actions/domain_blocks'; @@ -107,6 +108,8 @@ export default function conversations(state = initialState, action) { return filterConversations(state, [action.relationship.id]); case DOMAIN_BLOCK_SUCCESS: return filterConversations(state, action.accounts); + case CONVERSATIONS_DELETE_SUCCESS: + return state.update('items', list => list.filterNot(item => item.get('id') === action.id)); default: return state; } -- cgit From c35376132b6675c21c2c85dd2456cf0779e89ad9 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 04:54:29 +0200 Subject: Fix long domain block descriptions breaking table layout (#12029) --- app/javascript/styles/mastodon/about.scss | 21 ++++++++++++++++----- app/views/about/_domain_blocks.html.haml | 6 ++++-- 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/about.scss b/app/javascript/styles/mastodon/about.scss index 1dd8b7954..cf16b54ac 100644 --- a/app/javascript/styles/mastodon/about.scss +++ b/app/javascript/styles/mastodon/about.scss @@ -145,8 +145,6 @@ $small-breakpoint: 960px; thead tr, tbody tr { - break-after: auto; - break-inside: avoid; border-bottom: 1px solid lighten($ui-base-color, 4%); font-size: 1em; line-height: 1.625; @@ -167,12 +165,25 @@ $small-breakpoint: 960px; padding: 8px; align-self: start; align-items: start; + word-break: break-all; &.nowrap { - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; width: 25%; + position: relative; + + &::before { + content: ' '; + visibility: hidden; + } + + span { + position: absolute; + left: 8px; + right: 8px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } } } } diff --git a/app/views/about/_domain_blocks.html.haml b/app/views/about/_domain_blocks.html.haml index 940bcb934..e0c5df41d 100644 --- a/app/views/about/_domain_blocks.html.haml +++ b/app/views/about/_domain_blocks.html.haml @@ -6,5 +6,7 @@ %tbody - domain_blocks.each do |domain_block| %tr - %td.nowrap= domain_block.domain - %td= domain_block.public_comment if display_blocks_rationale? + %td.nowrap + %span{ title: domain_block.domain }= domain_block.domain + %td + = domain_block.public_comment if display_blocks_rationale? -- cgit From b0323d0888fcb4aa9f85a67422961a85b8ab6069 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Oct 2019 04:57:27 +0200 Subject: Add refresh button to list of rebloggers/favouriters in web UI (#12031) --- .../mastodon/features/favourites/index.js | 27 ++++++++++++++++++---- app/javascript/mastodon/features/reblogs/index.js | 27 ++++++++++++++++++---- 2 files changed, 44 insertions(+), 10 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/favourites/index.js b/app/javascript/mastodon/features/favourites/index.js index 90c26f0c3..249e6a044 100644 --- a/app/javascript/mastodon/features/favourites/index.js +++ b/app/javascript/mastodon/features/favourites/index.js @@ -5,17 +5,23 @@ import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import LoadingIndicator from '../../components/loading_indicator'; import { fetchFavourites } from '../../actions/interactions'; -import { FormattedMessage } from 'react-intl'; +import { defineMessages, injectIntl, FormattedMessage } from 'react-intl'; import AccountContainer from '../../containers/account_container'; import Column from '../ui/components/column'; -import ColumnBackButton from '../../components/column_back_button'; import ScrollableList from '../../components/scrollable_list'; +import Icon from 'mastodon/components/icon'; +import ColumnHeader from '../../components/column_header'; + +const messages = defineMessages({ + refresh: { id: 'refresh', defaultMessage: 'Refresh' }, +}); const mapStateToProps = (state, props) => ({ accountIds: state.getIn(['user_lists', 'favourited_by', props.params.statusId]), }); export default @connect(mapStateToProps) +@injectIntl class Favourites extends ImmutablePureComponent { static propTypes = { @@ -24,6 +30,7 @@ class Favourites extends ImmutablePureComponent { shouldUpdateScroll: PropTypes.func, accountIds: ImmutablePropTypes.list, multiColumn: PropTypes.bool, + intl: PropTypes.object.isRequired, }; componentWillMount () { @@ -38,8 +45,12 @@ class Favourites extends ImmutablePureComponent { } } + handleRefresh = () => { + this.props.dispatch(fetchFavourites(this.props.params.statusId)); + } + render () { - const { shouldUpdateScroll, accountIds, multiColumn } = this.props; + const { intl, shouldUpdateScroll, accountIds, multiColumn } = this.props; if (!accountIds) { return ( @@ -52,8 +63,14 @@ class Favourites extends ImmutablePureComponent { const emptyMessage = ; return ( - - + + + )} + /> ({ accountIds: state.getIn(['user_lists', 'reblogged_by', props.params.statusId]), }); export default @connect(mapStateToProps) +@injectIntl class Reblogs extends ImmutablePureComponent { static propTypes = { @@ -24,6 +30,7 @@ class Reblogs extends ImmutablePureComponent { shouldUpdateScroll: PropTypes.func, accountIds: ImmutablePropTypes.list, multiColumn: PropTypes.bool, + intl: PropTypes.object.isRequired, }; componentWillMount () { @@ -38,8 +45,12 @@ class Reblogs extends ImmutablePureComponent { } } + handleRefresh = () => { + this.props.dispatch(fetchReblogs(this.props.params.statusId)); + } + render () { - const { shouldUpdateScroll, accountIds, multiColumn } = this.props; + const { intl, shouldUpdateScroll, accountIds, multiColumn } = this.props; if (!accountIds) { return ( @@ -52,8 +63,14 @@ class Reblogs extends ImmutablePureComponent { const emptyMessage = ; return ( - - + + + )} + /> Date: Tue, 1 Oct 2019 15:07:58 +0200 Subject: Fix missing propType for conversation delete (#12035) --- .../mastodon/features/direct_timeline/components/conversation.js | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/javascript/mastodon/features/direct_timeline/components/conversation.js b/app/javascript/mastodon/features/direct_timeline/components/conversation.js index cc3faf0de..db9381f33 100644 --- a/app/javascript/mastodon/features/direct_timeline/components/conversation.js +++ b/app/javascript/mastodon/features/direct_timeline/components/conversation.js @@ -37,6 +37,7 @@ class Conversation extends ImmutablePureComponent { onMoveUp: PropTypes.func, onMoveDown: PropTypes.func, markRead: PropTypes.func.isRequired, + delete: PropTypes.func.isRequired, intl: PropTypes.object.isRequired, }; -- cgit From 3a4d994c40962a9abe45565a34e3d7a3ca1ccd49 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Oct 2019 15:10:00 +0200 Subject: Fix BootstrapTimelineService crashing when bootstrapped accounts are invalid (#12037) * Add test to handle suspended and missing users in BootstrapTimelineService * Fix BootstrapTimelineService crashing when bootstrapped accounts are invalid --- app/services/bootstrap_timeline_service.rb | 8 +++++++- spec/services/bootstrap_timeline_service_spec.rb | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/services/bootstrap_timeline_service.rb b/app/services/bootstrap_timeline_service.rb index db2c83e5d..c489601c1 100644 --- a/app/services/bootstrap_timeline_service.rb +++ b/app/services/bootstrap_timeline_service.rb @@ -17,7 +17,11 @@ class BootstrapTimelineService < BaseService def autofollow_bootstrap_timeline_accounts! bootstrap_timeline_accounts.each do |target_account| - FollowService.new.call(@source_account, target_account) + begin + FollowService.new.call(@source_account, target_account) + rescue ActiveRecord::RecordNotFound, Mastodon::NotPermittedError + nil + end end end @@ -40,7 +44,9 @@ class BootstrapTimelineService < BaseService def local_unlocked_accounts(usernames) Account.local + .without_suspended .where(username: usernames) .where(locked: false) + .where(moved_to_account_id: nil) end end diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb index a765de791..a28d2407c 100644 --- a/spec/services/bootstrap_timeline_service_spec.rb +++ b/spec/services/bootstrap_timeline_service_spec.rb @@ -22,9 +22,10 @@ RSpec.describe BootstrapTimelineService, type: :service do context 'when setting is set' do let!(:alice) { Fabricate(:account, username: 'alice') } let!(:bob) { Fabricate(:account, username: 'bob') } + let!(:eve) { Fabricate(:account, username: 'eve', suspended: true) } before do - Setting.bootstrap_timeline_accounts = 'alice, bob' + Setting.bootstrap_timeline_accounts = 'alice, @bob, eve, unknown' subject.call(source_account) end @@ -32,6 +33,10 @@ RSpec.describe BootstrapTimelineService, type: :service do expect(source_account.following?(alice)).to be true expect(source_account.following?(bob)).to be true end + + it 'does not follow suspended account' do + expect(source_account.following?(eve)).to be false + end end end end -- cgit From 26a8c6fd2dd02426d0353887f0db6eb5b470305a Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Oct 2019 17:11:14 +0200 Subject: Fix custom emoji animation on hover in conversations view (#12040) --- .../direct_timeline/components/conversation.js | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/direct_timeline/components/conversation.js b/app/javascript/mastodon/features/direct_timeline/components/conversation.js index db9381f33..2cbaa0791 100644 --- a/app/javascript/mastodon/features/direct_timeline/components/conversation.js +++ b/app/javascript/mastodon/features/direct_timeline/components/conversation.js @@ -11,6 +11,7 @@ import Permalink from 'mastodon/components/permalink'; import IconButton from 'mastodon/components/icon_button'; import RelativeTimestamp from 'mastodon/components/relative_timestamp'; import { HotKeys } from 'react-hotkeys'; +import { autoPlayGif } from 'mastodon/initial_state'; const messages = defineMessages({ more: { id: 'status.more', defaultMessage: 'More' }, @@ -41,6 +42,43 @@ class Conversation extends ImmutablePureComponent { intl: PropTypes.object.isRequired, }; + _updateEmojis () { + const node = this.namesNode; + + if (!node || autoPlayGif) { + return; + } + + const emojis = node.querySelectorAll('.custom-emoji'); + + for (var i = 0; i < emojis.length; i++) { + let emoji = emojis[i]; + if (emoji.classList.contains('status-emoji')) { + continue; + } + emoji.classList.add('status-emoji'); + + emoji.addEventListener('mouseenter', this.handleEmojiMouseEnter, false); + emoji.addEventListener('mouseleave', this.handleEmojiMouseLeave, false); + } + } + + componentDidMount () { + this._updateEmojis(); + } + + componentDidUpdate () { + this._updateEmojis(); + } + + handleEmojiMouseEnter = ({ target }) => { + target.src = target.getAttribute('data-original'); + } + + handleEmojiMouseLeave = ({ target }) => { + target.src = target.getAttribute('data-static'); + } + handleClick = () => { if (!this.context.router) { return; @@ -83,6 +121,10 @@ class Conversation extends ImmutablePureComponent { this.props.onToggleHidden(this.props.lastStatus); } + setNamesRef = (c) => { + this.namesNode = c; + } + render () { const { accounts, lastStatus, unread, intl } = this.props; @@ -127,7 +169,7 @@ class Conversation extends ImmutablePureComponent { -
+
{names} }} />
-- cgit From 66fda37fd04de989d12f3f4c565ba5bfc6ee189d Mon Sep 17 00:00:00 2001 From: Jeong Arm Date: Wed, 2 Oct 2019 02:19:10 +0900 Subject: Scroll into search bar when focus (#12032) --- .../mastodon/features/compose/components/search.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app') diff --git a/app/javascript/mastodon/features/compose/components/search.js b/app/javascript/mastodon/features/compose/components/search.js index 7f9edfeee..3e36a922b 100644 --- a/app/javascript/mastodon/features/compose/components/search.js +++ b/app/javascript/mastodon/features/compose/components/search.js @@ -60,12 +60,17 @@ class Search extends React.PureComponent { onShow: PropTypes.func.isRequired, openInRoute: PropTypes.bool, intl: PropTypes.object.isRequired, + singleColumn: PropTypes.bool, }; state = { expanded: false, }; + setRef = c => { + this.searchForm = c; + } + handleChange = (e) => { this.props.onChange(e.target.value); } @@ -95,6 +100,13 @@ class Search extends React.PureComponent { handleFocus = () => { this.setState({ expanded: true }); this.props.onShow(); + + if (this.searchForm && !this.props.singleColumn) { + const { left, right } = this.searchForm.getBoundingClientRect(); + if (left < 0 || right > (window.innerWidth || document.documentElement.clientWidth)) { + this.searchForm.scrollIntoView(); + } + } } handleBlur = () => { @@ -111,6 +123,7 @@ class Search extends React.PureComponent {