diff --git a/Changelog.md b/Changelog.md index b40deafc8..2e4ca13fd 100644 --- a/Changelog.md +++ b/Changelog.md @@ -43,6 +43,7 @@ Although the chat was never enabled per default and was marked as experimental, * Fix html-syntax in some handlebars templates [#8251](https://github.com/diaspora/diaspora/pull/8251) * Remove `chat_enabled` flag from archive export [#8265](https://github.com/diaspora/diaspora/pull/8265) * Change thumbnails in image slideshow to squares [#8275](https://github.com/diaspora/diaspora/pull/8275) +* Replace uglifier with terser for JS compression [#8268](https://github.com/diaspora/diaspora/pull/8268) ## Bug fixes diff --git a/Gemfile b/Gemfile index 6ae1fbda0..59739ec97 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,7 @@ gem "sidekiq-cron", "1.2.0" # Compression -gem "uglifier", "4.2.0" +gem "terser", "1.1.5" # Configuration diff --git a/Gemfile.lock b/Gemfile.lock index d918478e2..1bf8afb66 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -721,6 +721,8 @@ GEM temple (0.8.2) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) + terser (1.1.5) + execjs (>= 0.3.0, < 3) thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) @@ -747,8 +749,6 @@ GEM ethon (>= 0.9.0) tzinfo (1.2.9) thread_safe (~> 0.1) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.7) @@ -918,13 +918,13 @@ DEPENDENCIES sprockets-es6 (= 0.9.2) sprockets-rails (= 3.2.2) string-direction (= 1.2.2) + terser (= 1.1.5) timecop (= 0.9.4) toml-rb (= 2.0.1) turbo_dev_assets (= 0.0.2) twitter (= 7.0.0) twitter-text (= 3.1.0) typhoeus (= 1.4.0) - uglifier (= 4.2.0) unicorn (= 6.0.0) unicorn-worker-killer (= 0.4.5) uuid (= 2.3.9) diff --git a/app/models/user.rb b/app/models/user.rb index 14eb4562c..788fe6aba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -442,8 +442,13 @@ class User < ApplicationRecord aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances')) if AppConfig.settings.autofollow_on_join? - default_account = Person.find_or_fetch_by_identifier(AppConfig.settings.autofollow_on_join_user) - self.share_with(default_account, aq) if default_account + begin + default_account = Person.find_or_fetch_by_identifier(AppConfig.settings.autofollow_on_join_user) + share_with(default_account, aq) + rescue DiasporaFederation::Discovery::DiscoveryError + logger.warn "Error auto-sharing with #{AppConfig.settings.autofollow_on_join_user} + fix autofollow_on_join_user in configuration." + end end aq end diff --git a/app/workers/fetch_webfinger.rb b/app/workers/fetch_webfinger.rb index d2f00b0dc..dbf4f95e6 100644 --- a/app/workers/fetch_webfinger.rb +++ b/app/workers/fetch_webfinger.rb @@ -12,7 +12,9 @@ module Workers person = Person.find_or_fetch_by_identifier(account) # also, schedule to fetch a few public posts from that person - Diaspora::Fetcher::Public.queue_for(person) unless person.nil? + Diaspora::Fetcher::Public.queue_for(person) + rescue DiasporaFederation::Discovery::DiscoveryError + # Ignored end end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 304613a67..13a91a017 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -27,7 +27,7 @@ Rails.application.configure do config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + config.assets.js_compressor = :terser # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. diff --git a/lib/bookmarklet_renderer.rb b/lib/bookmarklet_renderer.rb index 75b2b51f1..a8e998a73 100644 --- a/lib/bookmarklet_renderer.rb +++ b/lib/bookmarklet_renderer.rb @@ -30,7 +30,7 @@ class BookmarkletRenderer def compile src = File.read(source) - @body = Uglifier.compile(src) + @body = Terser.compile(src) FileUtils.mkdir_p cached_path.dirname File.open(cached_path, "w") {|f| f.write(@body) } end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ff159932a..6784f4a92 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -797,10 +797,10 @@ describe User, type: :model do context "with autofollow sharing enabled" do it "should start sharing with autofollow account" do AppConfig.settings.autofollow_on_join = true - AppConfig.settings.autofollow_on_join_user = "one" - - expect(Person).to receive(:find_or_fetch_by_identifier).with("one") + person = FactoryBot.build(:person) + AppConfig.settings.autofollow_on_join_user = person.diaspora_handle + expect(Person).to receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) user.seed_aspects end end diff --git a/spec/workers/fetch_webfinger_spec.rb b/spec/workers/fetch_webfinger_spec.rb index 02382e9b4..73506a173 100644 --- a/spec/workers/fetch_webfinger_spec.rb +++ b/spec/workers/fetch_webfinger_spec.rb @@ -11,7 +11,7 @@ describe Workers::FetchWebfinger do end it "should webfinger and queue no job to fetch public posts if the person is not found" do - allow(Person).to receive(:find_or_fetch_by_identifier).and_return(nil) + allow(Person).to receive(:find_or_fetch_by_identifier).and_raise DiasporaFederation::Discovery::DiscoveryError expect(Diaspora::Fetcher::Public).not_to receive(:queue_for)