From ae871c4d46a8498a3ff5c400baa6e82174b384d0 Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Mon, 31 Aug 2020 19:47:09 +0900 Subject: Make Array-creation behavior of Paginable more predictable (#14687) * Make Array-creation behavior of Paginable more predictable Paginable.paginate_by_id usually returns ActiveRecord::Relation, but it returns an Array if min_id option is present. The behavior caused problems fixed with the following commits: - 552e886b648faa2a2229d86c7fd9abc8bb5ff99c - b63ede5005d33b52266650ec716d345f166e2df0 - 64ef37b89de806f49cc59e011aa0ee2039c82c46 To prevent from recurring similar problems, this commit introduces two changes: - The scope now always returns an Array whether min_id option is present or not. - The scope is renamed to to_a_paginated_by_id to clarify it returns an Array. * Transform Paginable.to_a_paginated_by_id from a scope to a class method https://api.rubyonrails.org/classes/ActiveRecord/Scoping/Named/ClassMethods.html#method-i-scope > The method is intended to return an ActiveRecord::Relation object, which > is composable with other scopes. Paginable.to_a_paginated_by_id returns an Array and is not appropriate as a scope. --- app/controllers/api/v1/admin/accounts_controller.rb | 2 +- app/controllers/api/v1/admin/reports_controller.rb | 2 +- app/controllers/api/v1/bookmarks_controller.rb | 2 +- app/controllers/api/v1/conversations_controller.rb | 2 +- app/controllers/api/v1/crypto/encrypted_messages_controller.rb | 2 +- app/controllers/api/v1/favourites_controller.rb | 2 +- app/controllers/api/v1/scheduled_statuses_controller.rb | 2 +- app/controllers/concerns/cache_concern.rb | 2 +- app/models/account_conversation.rb | 4 ++-- app/models/concerns/paginable.rb | 6 +++--- 10 files changed, 13 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/controllers/api/v1/admin/accounts_controller.rb b/app/controllers/api/v1/admin/accounts_controller.rb index c35ea5ab2..24c7fbef1 100644 --- a/app/controllers/api/v1/admin/accounts_controller.rb +++ b/app/controllers/api/v1/admin/accounts_controller.rb @@ -79,7 +79,7 @@ class Api::V1::Admin::AccountsController < Api::BaseController private def set_accounts - @accounts = filtered_accounts.order(id: :desc).includes(user: [:invite_request, :invite]).paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) + @accounts = filtered_accounts.order(id: :desc).includes(user: [:invite_request, :invite]).to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) end def set_account diff --git a/app/controllers/api/v1/admin/reports_controller.rb b/app/controllers/api/v1/admin/reports_controller.rb index 1d48d3160..c8f4cd8d8 100644 --- a/app/controllers/api/v1/admin/reports_controller.rb +++ b/app/controllers/api/v1/admin/reports_controller.rb @@ -63,7 +63,7 @@ class Api::V1::Admin::ReportsController < Api::BaseController private def set_reports - @reports = filtered_reports.order(id: :desc).with_accounts.paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) + @reports = filtered_reports.order(id: :desc).with_accounts.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) end def set_report diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb index 5c72f4a1a..aa3fb88f0 100644 --- a/app/controllers/api/v1/bookmarks_controller.rb +++ b/app/controllers/api/v1/bookmarks_controller.rb @@ -21,7 +21,7 @@ class Api::V1::BookmarksController < Api::BaseController end def results - @_results ||= account_bookmarks.eager_load(:status).paginate_by_id( + @_results ||= account_bookmarks.eager_load(:status).to_a_paginated_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index bc8013379..6c7583403 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -32,7 +32,7 @@ class Api::V1::ConversationsController < Api::BaseController def paginated_conversations AccountConversation.where(account: current_account) - .paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) + .to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) end def insert_pagination_headers diff --git a/app/controllers/api/v1/crypto/encrypted_messages_controller.rb b/app/controllers/api/v1/crypto/encrypted_messages_controller.rb index c764915e5..68cf4384f 100644 --- a/app/controllers/api/v1/crypto/encrypted_messages_controller.rb +++ b/app/controllers/api/v1/crypto/encrypted_messages_controller.rb @@ -26,7 +26,7 @@ class Api::V1::Crypto::EncryptedMessagesController < Api::BaseController end def set_encrypted_messages - @encrypted_messages = @current_device.encrypted_messages.paginate_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) + @encrypted_messages = @current_device.encrypted_messages.to_a_paginated_by_id(limit_param(LIMIT), params_slice(:max_id, :since_id, :min_id)) end def insert_pagination_headers diff --git a/app/controllers/api/v1/favourites_controller.rb b/app/controllers/api/v1/favourites_controller.rb index 71a707d2a..21836bc17 100644 --- a/app/controllers/api/v1/favourites_controller.rb +++ b/app/controllers/api/v1/favourites_controller.rb @@ -21,7 +21,7 @@ class Api::V1::FavouritesController < Api::BaseController end def results - @_results ||= account_favourites.eager_load(:status).paginate_by_id( + @_results ||= account_favourites.eager_load(:status).to_a_paginated_by_id( limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/controllers/api/v1/scheduled_statuses_controller.rb b/app/controllers/api/v1/scheduled_statuses_controller.rb index 9950296f3..f90642a73 100644 --- a/app/controllers/api/v1/scheduled_statuses_controller.rb +++ b/app/controllers/api/v1/scheduled_statuses_controller.rb @@ -32,7 +32,7 @@ class Api::V1::ScheduledStatusesController < Api::BaseController private def set_statuses - @statuses = current_account.scheduled_statuses.paginate_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id)) + @statuses = current_account.scheduled_statuses.to_a_paginated_by_id(limit_param(DEFAULT_STATUSES_LIMIT), params_slice(:max_id, :since_id, :min_id)) end def set_status diff --git a/app/controllers/concerns/cache_concern.rb b/app/controllers/concerns/cache_concern.rb index 189b92012..abbdb410a 100644 --- a/app/controllers/concerns/cache_concern.rb +++ b/app/controllers/concerns/cache_concern.rb @@ -49,6 +49,6 @@ module CacheConcern end def cache_collection_paginated_by_id(raw, klass, limit, options) - cache_collection raw.cache_ids.paginate_by_id(limit, options), klass + cache_collection raw.cache_ids.to_a_paginated_by_id(limit, options), klass end end diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb index b43816588..5e2ddd083 100644 --- a/app/models/account_conversation.rb +++ b/app/models/account_conversation.rb @@ -36,11 +36,11 @@ class AccountConversation < ApplicationRecord end class << self - def paginate_by_id(limit, options = {}) + def to_a_paginated_by_id(limit, options = {}) if options[:min_id] paginate_by_min_id(limit, options[:min_id]).reverse else - paginate_by_max_id(limit, options[:max_id], options[:since_id]) + paginate_by_max_id(limit, options[:max_id], options[:since_id]).to_a end end diff --git a/app/models/concerns/paginable.rb b/app/models/concerns/paginable.rb index 8863094f7..760cc3df4 100644 --- a/app/models/concerns/paginable.rb +++ b/app/models/concerns/paginable.rb @@ -20,12 +20,12 @@ module Paginable query } - scope :paginate_by_id, ->(limit, options = {}) { + def self.to_a_paginated_by_id(limit, options = {}) if options[:min_id].present? paginate_by_min_id(limit, options[:min_id]).reverse else - paginate_by_max_id(limit, options[:max_id], options[:since_id]) + paginate_by_max_id(limit, options[:max_id], options[:since_id]).to_a end - } + end end end -- cgit From b1bb1906beaabe27efcba3e23e57b771d225f3a6 Mon Sep 17 00:00:00 2001 From: Takeshi Umeda Date: Tue, 1 Sep 2020 01:11:27 +0900 Subject: Fix limited follower id in fan-out-on-write service (#14709) --- app/services/fan_out_on_write_service.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index 21931c2f1..e05d02cef 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -58,9 +58,9 @@ class FanOutOnWriteService < BaseService def deliver_to_mentioned_followers(status) Rails.logger.debug "Delivering status #{status.id} to limited followers" - status.mentions.joins(:account).merge(status.account.followers_for_local_distribution).select(:id).reorder(nil).find_in_batches do |followers| - FeedInsertWorker.push_bulk(followers) do |follower| - [status.id, follower.id, :home] + status.mentions.joins(:account).merge(status.account.followers_for_local_distribution).select(:id, :account_id).reorder(nil).find_in_batches do |mentions| + FeedInsertWorker.push_bulk(mentions) do |mention| + [status.id, mention.account_id, :home] end end end -- cgit From 7febf1929633bc5af74026d37d338b0edf420523 Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 31 Aug 2020 18:11:37 +0200 Subject: Add back “Home” link to the “Getting Started” column when the “Home” column isn't mounted (#14707) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add back "Home" link to "Getting started" when Home column isn't mounted * Fix keys in getting_started It should not matter much in practice as the list of items will only change extremely rarely, but having a `key` that corresponds to the actual item makes much more sense than having it be the index of the item within the list. --- .../mastodon/features/getting_started/index.js | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'app') diff --git a/app/javascript/mastodon/features/getting_started/index.js b/app/javascript/mastodon/features/getting_started/index.js index d9838e1c7..02e1bbba5 100644 --- a/app/javascript/mastodon/features/getting_started/index.js +++ b/app/javascript/mastodon/features/getting_started/index.js @@ -40,6 +40,7 @@ const messages = defineMessages({ const mapStateToProps = state => ({ myAccount: state.getIn(['accounts', me]), + columns: state.getIn(['settings', 'columns']), unreadFollowRequests: state.getIn(['user_lists', 'follow_requests', 'items'], ImmutableList()).size, }); @@ -89,60 +90,66 @@ class GettingStarted extends ImmutablePureComponent { } render () { - const { intl, myAccount, multiColumn, unreadFollowRequests } = this.props; + const { intl, myAccount, columns, multiColumn, unreadFollowRequests } = this.props; const navItems = []; - let i = 1; let height = (multiColumn) ? 0 : 60; if (multiColumn) { navItems.push( - , - , - , + , + , + , ); height += 34 + 48*2; if (profile_directory) { navItems.push( - , + , ); height += 48; } navItems.push( - , + , ); height += 34; } else if (profile_directory) { navItems.push( - , + , ); height += 48; } + if (multiColumn && !columns.find(item => item.get('id') === 'HOME')) { + navItems.push( + , + ); + height += 48; + } + navItems.push( - , - , - , - , + , + , + , + , ); height += 48*4; if (myAccount.get('locked') || unreadFollowRequests > 0) { - navItems.push(); + navItems.push(); height += 48; } if (!multiColumn) { navItems.push( - , - , + , + , ); height += 34 + 48; -- cgit From f0b6ddd97948d9c443cd155cb8ccc497e0608117 Mon Sep 17 00:00:00 2001 From: ThibG Date: Mon, 31 Aug 2020 23:30:27 +0200 Subject: Add border around 🐞 emoji (#14712) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/features/emoji/emoji.js | 2 +- lib/tasks/emojis.rake | 2 +- public/emoji/1f41e_border.svg | 29 +++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 public/emoji/1f41e_border.svg (limited to 'app') diff --git a/app/javascript/mastodon/features/emoji/emoji.js b/app/javascript/mastodon/features/emoji/emoji.js index f7d3cfd08..5237b25f0 100644 --- a/app/javascript/mastodon/features/emoji/emoji.js +++ b/app/javascript/mastodon/features/emoji/emoji.js @@ -12,7 +12,7 @@ const emojiFilenames = (emojis) => { }; // Emoji requiring extra borders depending on theme -const darkEmoji = emojiFilenames(['🎱', '🐜', '⚫', '🖤', '⬛', '◼️', '◾', '◼️', '✒️', '▪️', '💣', '🎳', '📷', '📸', '♣️', '🕶️', '✴️', '🔌', '💂‍♀️', '📽️', '🍳', '🦍', '💂', '🔪', '🕳️', '🕹️', '🕋', '🖊️', '🖋️', '💂‍♂️', '🎤', '🎓', '🎥', '🎼', '♠️', '🎩', '🦃', '📼', '📹', '🎮', '🐃', '🏴']); +const darkEmoji = emojiFilenames(['🎱', '🐜', '⚫', '🖤', '⬛', '◼️', '◾', '◼️', '✒️', '▪️', '💣', '🎳', '📷', '📸', '♣️', '🕶️', '✴️', '🔌', '💂‍♀️', '📽️', '🍳', '🦍', '💂', '🔪', '🕳️', '🕹️', '🕋', '🖊️', '🖋️', '💂‍♂️', '🎤', '🎓', '🎥', '🎼', '♠️', '🎩', '🦃', '📼', '📹', '🎮', '🐃', '🏴', '🐞']); const lightEmoji = emojiFilenames(['👽', '⚾', '🐔', '☁️', '💨', '🕊️', '👀', '🍥', '👻', '🐐', '❕', '❔', '⛸️', '🌩️', '🔊', '🔇', '📃', '🌧️', '🐏', '🍚', '🍙', '🐓', '🐑', '💀', '☠️', '🌨️', '🔉', '🔈', '💬', '💭', '🏐', '🏳️', '⚪', '⬜', '◽', '◻️', '▫️']); const emojiFilename = (filename) => { diff --git a/lib/tasks/emojis.rake b/lib/tasks/emojis.rake index 0e7921ffc..2ac8bc059 100644 --- a/lib/tasks/emojis.rake +++ b/lib/tasks/emojis.rake @@ -91,7 +91,7 @@ namespace :emojis do desc 'Generate emoji variants with white borders' task :generate_borders do src = Rails.root.join('app', 'javascript', 'mastodon', 'features', 'emoji', 'emoji_map.json') - emojis = '🎱🐜⚫🖤⬛◼️◾◼️✒️▪️💣🎳📷📸♣️🕶️✴️🔌💂‍♀️📽️🍳🦍💂🔪🕳️🕹️🕋🖊️🖋️💂‍♂️🎤🎓🎥🎼♠️🎩🦃📼📹🎮🐃🏴👽⚾🐔☁️💨🕊️👀🍥👻🐐❕❔⛸️🌩️🔊🔇📃🌧️🐏🍚🍙🐓🐑💀☠️🌨️🔉🔈💬💭🏐🏳️⚪⬜◽◻️▫️' + emojis = '🎱🐜⚫🖤⬛◼️◾◼️✒️▪️💣🎳📷📸♣️🕶️✴️🔌💂‍♀️📽️🍳🦍💂🔪🕳️🕹️🕋🖊️🖋️💂‍♂️🎤🎓🎥🎼♠️🎩🦃📼📹🎮🐃🏴🐞👽⚾🐔☁️💨🕊️👀🍥👻🐐❕❔⛸️🌩️🔊🔇📃🌧️🐏🍚🍙🐓🐑💀☠️🌨️🔉🔈💬💭🏐🏳️⚪⬜◽◻️▫️' map = Oj.load(File.read(src)) diff --git a/public/emoji/1f41e_border.svg b/public/emoji/1f41e_border.svg new file mode 100644 index 000000000..5d4b1e3d7 --- /dev/null +++ b/public/emoji/1f41e_border.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit From 5fc5a9f9f18872cb0f1b54359338b2e189dd2bb1 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Sep 2020 00:26:10 +0200 Subject: Update Tesseract.js (#14708) * [WiP] Update Tesseract.js - Update Tesseract.js to 2.2.1 - Use versioned file names - differentiate two progression states: preparing OCR and detecting picture * Get rid of copy-webpack-plugin --- .../features/ui/components/focal_point_modal.js | 49 ++++-- config/webpack/rules/index.js | 2 + config/webpack/rules/node_modules.js | 5 +- config/webpack/rules/tesseract.js | 14 ++ config/webpack/shared.js | 7 - package.json | 3 +- yarn.lock | 180 ++++----------------- 7 files changed, 86 insertions(+), 174 deletions(-) create mode 100644 config/webpack/rules/tesseract.js (limited to 'app') diff --git a/app/javascript/mastodon/features/ui/components/focal_point_modal.js b/app/javascript/mastodon/features/ui/components/focal_point_modal.js index 7348d9599..926a495d1 100644 --- a/app/javascript/mastodon/features/ui/components/focal_point_modal.js +++ b/app/javascript/mastodon/features/ui/components/focal_point_modal.js @@ -18,6 +18,8 @@ import { length } from 'stringz'; import { Tesseract as fetchTesseract } from 'mastodon/features/ui/util/async-components'; import GIFV from 'mastodon/components/gifv'; import { me } from 'mastodon/initial_state'; +import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js'; +import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js'; const messages = defineMessages({ close: { id: 'lightbox.close', defaultMessage: 'Close' }, @@ -104,6 +106,7 @@ class FocalPointModal extends ImmutablePureComponent { dirty: false, progress: 0, loading: true, + ocrStatus: '', }; componentWillMount () { @@ -219,11 +222,18 @@ class FocalPointModal extends ImmutablePureComponent { this.setState({ detecting: true }); - fetchTesseract().then(({ TesseractWorker }) => { - const worker = new TesseractWorker({ - workerPath: `${assetHost}/packs/ocr/worker.min.js`, - corePath: `${assetHost}/packs/ocr/tesseract-core.wasm.js`, - langPath: `${assetHost}/ocr/lang-data`, + fetchTesseract().then(({ createWorker }) => { + const worker = createWorker({ + workerPath: tesseractWorkerPath, + corePath: tesseractCorePath, + langPath: assetHost, + logger: ({ status, progress }) => { + if (status === 'recognizing text') { + this.setState({ ocrStatus: 'detecting', progress }); + } else { + this.setState({ ocrStatus: 'preparing', progress }); + } + }, }); let media_url = media.get('url'); @@ -236,12 +246,18 @@ class FocalPointModal extends ImmutablePureComponent { } } - worker.recognize(media_url) - .progress(({ progress }) => this.setState({ progress })) - .finally(() => worker.terminate()) - .then(({ text }) => this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false })) - .catch(() => this.setState({ detecting: false })); - }).catch(() => this.setState({ detecting: false })); + (async () => { + await worker.load(); + await worker.loadLanguage('eng'); + await worker.initialize('eng'); + const { data: { text } } = await worker.recognize(media_url); + this.setState({ description: removeExtraLineBreaks(text), dirty: true, detecting: false }); + await worker.terminate(); + })(); + }).catch((e) => { + console.error(e); + this.setState({ detecting: false }); + }); } handleThumbnailChange = e => { @@ -261,7 +277,7 @@ class FocalPointModal extends ImmutablePureComponent { render () { const { media, intl, account, onClose, isUploadingThumbnail } = this.props; - const { x, y, dragging, description, dirty, detecting, progress } = this.state; + const { x, y, dragging, description, dirty, detecting, progress, ocrStatus } = this.state; const width = media.getIn(['meta', 'original', 'width']) || null; const height = media.getIn(['meta', 'original', 'height']) || null; @@ -282,6 +298,13 @@ class FocalPointModal extends ImmutablePureComponent { descriptionLabel = ; } + let ocrMessage = ''; + if (ocrStatus === 'detecting') { + ocrMessage = ; + } else { + ocrMessage = ; + } + return (
@@ -333,7 +356,7 @@ class FocalPointModal extends ImmutablePureComponent { />
- } /> +
diff --git a/config/webpack/rules/index.js b/config/webpack/rules/index.js index bbf6b0187..92a384e6d 100644 --- a/config/webpack/rules/index.js +++ b/config/webpack/rules/index.js @@ -1,6 +1,7 @@ const babel = require('./babel'); const css = require('./css'); const file = require('./file'); +const tesseract = require('./tesseract'); const nodeModules = require('./node_modules'); // Webpack loaders are processed in reverse order @@ -8,6 +9,7 @@ const nodeModules = require('./node_modules'); // Lastly, process static files using file loader module.exports = { file, + tesseract, css, nodeModules, babel, diff --git a/config/webpack/rules/node_modules.js b/config/webpack/rules/node_modules.js index 7ed05504b..c084d3a57 100644 --- a/config/webpack/rules/node_modules.js +++ b/config/webpack/rules/node_modules.js @@ -4,7 +4,10 @@ const { settings, env } = require('../configuration'); module.exports = { test: /\.(js|mjs)$/, include: /node_modules/, - exclude: /@babel(?:\/|\\{1,2})runtime/, + exclude: [ + /@babel(?:\/|\\{1,2})runtime/, + /tesseract.js/, + ], use: [ { loader: 'babel-loader', diff --git a/config/webpack/rules/tesseract.js b/config/webpack/rules/tesseract.js new file mode 100644 index 000000000..de647c8d1 --- /dev/null +++ b/config/webpack/rules/tesseract.js @@ -0,0 +1,14 @@ +module.exports = { + test: [ + /tesseract\.js\/dist\/worker\.min\.js$/, + /tesseract\.js\/dist\/worker\.min\.js.map$/, + /tesseract\.js-core\/tesseract-core\.wasm$/, + /tesseract\.js-core\/tesseract-core\.wasm.js$/, + ], + use: { + loader: 'file-loader', + options: { + name: 'ocr/[name]-[hash].[ext]', + }, + }, +}; diff --git a/config/webpack/shared.js b/config/webpack/shared.js index 15a209253..667652809 100644 --- a/config/webpack/shared.js +++ b/config/webpack/shared.js @@ -5,7 +5,6 @@ const { basename, dirname, join, relative, resolve } = require('path'); const { sync } = require('glob'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const AssetsManifestPlugin = require('webpack-assets-manifest'); -const CopyPlugin = require('copy-webpack-plugin'); const extname = require('path-complete-extname'); const { env, settings, themes, output } = require('./configuration'); const rules = require('./rules'); @@ -85,12 +84,6 @@ module.exports = { writeToDisk: true, publicPath: true, }), - new CopyPlugin({ - patterns: [ - { from: 'node_modules/tesseract.js/dist/worker.min.js', to: 'ocr' }, - { from: 'node_modules/tesseract.js-core/tesseract-core.wasm.js', to: 'ocr' }, - ], - }), ], resolve: { diff --git a/package.json b/package.json index 078ce1fc9..5f1456b65 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,6 @@ "blurhash": "^1.1.3", "classnames": "^2.2.5", "compression-webpack-plugin": "^5.0.1", - "copy-webpack-plugin": "^6.0.3", "cross-env": "^7.0.2", "css-loader": "^4.2.2", "cssnano": "^4.1.10", @@ -159,7 +158,7 @@ "stringz": "^2.1.0", "substring-trie": "^1.0.2", "terser-webpack-plugin": "^3.0.6", - "tesseract.js": "2.0.0-alpha.16", + "tesseract.js": "^2.1.1", "throng": "^4.0.0", "tiny-queue": "^0.2.1", "uuid": "^8.2.0", diff --git a/yarn.lock b/yarn.lock index 52805ef9b..96f8354d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1341,27 +1341,6 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@nodelib/fs.scandir@2.1.3": - version "2.1.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b" - integrity sha512-eGmwYQn3gxo4r7jdQnkrrN6bY478C3P+a/y72IJukF8LjB6ZHeB3c+Ehacj3sYeSmUXGlnA67/PmbM9CVwL7Dw== - dependencies: - "@nodelib/fs.stat" "2.0.3" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.3", "@nodelib/fs.stat@^2.0.2": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.3.tgz#34dc5f4cabbc720f4e60f75a747e7ecd6c175bd3" - integrity sha512-bQBFruR2TAwoevBEd/NWMoAAtNGzTRgdrqnYCc7dhzfoNvqPzLyqlEQnzZ3kVnNrSp25iyxE00/3h2fqGAGArA== - -"@nodelib/fs.walk@^1.2.3": - version "1.2.4" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.4.tgz#011b9202a70a6366e436ca5c065844528ab04976" - integrity sha512-1V9XOY4rDW0rehzbrcqAmHnz8e7SKvX27gh8Gt2WgB0+pdzdiLV83p72kZPU+jvMbS1qU5mauP2iOvO8rhmurQ== - dependencies: - "@nodelib/fs.scandir" "2.1.3" - fastq "^1.6.0" - "@npmcli/move-file@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@npmcli/move-file/-/move-file-1.0.1.tgz#de103070dac0f48ce49cf6693c23af59c0f70464" @@ -1996,11 +1975,6 @@ array-union@^1.0.1: dependencies: array-uniq "^1.0.1" -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - array-uniq@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" @@ -2133,14 +2107,6 @@ axe-core@^3.5.4: resolved "https://registry.yarnpkg.com/axe-core/-/axe-core-3.5.5.tgz#84315073b53fa3c0c51676c588d59da09a192227" integrity sha512-5P0QZ6J5xGikH780pghEdbEKijCTrruK9KxtPZCFWUpef0f6GipO+xEZ5GKCb020mmqgbiNO6TcA55CriL784Q== -axios@^0.18.0: - version "0.18.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.1.tgz#ff3f0de2e7b5d180e757ad98000f1081b87bcea3" - integrity sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g== - dependencies: - follow-redirects "1.5.10" - is-buffer "^2.0.2" - axios@^0.19.2: version "0.19.2" resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" @@ -2792,11 +2758,6 @@ char-regex@^1.0.2: resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" integrity sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw== -check-types@^7.4.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/check-types/-/check-types-7.4.0.tgz#0378ec1b9616ec71f774931a3c6516fad8c152f4" - integrity sha512-YbulWHdfP99UfZ73NcUDlNJhEIDgm9Doq9GhpyXbF+7Aegi3CVV7qqMCKTTqJxlvEvnQBp9IA+dxsGN6xK/nSg== - check-types@^8.0.3: version "8.0.3" resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552" @@ -3152,23 +3113,6 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= -copy-webpack-plugin@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/copy-webpack-plugin/-/copy-webpack-plugin-6.0.3.tgz#2b3d2bfc6861b96432a65f0149720adbd902040b" - integrity sha512-q5m6Vz4elsuyVEIUXr7wJdIdePWTubsqVbEMvf1WQnHGv0Q+9yPRu7MtYFPt+GBOXRav9lvIINifTQ1vSCs+eA== - dependencies: - cacache "^15.0.4" - fast-glob "^3.2.4" - find-cache-dir "^3.3.1" - glob-parent "^5.1.1" - globby "^11.0.1" - loader-utils "^2.0.0" - normalize-path "^3.0.0" - p-limit "^3.0.1" - schema-utils "^2.7.0" - serialize-javascript "^4.0.0" - webpack-sources "^1.4.3" - core-js-compat@^3.6.2: version "3.6.5" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.6.5.tgz#2a51d9a4e25dfd6e690251aa81f99e3c05481f1c" @@ -3734,13 +3678,6 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - dns-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" @@ -4571,18 +4508,6 @@ fast-deep-equal@^3.1.1: resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== -fast-glob@^3.1.1, fast-glob@^3.2.4: - version "3.2.4" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.4.tgz#d20aefbf99579383e7f3cc66529158c9b98554d3" - integrity sha512-kr/Oo6PX51265qeuCYsyGypiO5uJFgBS0jksyG7FUeCyQzNwYnzrNIMR1NXfkZXsMYXYLRAHgISHBz8gQcxKHQ== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.0" - merge2 "^1.3.0" - micromatch "^4.0.2" - picomatch "^2.2.1" - fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -4593,13 +4518,6 @@ fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.6: resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917" integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= -fastq@^1.6.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.8.0.tgz#550e1f9f59bbc65fe185cb6a9b4d95357107f481" - integrity sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q== - dependencies: - reusify "^1.0.4" - faye-websocket@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.10.0.tgz#4e492f8d04dfb6f89003507f6edbf2d501e7c6f4" @@ -4657,10 +4575,10 @@ file-loader@^6.0.0: loader-utils "^2.0.0" schema-utils "^2.6.5" -file-type@^10.5.0: - version "10.11.0" - resolved "https://registry.yarnpkg.com/file-type/-/file-type-10.11.0.tgz#2961d09e4675b9fb9a3ee6b69e9cd23f43fd1890" - integrity sha512-uzk64HRpUZyTGZtVuvrjP0FYxzQrBf4rojot6J65YMEbwBLB0CWm0CLojVpwpmFmxcE/lkvYICgfcGozbBq6rw== +file-type@^12.4.1: + version "12.4.2" + resolved "https://registry.yarnpkg.com/file-type/-/file-type-12.4.2.tgz#a344ea5664a1d01447ee7fb1b635f72feb6169d9" + integrity sha512-UssQP5ZgIOKelfsaB5CuGAL+Y+q7EmONuiwF3N5HAH0t27rvrttgi6Ra9k/+DVaY9UF6+ybxu5pOXLUdA8N7Vg== file-uri-to-path@1.0.0: version "1.0.0" @@ -5004,7 +4922,7 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" -glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@^5.1.1, glob-parent@~5.1.0: +glob-parent@^5.0.0, glob-parent@~5.1.0: version "5.1.1" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== @@ -5076,18 +4994,6 @@ globals@^9.2.0: resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== -globby@^11.0.1: - version "11.0.1" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.1.tgz#9a2bf107a068f3ffeabc49ad702c79ede8cfd357" - integrity sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.1.1" - ignore "^5.1.4" - merge2 "^1.3.0" - slash "^3.0.0" - globby@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" @@ -5445,7 +5351,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1: dependencies: postcss "^7.0.14" -idb-keyval@^3.1.0: +idb-keyval@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/idb-keyval/-/idb-keyval-3.2.0.tgz#cbbf354deb5684b6cdc84376294fc05932845bd6" integrity sha512-slx8Q6oywCCSfKgPgL0sEsXtPVnSbTLWpyiDcu6msHOyKOLari1TD1qocXVCft80umnkk3/Qqh3lwoFt8T/BPQ== @@ -5470,11 +5376,6 @@ ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.1.4: - version "5.1.6" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.6.tgz#643194ad4bf2712f37852e386b6998eff0db2106" - integrity sha512-cgXgkypZBcCnOgSihyeqbo6gjIaIyDqPQB7Ra4vhE9m6kigdGoQDMHjviFhRZo3IMlRy6yElosoviMs5YxZXUA== - immutable@^3.8.2: version "3.8.2" resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3" @@ -5746,11 +5647,6 @@ is-binary-path@~2.1.0: dependencies: binary-extensions "^2.0.0" -is-buffer@^2.0.2: - version "2.0.4" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-2.0.4.tgz#3e572f23c8411a5cfd9557c849e3665e0b290623" - integrity sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A== - is-callable@^1.1.4, is-callable@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" @@ -5822,6 +5718,11 @@ is-docker@^2.0.0: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.1.1.tgz#4125a88e44e450d384e09047ede71adc2d144156" integrity sha512-ZOoqiXfEwtGknTiuDEy8pN2CfE3TxMHprvNer1mXiqwkOT77Rw3YVrUQ52EqAOU3QAWDQ+bQdx7HJzrv7LS2Hw== +is-electron@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/is-electron/-/is-electron-2.2.0.tgz#8943084f09e8b731b3a7a0298a7b5d56f6b7eef0" + integrity sha512-SpMppC2XR3YdxSzczXReBjqs2zGscWQpBIKqwXYBFic0ERaxNVgwLCHwOLZeESfdJQjX0RDvrJ1lBXX2ij+G1Q== + is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -6002,11 +5903,6 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0: resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo= -is-url@1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.2.tgz#498905a593bf47cc2d9e7f738372bbf7696c7f26" - integrity sha1-SYkFpZO/R8wtnn9zg3K792lsfyY= - is-url@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/is-url/-/is-url-1.2.4.tgz#04a4df46d28c4cff3d73d01ff06abeb318a1aa52" @@ -7010,11 +6906,6 @@ merge-stream@^2.0.0: resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== -merge2@^1.3.0: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - merge@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.1.tgz#38bebf80c3220a8a487b6fcfb3941bb11720c145" @@ -7298,6 +7189,11 @@ nice-try@^1.0.4: resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== +node-fetch@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd" + integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== + node-forge@0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579" @@ -9118,7 +9014,7 @@ regenerator-runtime@^0.12.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== -regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7: +regenerator-runtime@^0.13.3, regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7: version "0.13.7" resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55" integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew== @@ -9362,11 +9258,6 @@ retry@^0.12.0: resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b" integrity sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs= -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - rgb-regex@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/rgb-regex/-/rgb-regex-1.0.1.tgz#c0e0d6882df0e23be254a475e8edd41915feaeb1" @@ -9418,11 +9309,6 @@ run-async@^0.1.0: dependencies: once "^1.3.0" -run-parallel@^1.1.9: - version "1.1.9" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" - integrity sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q== - run-queue@^1.0.0, run-queue@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47" @@ -10418,35 +10304,27 @@ terser@^4.1.2, terser@^4.8.0: source-map "~0.6.1" source-map-support "~0.5.12" -tesseract.js-core@^2.0.0-beta.12: +tesseract.js-core@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/tesseract.js-core/-/tesseract.js-core-2.2.0.tgz#6ef78051272a381969fac3e45a226e85022cffef" integrity sha512-a8L+OJTbUipBsEDsJhDPlnLB0TY1MkTZqw5dqUwmiDSjUzwvU7HWLg/2+WDRulKUi4LE+7PnHlaBlW0k+V0U0w== -tesseract.js-utils@^1.0.0-beta.8: - version "1.0.0-beta.8" - resolved "https://registry.yarnpkg.com/tesseract.js-utils/-/tesseract.js-utils-1.0.0-beta.8.tgz#d1ef25c12609a337c3e0ac12a33f9903f3145a68" - integrity sha512-qjHBfWfzo2o1ZY9XI0Wh2hmpp38+mIgCMOk60W5Yyie/pBl421VLBKOZUEwQgpbLnOJ24VU6Q8yXsVgtFFHcFg== +tesseract.js@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/tesseract.js/-/tesseract.js-2.1.1.tgz#5c50fc95542ce8d834cb952bfb75a8fc85f1441d" + integrity sha512-utg0A8UzT1KwBvZf+UMGmM8LU6izeol6yIem0Z44+7Qqd/YWgRVQ99XOG18ApTOXX48lGE++PDwlcZYkv0ygRQ== dependencies: - axios "^0.18.0" bmp-js "^0.1.0" - file-type "^10.5.0" - idb-keyval "^3.1.0" + file-type "^12.4.1" + idb-keyval "^3.2.0" + is-electron "^2.2.0" is-url "^1.2.4" - zlibjs "^0.3.1" - -tesseract.js@2.0.0-alpha.16: - version "2.0.0-alpha.16" - resolved "https://registry.yarnpkg.com/tesseract.js/-/tesseract.js-2.0.0-alpha.16.tgz#1e17717234a1464481abe12283f2c3ac79603d2e" - integrity sha512-8g3je2Kl8rkAFtpmwilGGj+8rCiPClNQaCjW6IafOPNn7hzFnVdL6fU6rG1Xsrc4Twv0HOa75kbpx5u70/WbTA== - dependencies: - axios "^0.18.0" - check-types "^7.4.0" - is-url "1.2.2" + node-fetch "^2.6.0" opencollective-postinstall "^2.0.2" + regenerator-runtime "^0.13.3" resolve-url "^0.2.1" - tesseract.js-core "^2.0.0-beta.12" - tesseract.js-utils "^1.0.0-beta.8" + tesseract.js-core "^2.2.0" + zlibjs "^0.3.1" test-exclude@^6.0.0: version "6.0.0" -- cgit From 8972e5f7f643c7a851de68b131b5b49844818ec5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2020 03:04:00 +0200 Subject: Bump rubocop from 0.86.0 to 0.88.0 (#14412) * Bump rubocop from 0.86.0 to 0.88.0 Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.86.0 to 0.88.0. - [Release notes](https://github.com/rubocop-hq/rubocop/releases) - [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md) - [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.86.0...v0.88.0) Signed-off-by: dependabot[bot] * Fix for latest RuboCop Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yamagishi Kazutoshi --- .codeclimate.yml | 2 +- .rubocop.yml | 175 ++++++++++++++++++++- Gemfile | 2 +- Gemfile.lock | 8 +- app/controllers/api/base_controller.rb | 1 + app/controllers/concerns/challengable_concern.rb | 1 - app/controllers/concerns/signature_verification.rb | 2 +- app/helpers/application_helper.rb | 2 + app/lib/activitypub/linked_data_signature.rb | 4 +- app/lib/entity_cache.rb | 2 +- app/lib/formatter.rb | 2 + app/lib/request.rb | 2 +- app/lib/sidekiq_error_handler.rb | 2 + app/models/preview_card.rb | 2 + app/models/user.rb | 8 +- app/services/fetch_link_card_service.rb | 2 + app/services/notify_service.rb | 2 + app/services/update_account_service.rb | 4 +- lib/mastodon/redis_config.rb | 2 +- lib/mastodon/version.rb | 6 +- lib/paperclip/color_extractor.rb | 4 +- 21 files changed, 203 insertions(+), 32 deletions(-) (limited to 'app') diff --git a/.codeclimate.yml b/.codeclimate.yml index b4ec9400e..9c9b4517a 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -30,7 +30,7 @@ plugins: channel: eslint-7 rubocop: enabled: true - channel: rubocop-0-82 + channel: rubocop-0-88 sass-lint: enabled: true exclude_patterns: diff --git a/.rubocop.yml b/.rubocop.yml index 25e0fa940..14728bf0e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,30 +25,68 @@ Layout/AccessModifierIndentation: Layout/EmptyLineAfterMagicComment: Enabled: false +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Layout/EmptyLinesAroundAttributeAccessor: + Enabled: true + +Layout/HashAlignment: + Enabled: false + # EnforcedHashRocketStyle: table + # EnforcedColonStyle: table + +Layout/SpaceAroundMethodCallOperator: + Enabled: true + Layout/SpaceInsideHashLiteralBraces: EnforcedStyle: space +Lint/DeprecatedOpenSSLConstant: + Enabled: true + +Lint/DuplicateElsifCondition: + Enabled: true + +Lint/MixedRegexpCaptureTypes: + Enabled: true + +Lint/RaiseException: + Enabled: true + +Lint/StructNewOverride: + Enabled: true + Lint/UselessAccessModifier: ContextCreatingMethods: - class_methods Metrics/AbcSize: Max: 100 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/BlockLength: - Max: 35 + Max: 55 Exclude: - 'lib/tasks/**/*' + - 'lib/mastodon/*_cli.rb' Metrics/BlockNesting: Max: 3 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/ClassLength: CountComments: false - Max: 300 + Max: 400 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/CyclomaticComplexity: Max: 25 + Exclude: + - 'lib/mastodon/*_cli.rb' Layout/LineLength: AllowURI: true @@ -56,7 +94,9 @@ Layout/LineLength: Metrics/MethodLength: CountComments: false - Max: 55 + Max: 65 + Exclude: + - 'lib/mastodon/*_cli.rb' Metrics/ModuleLength: CountComments: false @@ -67,24 +107,29 @@ Metrics/ParameterLists: CountKeywordArgs: true Metrics/PerceivedComplexity: - Max: 20 + Max: 25 Naming/MemoizedInstanceVariableName: Enabled: false +Naming/MethodParameterName: + Enabled: true + Rails: Enabled: true -Rails/EnumHash: +Rails/ApplicationController: Enabled: false + Exclude: + - 'app/controllers/well_known/**/*.rb' -Rails/HasAndBelongsToMany: +Rails/BelongsTo: Enabled: false -Rails/SkipsModelValidations: +Rails/ContentTag: Enabled: false -Rails/HttpStatus: +Rails/EnumHash: Enabled: false Rails/Exit: @@ -92,9 +137,60 @@ Rails/Exit: - 'lib/mastodon/*' - 'lib/cli.rb' +Rails/FilePath: + Enabled: false + +Rails/HasAndBelongsToMany: + Enabled: false + +Rails/HasManyOrHasOneDependent: + Enabled: false + Rails/HelperInstanceVariable: Enabled: false +Rails/HttpStatus: + Enabled: false + +Rails/IndexBy: + Enabled: false + +Rails/InverseOf: + Enabled: false + +Rails/LexicallyScopedActionFilter: + Enabled: false + +Rails/OutputSafety: + Enabled: true + +Rails/RakeEnvironment: + Enabled: false + +Rails/RedundantForeignKey: + Enabled: false + +Rails/SkipsModelValidations: + Enabled: false + +Rails/UniqueValidationWithoutIndex: + Enabled: false + +Style/AccessorGrouping: + Enabled: true + +Style/AccessModifierDeclarations: + Enabled: false + +Style/ArrayCoercion: + Enabled: true + +Style/BisectedAttrAccessor: + Enabled: true + +Style/CaseLikeIf: + Enabled: false + Style/ClassAndModuleChildren: Enabled: false @@ -109,6 +205,15 @@ Style/Documentation: Style/DoubleNegation: Enabled: true +Style/ExpandPathArguments: + Enabled: false + +Style/ExponentialNotation: + Enabled: true + +Style/FormatString: + Enabled: false + Style/FormatStringToken: Enabled: false @@ -118,9 +223,33 @@ Style/FrozenStringLiteralComment: Style/GuardClause: Enabled: false +Style/HashAsLastArrayItem: + Enabled: false + +Style/HashEachMethods: + Enabled: true + +Style/HashLikeCase: + Enabled: true + +Style/HashTransformKeys: + Enabled: true + +Style/HashTransformValues: + Enabled: false + +Style/IfUnlessModifier: + Enabled: false + +Style/InverseMethods: + Enabled: false + Style/Lambda: Enabled: false +Style/MutableConstant: + Enabled: false + Style/PercentLiteralDelimiters: PreferredDelimiters: '%i': '()' @@ -129,9 +258,36 @@ Style/PercentLiteralDelimiters: Style/PerlBackrefs: AutoCorrect: false +Style/RedundantAssignment: + Enabled: false + +Style/RedundantFetchBlock: + Enabled: true + +Style/RedundantFileExtensionInRequire: + Enabled: true + +Style/RedundantRegexpCharacterClass: + Enabled: false + +Style/RedundantRegexpEscape: + Enabled: false + +Style/RedundantReturn: + Enabled: true + Style/RegexpLiteral: Enabled: false +Style/RescueStandardError: + Enabled: false + +Style/SignalException: + Enabled: false + +Style/SlicingWithRange: + Enabled: true + Style/SymbolArray: Enabled: false @@ -140,3 +296,6 @@ Style/TrailingCommaInArrayLiteral: Style/TrailingCommaInHashLiteral: EnforcedStyleForMultiline: 'comma' + +Style/UnpackFirst: + Enabled: false diff --git a/Gemfile b/Gemfile index 3f53e3f63..6a683d586 100644 --- a/Gemfile +++ b/Gemfile @@ -140,7 +140,7 @@ group :development do gem 'letter_opener', '~> 1.7' gem 'letter_opener_web', '~> 1.4' gem 'memory_profiler' - gem 'rubocop', '~> 0.86', require: false + gem 'rubocop', '~> 0.88', require: false gem 'rubocop-rails', '~> 2.6', require: false gem 'brakeman', '~> 4.9', require: false gem 'bundler-audit', '~> 0.7', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 4157e1269..1e289c30a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -535,13 +535,13 @@ GEM rspec-support (3.9.3) rspec_junit_formatter (0.4.1) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.86.0) + rubocop (0.88.0) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 2.7.1.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.7) rexml - rubocop-ast (>= 0.0.3, < 1.0) + rubocop-ast (>= 0.1.0, < 1.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) rubocop-ast (0.3.0) @@ -778,7 +778,7 @@ DEPENDENCIES rspec-rails (~> 4.0) rspec-sidekiq (~> 3.1) rspec_junit_formatter (~> 0.4) - rubocop (~> 0.86) + rubocop (~> 0.88) rubocop-rails (~> 2.6) ruby-progressbar (~> 1.10) sanitize (~> 5.2) diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index 045e7dd26..467225547 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -71,6 +71,7 @@ class Api::BaseController < ApplicationController def limit_param(default_limit) return default_limit unless params[:limit] + [params[:limit].to_i.abs, default_limit * 2].min end diff --git a/app/controllers/concerns/challengable_concern.rb b/app/controllers/concerns/challengable_concern.rb index b29d90b3c..2995a25e0 100644 --- a/app/controllers/concerns/challengable_concern.rb +++ b/app/controllers/concerns/challengable_concern.rb @@ -32,7 +32,6 @@ module ChallengableConcern if params.key?(:form_challenge) if challenge_passed? session[:challenge_passed_at] = Time.now.utc - return else flash.now[:alert] = I18n.t('challenge.invalid_password') render_challenge diff --git a/app/controllers/concerns/signature_verification.rb b/app/controllers/concerns/signature_verification.rb index 18f549de9..f69c62ec2 100644 --- a/app/controllers/concerns/signature_verification.rb +++ b/app/controllers/concerns/signature_verification.rb @@ -131,7 +131,7 @@ module SignatureVerification end def verify_signature(account, signature, compare_signed_string) - if account.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, signature, compare_signed_string) + if account.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), signature, compare_signed_string) @signed_request_account = account @signed_request_account end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 716df0bac..5512a9543 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -162,6 +162,8 @@ module ApplicationHelper end json = ActiveModelSerializers::SerializableResource.new(InitialStatePresenter.new(state_params), serializer: InitialStateSerializer).to_json + # rubocop:disable Rails/OutputSafety content_tag(:script, json_escape(json).html_safe, id: 'initial-state', type: 'application/json') + # rubocop:enable Rails/OutputSafety end end diff --git a/app/lib/activitypub/linked_data_signature.rb b/app/lib/activitypub/linked_data_signature.rb index f52a8f406..e853a970e 100644 --- a/app/lib/activitypub/linked_data_signature.rb +++ b/app/lib/activitypub/linked_data_signature.rb @@ -27,7 +27,7 @@ class ActivityPub::LinkedDataSignature document_hash = hash(@json.without('signature')) to_be_verified = options_hash + document_hash - if creator.keypair.public_key.verify(OpenSSL::Digest::SHA256.new, Base64.decode64(signature), to_be_verified) + if creator.keypair.public_key.verify(OpenSSL::Digest.new('SHA256'), Base64.decode64(signature), to_be_verified) creator end end @@ -44,7 +44,7 @@ class ActivityPub::LinkedDataSignature to_be_signed = options_hash + document_hash keypair = sign_with.present? ? OpenSSL::PKey::RSA.new(sign_with) : creator.keypair - signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest::SHA256.new, to_be_signed)) + signature = Base64.strict_encode64(keypair.sign(OpenSSL::Digest.new('SHA256'), to_be_signed)) @json.merge('signature' => options.merge('signatureValue' => signature)) end diff --git a/app/lib/entity_cache.rb b/app/lib/entity_cache.rb index afdbd70f2..89cbf8d2c 100644 --- a/app/lib/entity_cache.rb +++ b/app/lib/entity_cache.rb @@ -16,7 +16,7 @@ class EntityCache end def emoji(shortcodes, domain) - shortcodes = [shortcodes] unless shortcodes.is_a?(Array) + shortcodes = Array(shortcodes) cached = Rails.cache.read_multi(*shortcodes.map { |shortcode| to_key(:emoji, shortcode, domain) }) uncached_ids = [] diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb index e6f5d7a63..7f217ae9f 100644 --- a/app/lib/formatter.rb +++ b/app/lib/formatter.rb @@ -135,6 +135,7 @@ class Formatter end end + # rubocop:disable Metrics/BlockNesting def encode_custom_emojis(html, emojis, animate = false) return html if emojis.empty? @@ -189,6 +190,7 @@ class Formatter html end + # rubocop:enable Metrics/BlockNesting def rewrite(text, entities) text = text.to_s diff --git a/app/lib/request.rb b/app/lib/request.rb index bcba1eebf..89fbeaf95 100644 --- a/app/lib/request.rb +++ b/app/lib/request.rb @@ -114,7 +114,7 @@ class Request def signature algorithm = 'rsa-sha256' - signature = Base64.strict_encode64(@keypair.sign(OpenSSL::Digest::SHA256.new, signed_string)) + signature = Base64.strict_encode64(@keypair.sign(OpenSSL::Digest.new('SHA256'), signed_string)) "keyId=\"#{key_id}\",algorithm=\"#{algorithm}\",headers=\"#{signed_headers.keys.join(' ').downcase}\",signature=\"#{signature}\"" end diff --git a/app/lib/sidekiq_error_handler.rb b/app/lib/sidekiq_error_handler.rb index b07817d45..ab555b1be 100644 --- a/app/lib/sidekiq_error_handler.rb +++ b/app/lib/sidekiq_error_handler.rb @@ -17,8 +17,10 @@ class SidekiqErrorHandler private + # rubocop:disable Naming/MethodParameterName def limit_backtrace_and_raise(e) e.set_backtrace(e.backtrace.first(BACKTRACE_LIMIT)) raise e end + # rubocop:enable Naming/MethodParameterName end diff --git a/app/models/preview_card.rb b/app/models/preview_card.rb index 235928260..a6ec839f8 100644 --- a/app/models/preview_card.rb +++ b/app/models/preview_card.rb @@ -72,6 +72,7 @@ class PreviewCard < ApplicationRecord class << self private + # rubocop:disable Naming/MethodParameterName def image_styles(f) styles = { original: { @@ -85,6 +86,7 @@ class PreviewCard < ApplicationRecord styles[:original][:format] = 'jpg' if f.instance.image_content_type == 'image/gif' styles end + # rubocop:enable Naming/MethodParameterName end private diff --git a/app/models/user.rb b/app/models/user.rb index 7e3b37475..dbee08988 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -253,16 +253,16 @@ class User < ApplicationRecord @shows_application ||= settings.show_application end + # rubocop:disable Naming/MethodParameterName def token_for_app(a) return nil if a.nil? || a.owner != self - Doorkeeper::AccessToken - .find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| - + Doorkeeper::AccessToken.find_or_create_by(application_id: a.id, resource_owner_id: id) do |t| t.scopes = a.scopes t.expires_in = Doorkeeper.configuration.access_token_expires_in t.use_refresh_token = Doorkeeper.configuration.refresh_token_enabled? end end + # rubocop:enable Naming/MethodParameterName def activate_session(request) session_activations.activate(session_id: SecureRandom.hex, @@ -413,7 +413,7 @@ class User < ApplicationRecord end def notify_staff_about_pending_account! - User.staff.includes(:account).each do |u| + User.staff.includes(:account).find_each do |u| next unless u.allows_pending_account_emails? AdminMailer.new_pending_account(u.account, self).deliver_later end diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index beab449b2..7efa31054 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -78,6 +78,7 @@ class FetchLinkCardService < BaseService uri.host.blank? || TagManager.instance.local_url?(uri.to_s) || !%w(http https).include?(uri.scheme) end + # rubocop:disable Naming/MethodParameterName def mention_link?(a) @status.mentions.any? do |mention| a['href'] == ActivityPub::TagManager.instance.url_for(mention.account) @@ -88,6 +89,7 @@ class FetchLinkCardService < BaseService # Avoid links for hashtags and mentions (microformats) a['rel']&.include?('tag') || a['class']&.match?(/u-url|h-card/) || mention_link?(a) end + # rubocop:enable Naming/MethodParameterName def attempt_oembed service = FetchOEmbedService.new diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 9364a6ae8..abd676494 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -13,7 +13,9 @@ class NotifyService < BaseService push_to_conversation! if direct_message? send_email! if email_enabled? rescue ActiveRecord::RecordInvalid + # rubocop:disable Style/RedundantReturn return + # rubocop:enable Style/RedundantReturn end private diff --git a/app/services/update_account_service.rb b/app/services/update_account_service.rb index 666db5c71..77f794e17 100644 --- a/app/services/update_account_service.rb +++ b/app/services/update_account_service.rb @@ -12,8 +12,8 @@ class UpdateAccountService < BaseService check_links(account) process_hashtags(account) end - rescue Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => de - account.errors.add(:avatar, de.message) + rescue Mastodon::DimensionsValidationError, Mastodon::StreamValidationError => e + account.errors.add(:avatar, e.message) false end diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb index e9db9122f..c3c8ff800 100644 --- a/lib/mastodon/redis_config.rb +++ b/lib/mastodon/redis_config.rb @@ -23,7 +23,7 @@ end setup_redis_env_url setup_redis_env_url(:cache, false) -namespace = ENV.fetch('REDIS_NAMESPACE') { nil } +namespace = ENV.fetch('REDIS_NAMESPACE', nil) cache_namespace = namespace ? namespace + '_cache' : 'cache' REDIS_CACHE_PARAMS = { diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 7aa6cb2c7..7b940d1f8 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -33,16 +33,16 @@ module Mastodon end def repository - ENV.fetch('GITHUB_REPOSITORY') { 'tootsuite/mastodon' } + ENV.fetch('GITHUB_REPOSITORY', 'tootsuite/mastodon') end def source_base_url - ENV.fetch('SOURCE_BASE_URL') { "https://github.com/#{repository}" } + ENV.fetch('SOURCE_BASE_URL', "https://github.com/#{repository}") end # specify git tag or commit hash here def source_tag - ENV.fetch('SOURCE_TAG') { nil } + ENV.fetch('SOURCE_TAG', nil) end def source_url diff --git a/lib/paperclip/color_extractor.rb b/lib/paperclip/color_extractor.rb index c8bb771a0..f850dc067 100644 --- a/lib/paperclip/color_extractor.rb +++ b/lib/paperclip/color_extractor.rb @@ -89,7 +89,7 @@ module Paperclip end end - # rubocop:disable Style/MethodParameterName + # rubocop:disable Naming/MethodParameterName def rgb_to_hsl(r, g, b) r /= 255.0 g /= 255.0 @@ -156,7 +156,7 @@ module Paperclip [(r * 255).round, (g * 255).round, (b * 255).round] end - # rubocop:enable Style/MethodParameterName + # rubocop:enable Naming/MethodParameterName def lighten_or_darken(color, by) hue, saturation, light = rgb_to_hsl(color.r, color.g, color.b) -- cgit From 1c308af84cddf8491b11aa6431c225faa80a9a5b Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 1 Sep 2020 13:30:42 +0200 Subject: Change own direct-visibility statuses to be in the home feed again (#14711) And remove highlighting in web UI Full circle from #8940 --- app/javascript/styles/mastodon/components.scss | 23 ----------------------- app/lib/feed_manager.rb | 2 +- app/services/fan_out_on_write_service.rb | 3 ++- 3 files changed, 3 insertions(+), 25 deletions(-) (limited to 'app') diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 06533246b..d91dde641 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -980,14 +980,6 @@ outline: 0; background: lighten($ui-base-color, 4%); - .status.status-direct { - background: lighten($ui-base-color, 12%); - - &.muted { - background: transparent; - } - } - .detailed-status, .detailed-status__action-bar { background: lighten($ui-base-color, 8%); @@ -1022,11 +1014,6 @@ margin-top: 8px; } - &.status-direct:not(.read) { - background: lighten($ui-base-color, 8%); - border-bottom-color: lighten($ui-base-color, 12%); - } - &.light { .status__relative-time, .status__visibility-icon { @@ -1064,16 +1051,6 @@ } } -.notification-favourite { - .status.status-direct { - background: transparent; - - .icon-button.disabled { - color: lighten($action-button-color, 13%); - } - } -} - .status__relative-time, .status__visibility-icon, .notification__relative_time { diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb index 96fa6cfc0..bebdc4a74 100644 --- a/app/lib/feed_manager.rb +++ b/app/lib/feed_manager.rb @@ -144,7 +144,7 @@ class FeedManager aggregate = account.user&.aggregates_reblogs? timeline_key = key(:home, account.id) - account.statuses.where.not(visibility: :direct).limit(limit).each do |status| + account.statuses.limit(limit).each do |status| add_to_feed(:home, account.id, status, aggregate) end diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb index e05d02cef..4f6c64de1 100644 --- a/app/services/fan_out_on_write_service.rb +++ b/app/services/fan_out_on_write_service.rb @@ -6,12 +6,13 @@ class FanOutOnWriteService < BaseService def call(status) raise Mastodon::RaceConditionError if status.visibility.nil? + deliver_to_self(status) if status.account.local? + if status.direct_visibility? deliver_to_own_conversation(status) elsif status.limited_visibility? deliver_to_mentioned_followers(status) else - deliver_to_self(status) if status.account.local? deliver_to_followers(status) deliver_to_lists(status) end -- cgit From 79305428a7c2bda311bc9d367a84acc28f569522 Mon Sep 17 00:00:00 2001 From: ThibG Date: Tue, 1 Sep 2020 13:31:28 +0200 Subject: Add configuration option to filter replies in lists (#9205) * Add database support for list show-reply preferences * Add backend support to read and update list-specific show_replies settings * Add basic UI to set list replies setting * Add specs for list replies policy * Switch "cycling" reply policy link to a set of radio inputs * Capitalize replies_policy strings * Change radio button design to be consistent with that of the directory explorer --- app/controllers/api/v1/lists_controller.rb | 2 +- app/javascript/mastodon/actions/lists.js | 4 +- .../mastodon/features/list_timeline/index.js | 30 ++++++- app/javascript/styles/mastodon/components.scss | 4 + app/lib/feed_manager.rb | 3 +- app/models/list.rb | 13 +-- app/serializers/rest/list_serializer.rb | 2 +- .../20181127165847_add_show_replies_to_lists.rb | 23 +++++ db/schema.rb | 1 + spec/lib/feed_manager_spec.rb | 97 +++++++++++++++++++++- 10 files changed, 165 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20181127165847_add_show_replies_to_lists.rb (limited to 'app') diff --git a/app/controllers/api/v1/lists_controller.rb b/app/controllers/api/v1/lists_controller.rb index 054172bee..e5ac45fef 100644 --- a/app/controllers/api/v1/lists_controller.rb +++ b/app/controllers/api/v1/lists_controller.rb @@ -38,6 +38,6 @@ class Api::V1::ListsController < Api::BaseController end def list_params - params.permit(:title) + params.permit(:title, :replies_policy) end end diff --git a/app/javascript/mastodon/actions/lists.js b/app/javascript/mastodon/actions/lists.js index d736bacef..5ab922436 100644 --- a/app/javascript/mastodon/actions/lists.js +++ b/app/javascript/mastodon/actions/lists.js @@ -150,10 +150,10 @@ export const createListFail = error => ({ error, }); -export const updateList = (id, title, shouldReset) => (dispatch, getState) => { +export const updateList = (id, title, shouldReset, replies_policy) => (dispatch, getState) => { dispatch(updateListRequest(id)); - api(getState).put(`/api/v1/lists/${id}`, { title }).then(({ data }) => { + api(getState).put(`/api/v1/lists/${id}`, { title, replies_policy }).then(({ data }) => { dispatch(updateListSuccess(data)); if (shouldReset) { diff --git a/app/javascript/mastodon/features/list_timeline/index.js b/app/javascript/mastodon/features/list_timeline/index.js index f3205b2bf..a3be8fbea 100644 --- a/app/javascript/mastodon/features/list_timeline/index.js +++ b/app/javascript/mastodon/features/list_timeline/index.js @@ -10,15 +10,19 @@ import { addColumn, removeColumn, moveColumn } from '../../actions/columns'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import { connectListStream } from '../../actions/streaming'; import { expandListTimeline } from '../../actions/timelines'; -import { fetchList, deleteList } from '../../actions/lists'; +import { fetchList, deleteList, updateList } from '../../actions/lists'; import { openModal } from '../../actions/modal'; import MissingIndicator from '../../components/missing_indicator'; import LoadingIndicator from '../../components/loading_indicator'; import Icon from 'mastodon/components/icon'; +import RadioButton from 'mastodon/components/radio_button'; const messages = defineMessages({ deleteMessage: { id: 'confirmations.delete_list.message', defaultMessage: 'Are you sure you want to permanently delete this list?' }, deleteConfirm: { id: 'confirmations.delete_list.confirm', defaultMessage: 'Delete' }, + all_replies: { id: 'lists.replies_policy.all_replies', defaultMessage: 'Any followed user' }, + no_replies: { id: 'lists.replies_policy.no_replies', defaultMessage: 'No one' }, + list_replies: { id: 'lists.replies_policy.list_replies', defaultMessage: 'Members of the list' }, }); const mapStateToProps = (state, props) => ({ @@ -131,11 +135,18 @@ class ListTimeline extends React.PureComponent { })); } + handleRepliesPolicyChange = ({ target }) => { + const { dispatch } = this.props; + const { id } = this.props.params; + dispatch(updateList(id, undefined, false, target.value)); + } + render () { - const { shouldUpdateScroll, hasUnread, columnId, multiColumn, list } = this.props; + const { shouldUpdateScroll, hasUnread, columnId, multiColumn, list, intl } = this.props; const { id } = this.props.params; const pinned = !!columnId; const title = list ? list.get('title') : id; + const replies_policy = list ? list.get('replies_policy') : undefined; if (typeof list === 'undefined') { return ( @@ -166,7 +177,7 @@ class ListTimeline extends React.PureComponent { pinned={pinned} multiColumn={multiColumn} > -
+
@@ -175,6 +186,19 @@ class ListTimeline extends React.PureComponent {
+ + { replies_policy !== undefined && ( +
+ + + +
+ { ['no_replies', 'list_replies', 'all_replies'].map(policy => ( + + ))} +
+
+ )}