From fa4a82326d4e33c63a76c6725c36e85fe3ae9310 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 8 Oct 2024 09:21:36 -0400 Subject: [PATCH 01/13] Bring icon vertical middle to applications list style (#32293) --- app/javascript/styles/mastodon/admin.scss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss index 0712a0d3f4..c7b32a9c9e 100644 --- a/app/javascript/styles/mastodon/admin.scss +++ b/app/javascript/styles/mastodon/admin.scss @@ -1029,6 +1029,12 @@ a.name-tag, color: var(--user-role-accent); } +.applications-list { + .icon { + vertical-align: middle; + } +} + .announcements-list, .filters-list { border: 1px solid var(--background-border-color); From 9e04e46521a2580574caf0ede45229c0ef8df9ec Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Tue, 8 Oct 2024 09:23:30 -0400 Subject: [PATCH 02/13] Reference `IpBlock.severities` keys from CLI option check (#32291) --- lib/mastodon/cli/ip_blocks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mastodon/cli/ip_blocks.rb b/lib/mastodon/cli/ip_blocks.rb index 3c5fdb275c..ef24f2e047 100644 --- a/lib/mastodon/cli/ip_blocks.rb +++ b/lib/mastodon/cli/ip_blocks.rb @@ -5,7 +5,7 @@ require_relative 'base' module Mastodon::CLI class IpBlocks < Base - option :severity, required: true, enum: %w(no_access sign_up_requires_approval sign_up_block), desc: 'Severity of the block' + option :severity, required: true, enum: IpBlock.severities.keys, desc: 'Severity of the block' option :comment, aliases: [:c], desc: 'Optional comment' option :duration, aliases: [:d], type: :numeric, desc: 'Duration of the block in seconds' option :force, type: :boolean, aliases: [:f], desc: 'Overwrite existing blocks' From c0d3b3de1030577a33cb61f38cdb0de10451dd1d Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Oct 2024 14:13:32 +0200 Subject: [PATCH 03/13] Fix `latest` tag for 4.3 docker image builds (#32350) --- .github/workflows/build-releases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-releases.yml b/.github/workflows/build-releases.yml index 3f0bef32ac..da9a458282 100644 --- a/.github/workflows/build-releases.yml +++ b/.github/workflows/build-releases.yml @@ -23,7 +23,7 @@ jobs: # Only tag with latest when ran against the latest stable branch # This needs to be updated after each minor version release flavor: | - latest=${{ startsWith(github.ref, 'refs/tags/v4.2.') }} + latest=${{ startsWith(github.ref, 'refs/tags/v4.3.') }} tags: | type=pep440,pattern={{raw}} type=pep440,pattern=v{{major}}.{{minor}} From 6ac78ead5202332a06c8ef3869ea5c4927ea5842 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Oct 2024 19:16:57 +0200 Subject: [PATCH 04/13] Fix 4 columns barely not fitting on 1920px screen (#32361) --- app/javascript/styles/mastodon/components.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 4ed05ead3f..6e386ff687 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -2863,7 +2863,7 @@ $ui-header-logo-wordmark-width: 99px; } .column { - width: 400px; + width: clamp(380px, calc((100% - 350px) / 4), 400px); position: relative; box-sizing: border-box; display: flex; From 45a520603b10792e24a2190215c0305c739108d0 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Oct 2024 19:24:22 +0200 Subject: [PATCH 05/13] Fix list edition modal styling (#32358) --- .../styles/mastodon/components.scss | 111 ++++++++---------- 1 file changed, 50 insertions(+), 61 deletions(-) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 6e386ff687..78e5290139 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -7961,7 +7961,6 @@ noscript { justify-content: flex-start; gap: 15px; align-items: center; - border: 1px solid var(--background-border-color); border-top: 0; label { @@ -7988,79 +7987,23 @@ noscript { background: rgba($base-overlay-background, 0.5); } +.list-adder, .list-editor { - background: $ui-base-color; + backdrop-filter: var(--background-filter); + background: var(--modal-background-color); + border: 1px solid var(--modal-border-color); flex-direction: column; border-radius: 8px; - box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4); width: 380px; overflow: hidden; @media screen and (width <= 420px) { width: 90%; } - - h4 { - padding: 15px 0; - background: lighten($ui-base-color, 13%); - font-weight: 500; - font-size: 16px; - text-align: center; - border-radius: 8px 8px 0 0; - } - - .drawer__pager { - height: 50vh; - border-radius: 4px; - } - - .drawer__inner { - border-radius: 0 0 8px 8px; - - &.backdrop { - width: calc(100% - 60px); - box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4); - border-radius: 0 0 0 8px; - } - } - - &__accounts { - overflow-y: auto; - } - - .account__display-name { - &:hover strong { - text-decoration: none; - } - } - - .account__avatar { - cursor: default; - } - - .search { - margin-bottom: 0; - } } .list-adder { - background: $ui-base-color; - flex-direction: column; - border-radius: 8px; - box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4); - width: 380px; - overflow: hidden; - - @media screen and (width <= 420px) { - width: 90%; - } - - &__account { - background: lighten($ui-base-color, 13%); - } - &__lists { - background: lighten($ui-base-color, 13%); height: 50vh; border-radius: 0 0 8px 8px; overflow-y: auto; @@ -8081,6 +8024,52 @@ noscript { text-decoration: none; font-size: 16px; padding: 10px; + display: flex; + align-items: center; + gap: 4px; + } +} + +.list-editor { + h4 { + padding: 15px 0; + background: lighten($ui-base-color, 13%); + font-weight: 500; + font-size: 16px; + text-align: center; + border-radius: 8px 8px 0 0; + } + + .drawer__pager { + height: 50vh; + border: 0; + } + + .drawer__inner { + &.backdrop { + width: calc(100% - 60px); + box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4); + border-radius: 0 0 0 8px; + } + } + + &__accounts { + background: unset; + overflow-y: auto; + } + + .account__display-name { + &:hover strong { + text-decoration: none; + } + } + + .account__avatar { + cursor: default; + } + + .search { + margin-bottom: 0; } } From e5e0144957513719de1885c41ff08eebcac25fa8 Mon Sep 17 00:00:00 2001 From: Claire Date: Wed, 9 Oct 2024 19:29:02 +0200 Subject: [PATCH 06/13] Fix notification requests from suspended accounts still being listed (#32354) --- .../v1/notifications/requests_controller.rb | 2 +- app/models/notification_policy.rb | 2 +- app/models/notification_request.rb | 2 ++ spec/models/notification_policy_spec.rb | 18 ++++++++++++------ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/v1/notifications/requests_controller.rb b/app/controllers/api/v1/notifications/requests_controller.rb index 36ee073b9c..3c90f13ce2 100644 --- a/app/controllers/api/v1/notifications/requests_controller.rb +++ b/app/controllers/api/v1/notifications/requests_controller.rb @@ -52,7 +52,7 @@ class Api::V1::Notifications::RequestsController < Api::BaseController private def load_requests - requests = NotificationRequest.where(account: current_account).includes(:last_status, from_account: [:account_stat, :user]).to_a_paginated_by_id( + requests = NotificationRequest.where(account: current_account).without_suspended.includes(:last_status, from_account: [:account_stat, :user]).to_a_paginated_by_id( limit_param(DEFAULT_ACCOUNTS_LIMIT), params_slice(:max_id, :since_id, :min_id) ) diff --git a/app/models/notification_policy.rb b/app/models/notification_policy.rb index 3b16f33d88..d22f871a37 100644 --- a/app/models/notification_policy.rb +++ b/app/models/notification_policy.rb @@ -62,6 +62,6 @@ class NotificationPolicy < ApplicationRecord private def pending_notification_requests - @pending_notification_requests ||= notification_requests.limit(MAX_MEANINGFUL_COUNT).pick(Arel.sql('count(*), coalesce(sum(notifications_count), 0)::bigint')) + @pending_notification_requests ||= notification_requests.without_suspended.limit(MAX_MEANINGFUL_COUNT).pick(Arel.sql('count(*), coalesce(sum(notifications_count), 0)::bigint')) end end diff --git a/app/models/notification_request.rb b/app/models/notification_request.rb index f0778b3af3..eb9ff93ab7 100644 --- a/app/models/notification_request.rb +++ b/app/models/notification_request.rb @@ -26,6 +26,8 @@ class NotificationRequest < ApplicationRecord before_save :prepare_notifications_count + scope :without_suspended, -> { joins(:from_account).merge(Account.without_suspended) } + def self.preload_cache_collection(requests) cached_statuses_by_id = yield(requests.filter_map(&:last_status)).index_by(&:id) # Call cache_collection in block diff --git a/spec/models/notification_policy_spec.rb b/spec/models/notification_policy_spec.rb index 02a582bb08..7d1b494dd5 100644 --- a/spec/models/notification_policy_spec.rb +++ b/spec/models/notification_policy_spec.rb @@ -7,19 +7,25 @@ RSpec.describe NotificationPolicy do subject { Fabricate(:notification_policy) } let(:sender) { Fabricate(:account) } + let(:suspended_sender) { Fabricate(:account) } before do Fabricate.times(2, :notification, account: subject.account, activity: Fabricate(:status, account: sender), filtered: true, type: :mention) Fabricate(:notification_request, account: subject.account, from_account: sender) + + Fabricate(:notification, account: subject.account, activity: Fabricate(:status, account: suspended_sender), filtered: true, type: :mention) + Fabricate(:notification_request, account: subject.account, from_account: suspended_sender) + + suspended_sender.suspend! + subject.summarize! end - it 'sets pending_requests_count' do - expect(subject.pending_requests_count).to eq 1 - end - - it 'sets pending_notifications_count' do - expect(subject.pending_notifications_count).to eq 2 + it 'sets pending_requests_count and pending_notifications_count' do + expect(subject).to have_attributes( + pending_requests_count: 1, + pending_notifications_count: 2 + ) end end end From de4f7859b4cf5fc5254173368cf35f0d711331b6 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Wed, 9 Oct 2024 14:33:28 -0500 Subject: [PATCH 07/13] Restore list column border (#32367) --- app/javascript/styles/mastodon/components.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 78e5290139..1f69dab7be 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -7961,6 +7961,7 @@ noscript { justify-content: flex-start; gap: 15px; align-items: center; + border: 1px solid var(--background-border-color); border-top: 0; label { From f75eb1a8b0386d2ca5c1c05ee3b10364b3e11211 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Oct 2024 13:04:38 +0200 Subject: [PATCH 08/13] =?UTF-8?q?Fix=20=E2=80=9CMention=E2=80=9D=20appeari?= =?UTF-8?q?ng=20for=20otherwise=20filtered=20posts=20(#32356)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/notification_with_status.tsx | 9 +++- app/javascript/mastodon/selectors/filters.ts | 50 +++++++++++++++++++ app/javascript/mastodon/selectors/index.js | 15 +----- 3 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 app/javascript/mastodon/selectors/filters.ts diff --git a/app/javascript/mastodon/features/notifications_v2/components/notification_with_status.tsx b/app/javascript/mastodon/features/notifications_v2/components/notification_with_status.tsx index a1c275a1f3..3e6428287d 100644 --- a/app/javascript/mastodon/features/notifications_v2/components/notification_with_status.tsx +++ b/app/javascript/mastodon/features/notifications_v2/components/notification_with_status.tsx @@ -13,6 +13,7 @@ import { import type { IconProp } from 'mastodon/components/icon'; import { Icon } from 'mastodon/components/icon'; import Status from 'mastodon/containers/status_container'; +import { getStatusHidden } from 'mastodon/selectors/filters'; import { useAppSelector, useAppDispatch } from 'mastodon/store'; import { DisplayedName } from './displayed_name'; @@ -48,6 +49,12 @@ export const NotificationWithStatus: React.FC<{ (state) => state.statuses.getIn([statusId, 'visibility']) === 'direct', ); + const isFiltered = useAppSelector( + (state) => + statusId && + getStatusHidden(state, { id: statusId, contextType: 'notifications' }), + ); + const handlers = useMemo( () => ({ open: () => { @@ -73,7 +80,7 @@ export const NotificationWithStatus: React.FC<{ [dispatch, statusId], ); - if (!statusId) return null; + if (!statusId || isFiltered) return null; return ( diff --git a/app/javascript/mastodon/selectors/filters.ts b/app/javascript/mastodon/selectors/filters.ts new file mode 100644 index 0000000000..f84d01216a --- /dev/null +++ b/app/javascript/mastodon/selectors/filters.ts @@ -0,0 +1,50 @@ +import { createSelector } from '@reduxjs/toolkit'; + +import type { RootState } from 'mastodon/store'; +import { toServerSideType } from 'mastodon/utils/filters'; + +// TODO: move to `app/javascript/mastodon/models` and use more globally +type Filter = Immutable.Map; + +// TODO: move to `app/javascript/mastodon/models` and use more globally +type FilterResult = Immutable.Map; + +export const getFilters = createSelector( + [ + (state: RootState) => state.filters as Immutable.Map, + (_, { contextType }: { contextType: string }) => contextType, + ], + (filters, contextType) => { + if (!contextType) { + return null; + } + + const now = new Date(); + const serverSideType = toServerSideType(contextType); + + return filters.filter((filter) => { + const context = filter.get('context') as Immutable.List; + const expiration = filter.get('expires_at') as Date | null; + return ( + context.includes(serverSideType) && + (expiration === null || expiration > now) + ); + }); + }, +); + +export const getStatusHidden = ( + state: RootState, + { id, contextType }: { id: string; contextType: string }, +) => { + const filters = getFilters(state, { contextType }); + if (filters === null) return false; + + const filtered = state.statuses.getIn([id, 'filtered']) as + | Immutable.List + | undefined; + return filtered?.some( + (result) => + filters.getIn([result.get('filter'), 'filter_action']) === 'hide', + ); +}; diff --git a/app/javascript/mastodon/selectors/index.js b/app/javascript/mastodon/selectors/index.js index 10e1b167ca..345ceac49a 100644 --- a/app/javascript/mastodon/selectors/index.js +++ b/app/javascript/mastodon/selectors/index.js @@ -1,23 +1,12 @@ import { createSelector } from '@reduxjs/toolkit'; import { List as ImmutableList, Map as ImmutableMap } from 'immutable'; -import { toServerSideType } from 'mastodon/utils/filters'; - import { me } from '../initial_state'; +import { getFilters } from './filters'; + export { makeGetAccount } from "./accounts"; -const getFilters = createSelector([state => state.get('filters'), (_, { contextType }) => contextType], (filters, contextType) => { - if (!contextType) { - return null; - } - - const now = new Date(); - const serverSideType = toServerSideType(contextType); - - return filters.filter(filter => filter.get('context').includes(serverSideType) && (filter.get('expires_at') === null || filter.get('expires_at') > now)); -}); - export const makeGetStatus = () => { return createSelector( [ From e018e6321feb97609b18ac61d3349beb6de170b5 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Oct 2024 15:42:08 +0200 Subject: [PATCH 09/13] =?UTF-8?q?Fix=20=E2=80=9CMark=20every=20notificatio?= =?UTF-8?q?n=20as=20read=E2=80=9D=20not=20updating=20the=20read=20marker?= =?UTF-8?q?=20if=20scrolled=20down=20(#32385)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/javascript/mastodon/reducers/notification_groups.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/reducers/notification_groups.ts b/app/javascript/mastodon/reducers/notification_groups.ts index 8b033f0fc7..91e91d7549 100644 --- a/app/javascript/mastodon/reducers/notification_groups.ts +++ b/app/javascript/mastodon/reducers/notification_groups.ts @@ -559,7 +559,10 @@ export const notificationGroupsReducer = createReducer( compareId(state.lastReadId, mostRecentGroup.page_max_id) < 0 ) state.lastReadId = mostRecentGroup.page_max_id; - commitLastReadId(state); + + // We don't call `commitLastReadId`, because that is conditional + // and we want to unconditionally update the state instead. + state.readMarkerId = state.lastReadId; }) .addCase(fetchMarkers.fulfilled, (state, action) => { if ( From a295832960f3a782b928145279af335f956fff1f Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 10 Oct 2024 16:53:12 +0200 Subject: [PATCH 10/13] Fix mute duration not being shown in list of muted accounts in web UI (#32388) --- app/javascript/mastodon/api_types/accounts.ts | 11 ++++++++++- app/javascript/mastodon/models/account.ts | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/javascript/mastodon/api_types/accounts.ts b/app/javascript/mastodon/api_types/accounts.ts index 5bf3e64288..fdbd7523fc 100644 --- a/app/javascript/mastodon/api_types/accounts.ts +++ b/app/javascript/mastodon/api_types/accounts.ts @@ -13,7 +13,7 @@ export interface ApiAccountRoleJSON { } // See app/serializers/rest/account_serializer.rb -export interface ApiAccountJSON { +export interface BaseApiAccountJSON { acct: string; avatar: string; avatar_static: string; @@ -45,3 +45,12 @@ export interface ApiAccountJSON { memorial?: boolean; hide_collections: boolean; } + +// See app/serializers/rest/muted_account_serializer.rb +export interface ApiMutedAccountJSON extends BaseApiAccountJSON { + mute_expires_at?: string | null; +} + +// For now, we have the same type representing both `Account` and `MutedAccount` +// objects, but we should refactor this in the future. +export type ApiAccountJSON = ApiMutedAccountJSON; diff --git a/app/javascript/mastodon/models/account.ts b/app/javascript/mastodon/models/account.ts index a04ebe6291..8e8e3b0e8d 100644 --- a/app/javascript/mastodon/models/account.ts +++ b/app/javascript/mastodon/models/account.ts @@ -95,6 +95,9 @@ export const accountDefaultValues: AccountShape = { limited: false, moved: null, hide_collections: false, + // This comes from `ApiMutedAccountJSON`, but we should eventually + // store that in a different object. + mute_expires_at: null, }; const AccountFactory = ImmutableRecord(accountDefaultValues); From 81472396bc581992b8818a3d01c06778b462c42e Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Oct 2024 11:19:48 +0200 Subject: [PATCH 11/13] Add note about not changing ActiveRecord encryption secrets once they are set (#32413) --- lib/tasks/db.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index d8bc927bc4..79599bd917 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -8,7 +8,7 @@ namespace :db do desc 'Generate a set of keys for configuring Active Record encryption in a given environment' task :init do # rubocop:disable Rails/RakeEnvironment puts <<~MSG - Add these secret environment variables to your Mastodon environment (e.g. .env.production):#{' '} + Add the following secret environment variables to your Mastodon environment (e.g. .env.production), ensure they are shared across all your nodes and do not change them after they are set:#{' '} ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=#{SecureRandom.alphanumeric(32)} ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=#{SecureRandom.alphanumeric(32)} From 799f507dce2f41b76990cc568410704a22c54837 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Oct 2024 12:24:03 +0200 Subject: [PATCH 12/13] Fix language of push notifications (#32415) --- app/workers/web/push_notification_worker.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb index 104503f130..e771928ef3 100644 --- a/app/workers/web/push_notification_worker.rb +++ b/app/workers/web/push_notification_worker.rb @@ -55,12 +55,8 @@ class Web::PushNotificationWorker end def push_notification_json - Oj.dump(serialized_notification_in_subscription_locale.as_json) - end - - def serialized_notification_in_subscription_locale I18n.with_locale(@subscription.locale.presence || I18n.default_locale) do - serialized_notification + Oj.dump(serialized_notification.as_json) end end From f99da81ef8b14a851347503d4177f83322c16d9a Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 11 Oct 2024 16:16:37 +0200 Subject: [PATCH 13/13] Add tag with commit hash to PR image builds (#32418) --- .github/workflows/build-push-pr.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-push-pr.yml b/.github/workflows/build-push-pr.yml index 72baed5121..d3bc8e5df8 100644 --- a/.github/workflows/build-push-pr.yml +++ b/.github/workflows/build-push-pr.yml @@ -21,9 +21,11 @@ jobs: uses: actions/checkout@v4 - id: version_vars run: | - echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT + echo mastodon_version_metadata=pr-${{ github.event.pull_request.number }}-$(git rev-parse --short ${{github.event.pull_request.head.sha}}) >> $GITHUB_OUTPUT + echo mastodon_short_sha=$(git rev-parse --short ${{github.event.pull_request.head.sha}}) >> $GITHUB_OUTPUT outputs: metadata: ${{ steps.version_vars.outputs.mastodon_version_metadata }} + short_sha: ${{ steps.version_vars.outputs.mastodon_short_sha }} build-image: needs: compute-suffix @@ -39,6 +41,7 @@ jobs: latest=auto tags: | type=ref,event=pr + type=ref,event=pr,suffix=-${{ needs.compute-suffix.outputs.short_sha }} secrets: inherit build-image-streaming: @@ -55,4 +58,5 @@ jobs: latest=auto tags: | type=ref,event=pr + type=ref,event=pr,suffix=-${{ needs.compute-suffix.outputs.short_sha }} secrets: inherit