Skip to content

Commit

Permalink
Merge commit 'f99da81ef8b14a851347503d4177f83322c16d9a' into glitch-s…
Browse files Browse the repository at this point in the history
…oc/stable-4.3
  • Loading branch information
ClearlyClaire committed Oct 14, 2024
2 parents 93fa102 + f99da81 commit b40adb4
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 80 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-push-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/build-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def dismiss_bulk
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)
)
Expand Down
11 changes: 10 additions & 1 deletion app/javascript/mastodon/api_types/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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: () => {
Expand All @@ -73,7 +80,7 @@ export const NotificationWithStatus: React.FC<{
[dispatch, statusId],
);

if (!statusId) return null;
if (!statusId || isFiltered) return null;

return (
<HotKeys handlers={handlers}>
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/mastodon/models/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AccountShape>(accountDefaultValues);
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/mastodon/reducers/notification_groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,10 @@ export const notificationGroupsReducer = createReducer<NotificationGroupsState>(
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 (
Expand Down
50 changes: 50 additions & 0 deletions app/javascript/mastodon/selectors/filters.ts
Original file line number Diff line number Diff line change
@@ -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<string, unknown>;

// TODO: move to `app/javascript/mastodon/models` and use more globally
type FilterResult = Immutable.Map<string, unknown>;

export const getFilters = createSelector(
[
(state: RootState) => state.filters as Immutable.Map<string, Filter>,
(_, { 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<string>;
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<FilterResult>
| undefined;
return filtered?.some(
(result) =>
filters.getIn([result.get('filter'), 'filter_action']) === 'hide',
);
};
15 changes: 2 additions & 13 deletions app/javascript/mastodon/selectors/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
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';

export { makeGetAccount } from "./accounts";

const getFilters = createSelector([state => state.get('filters'), (_, { contextType }) => contextType], (filters, contextType) => {
if (!contextType) {
return null;
}
import { getFilters } from './filters';

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 { makeGetAccount } from "./accounts";

export const makeGetStatus = () => {
return createSelector(
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/styles/mastodon/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,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);
Expand Down
84 changes: 37 additions & 47 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -7988,18 +7988,50 @@ 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%;
}
}

.list-adder {
&__lists {
height: 50vh;
border-radius: 0 0 8px 8px;
overflow-y: auto;
}

.list {
padding: 10px;
border-bottom: 1px solid var(--background-border-color);
}

.list__wrapper {
display: flex;
}

.list__display-name {
flex: 1 1 auto;
overflow: hidden;
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%);
Expand All @@ -8011,12 +8043,10 @@ noscript {

.drawer__pager {
height: 50vh;
border-radius: 4px;
border: 0;
}

.drawer__inner {
border-radius: 0 0 8px 8px;

&.backdrop {
width: calc(100% - 60px);
box-shadow: 2px 4px 15px rgba($base-shadow-color, 0.4);
Expand All @@ -8025,6 +8055,7 @@ noscript {
}

&__accounts {
background: unset;
overflow-y: auto;
}

Expand All @@ -8043,47 +8074,6 @@ noscript {
}
}

.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;
}

.list {
padding: 10px;
border-bottom: 1px solid var(--background-border-color);
}

.list__wrapper {
display: flex;
}

.list__display-name {
flex: 1 1 auto;
overflow: hidden;
text-decoration: none;
font-size: 16px;
padding: 10px;
}
}

.focal-point {
position: relative;
cursor: move;
Expand Down
2 changes: 1 addition & 1 deletion app/models/notification_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ def filter_private_mentions=(value)
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
2 changes: 2 additions & 0 deletions app/models/notification_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions app/workers/web/push_notification_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,8 @@ def web_push_request
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

Expand Down
2 changes: 1 addition & 1 deletion lib/mastodon/cli/ip_blocks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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'
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/db.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
Loading

0 comments on commit b40adb4

Please sign in to comment.