From: Thibaut Girka Date: Mon, 28 Sep 2020 12:13:30 +0000 (+0200) Subject: Merge branch 'master' into glitch-soc/merge-upstream X-Git-Url: https://git.xn--scling-oua.cat.family/?a=commitdiff_plain;h=a7aedebc310ad7d387c508f7b0198a567a408fe6;p=mastodon.git Merge branch 'master' into glitch-soc/merge-upstream Conflicts: - `Gemfile.lock`: Not a real conflict, upstream updated dependencies that were too close to glitch-soc-only ones in the file. - `app/controllers/oauth/authorized_applications_controller.rb`: Upstream changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/controllers/settings/base_controller.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/controllers/settings/sessions_controller.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's theming system. Ported upstream changes. - `app/models/user.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc not preventing moved accounts from logging in. Ported upstream changes while keeping the ability for moved accounts to log in. - `app/policies/status_policy.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's local-only toots. Ported upstream changes. - `app/serializers/rest/account_serializer.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's ability to hide followers count. Ported upstream changes. - `app/services/process_mentions_service.rb`: Upstream refactored and changed the logic surrounding suspended accounts. Minor conflict due to glitch-soc's local-only toots. Ported upstream changes. - `package.json`: Not a real conflict, upstream updated dependencies that were too close to glitch-soc-only ones in the file. --- a7aedebc310ad7d387c508f7b0198a567a408fe6 diff --cc Gemfile.lock index 581d494ab,cdbb310c4..6f9c6a6f9 --- a/Gemfile.lock +++ b/Gemfile.lock @@@ -481,8 -480,7 +480,8 @@@ GE link_header (~> 0.0, >= 0.0.8) rdf-normalize (0.4.0) rdf (~> 3.1) + redcarpet (3.5.0) - redis (4.2.1) + redis (4.2.2) redis-actionpack (5.2.0) actionpack (>= 5, < 7) redis-rack (>= 2.1.0, < 3) diff --cc app/controllers/api/v1/mutes_controller.rb index 5dc047b43,805d0dee2..a89f3d700 --- a/app/controllers/api/v1/mutes_controller.rb +++ b/app/controllers/api/v1/mutes_controller.rb @@@ -21,12 -16,10 +21,14 @@@ class Api::V1::MutesController < Api::B paginated_mutes.map(&:target_account) end + def load_mutes + paginated_mutes.includes(:account, :target_account).to_a + end + def paginated_mutes @paginated_mutes ||= Mute.eager_load(:target_account) + .joins(:target_account) + .merge(Account.without_suspended) .where(account: current_account) .paginate_by_max_id( limit_param(DEFAULT_ACCOUNTS_LIMIT), diff --cc app/controllers/oauth/authorized_applications_controller.rb index c5ccece13,45151cdd7..b2564a791 --- a/app/controllers/oauth/authorized_applications_controller.rb +++ b/app/controllers/oauth/authorized_applications_controller.rb @@@ -5,7 -5,7 +5,8 @@@ class Oauth::AuthorizedApplicationsCont before_action :store_current_location before_action :authenticate_resource_owner! + before_action :set_pack + before_action :require_not_suspended!, only: :destroy before_action :set_body_classes skip_before_action :require_functional! @@@ -27,7 -27,7 +28,11 @@@ store_location_for(:user, request.url) end + def set_pack + use_pack 'settings' + end ++ + def require_not_suspended! + forbidden if current_account.suspended? + end end diff --cc app/controllers/settings/base_controller.rb index b97603af6,8311538a5..dee3922d8 --- a/app/controllers/settings/base_controller.rb +++ b/app/controllers/settings/base_controller.rb @@@ -1,7 -1,9 +1,10 @@@ # frozen_string_literal: true class Settings::BaseController < ApplicationController + before_action :set_pack + layout 'admin' + + before_action :authenticate_user! before_action :set_body_classes before_action :set_cache_headers diff --cc app/controllers/settings/identity_proofs_controller.rb index b217b3c3b,bf2899da6..4618c7883 --- a/app/controllers/settings/identity_proofs_controller.rb +++ b/app/controllers/settings/identity_proofs_controller.rb @@@ -1,11 -1,7 +1,8 @@@ # frozen_string_literal: true class Settings::IdentityProofsController < Settings::BaseController - layout 'admin' - - before_action :authenticate_user! before_action :check_required_params, only: :new + before_action :check_enabled, only: :new def index @proofs = AccountIdentityProof.where(account: current_account).order(provider: :asc, provider_username: :asc) diff --cc app/models/user.rb index 4467362e1,6b21d6ed6..6cd2ca6bd --- a/app/models/user.rb +++ b/app/models/user.rb @@@ -177,7 -176,7 +177,7 @@@ class User < ApplicationRecor end def functional? - confirmed? && approved? && !disabled? && !account.suspended? - confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial? && account.moved_to_account_id.nil? ++ confirmed? && approved? && !disabled? && !account.suspended? && !account.memorial? end def unconfirmed_or_pending? diff --cc app/policies/status_policy.rb index fa5c0dd9c,bcf9c3395..d0359580d --- a/app/policies/status_policy.rb +++ b/app/policies/status_policy.rb @@@ -12,7 -12,7 +12,8 @@@ class StatusPolicy < ApplicationPolic end def show? + return false if author.suspended? + return false if local_only? && (current_account.nil? || !current_account.local?) if requires_mention? owned? || mention_exists? diff --cc app/serializers/rest/account_serializer.rb index 4e497cdbd,189a62d0e..5cc42c7cf --- a/app/serializers/rest/account_serializer.rb +++ b/app/serializers/rest/account_serializer.rb @@@ -60,7 -59,41 +59,45 @@@ class REST::AccountSerializer < ActiveM object.last_status_at&.to_date&.iso8601 end + def followers_count + (Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count + end ++ + def display_name + object.suspended? ? '' : object.display_name + end + + def locked + object.suspended? ? false : object.locked + end + + def bot + object.suspended? ? false : object.bot + end + + def discoverable + object.suspended? ? false : object.discoverable + end + + def moved_to_account + object.suspended? ? nil : object.moved_to_account + end + + def emojis + object.suspended? ? [] : object.emojis + end + + def fields + object.suspended? ? [] : object.fields + end + + def suspended + object.suspended? + end + + delegate :suspended?, to: :object + + def moved_and_not_nested? + object.moved? && object.moved_to_account.moved_to_account_id.nil? + end end diff --cc app/services/process_mentions_service.rb index f45422970,12f0f1b08..feffb872b --- a/app/services/process_mentions_service.rb +++ b/app/services/process_mentions_service.rb @@@ -58,8 -58,8 +58,8 @@@ class ProcessMentionsService < BaseServ mentioned_account = mention.account if mentioned_account.local? - LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name) + LocalNotificationWorker.perform_async(mentioned_account.id, mention.id, mention.class.name, :mention) - elsif mentioned_account.activitypub? + elsif mentioned_account.activitypub? && !@status.local_only? ActivityPub::DeliveryWorker.perform_async(activitypub_json, mention.status.account_id, mentioned_account.inbox_url) end end diff --cc app/workers/feed_insert_worker.rb index fd35af562,b70c7e389..45e6bb88d --- a/app/workers/feed_insert_worker.rb +++ b/app/workers/feed_insert_worker.rb @@@ -45,8 -50,10 +54,12 @@@ class FeedInsertWorke FeedManager.instance.push_to_home(@follower, @status) when :list FeedManager.instance.push_to_list(@list, @status) + when :direct + FeedManager.instance.push_to_direct(@account, @status) end end + + def perform_notify + NotifyService.new.call(@follower, :status, @status) + end end diff --cc package.json index 11e2b5c84,d6ed58ca4..30dfbc471 --- a/package.json +++ b/package.json @@@ -70,13 -69,12 +70,13 @@@ "@babel/runtime": "^7.11.2", "@clusterws/cws": "^3.0.0", "@gamestdio/websocket": "^0.3.2", - "@github/webauthn-json": "^0.4.2", + "@github/webauthn-json": "^0.5.4", "@rails/ujs": "^6.0.3", "array-includes": "^3.1.1", + "atrament": "0.2.4", "arrow-key-navigation": "^1.2.0", "autoprefixer": "^9.8.6", - "axios": "^0.19.2", + "axios": "^0.20.0", "babel-loader": "^8.1.0", "babel-plugin-lodash": "^3.3.4", "babel-plugin-preval": "^5.0.0", @@@ -96,8 -94,7 +96,8 @@@ "escape-html": "^1.0.3", "exif-js": "^2.3.0", "express": "^4.17.1", + "favico.js": "^0.3.10", - "file-loader": "^6.0.0", + "file-loader": "^6.1.0", "font-awesome": "^4.7.0", "glob": "^7.1.6", "history": "^4.10.1", diff --cc spec/models/concerns/account_interactions_spec.rb index 36e346f14,f0380179c..68eb9c027 --- a/spec/models/concerns/account_interactions_spec.rb +++ b/spec/models/concerns/account_interactions_spec.rb @@@ -12,9 -12,9 +12,9 @@@ describe AccountInteractions d subject { Account.following_map(target_account_ids, account_id) } context 'account with Follow' do - it 'returns { target_account_id => true }' do + it 'returns { target_account_id => { reblogs: true } }' do Fabricate(:follow, account: account, target_account: target_account) - is_expected.to eq(target_account_id => { reblogs: true }) + is_expected.to eq(target_account_id => { reblogs: true, notify: false }) end end diff --cc spec/services/notify_service_spec.rb index b09d335ba,f2cb22c5e..118436f8b --- a/spec/services/notify_service_spec.rb +++ b/spec/services/notify_service_spec.rb @@@ -47,9 -48,10 +48,10 @@@ RSpec.describe NotifyService, type: :se recipient.suspend! is_expected.to_not change(Notification, :count) end - + context 'for direct messages' do let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) } + let(:type) { :mention } before do user.settings.interactions = user.settings.interactions.merge('must_be_following_dm' => enabled)