Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream 20240628 #766

Merged
merged 41 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3f81e7d
chore(deps): update dependency @types/http-link-header to v1.0.6 (#30…
renovate[bot] Jun 24, 2024
6d14cfb
Unset Rails/UnusedIgnoredColumns (#30800)
nschonni Jun 24, 2024
b371009
chore(deps): update dependency opentelemetry-instrumentation-faraday …
renovate[bot] Jun 24, 2024
54cc204
Use WebSocketServer instead of WebSocket.Server in streaming (#30788)
TheEssem Jun 24, 2024
1af6313
Fix CMD syntax in streaming Dockerfile (#30795)
TheEssem Jun 24, 2024
61722b1
New Crowdin Translations (automated) (#30808)
github-actions[bot] Jun 24, 2024
8827cd5
Fix `/admin/accounts/:account_id/statuses/:id` for edited posts with …
ClearlyClaire Jun 24, 2024
f6e4660
Added check for STATSD_ADDR setting to emit a warning and proceed rat…
timothyjrogers Jun 24, 2024
39d80e8
Remove `lockfileMaintenance` setting (#30799)
mjankowski Jun 24, 2024
6527d50
Disable `Rails/BulkChangeTable` cop (#30820)
mjankowski Jun 24, 2024
052c90b
New Crowdin Translations (automated) (#30825)
github-actions[bot] Jun 25, 2024
30ae595
Fix: Ensure "With Media" is highlighted from Admin Accounts page (#30…
ThisIsMissEm Jun 25, 2024
3092748
chore(deps): update dependency aws-sdk-s3 to v1.153.0 (#30824)
renovate[bot] Jun 25, 2024
547e979
Change `apiRequest` to accept both `params` and `data` (#30818)
renchap Jun 25, 2024
8ef5972
Ignore intermittent chrome/manifest/icon interaction failure (#30793)
mjankowski Jun 25, 2024
845fe1c
Add the Interlingua locale (#30828)
renchap Jun 25, 2024
2c7eed1
Fix API requests after #30818 (#30837)
ClearlyClaire Jun 25, 2024
07d2226
chore(deps): update dependency typescript to v5.5.2 (#30815)
renovate[bot] Jun 25, 2024
a40831b
Fix account search results (#30803)
Gargron Jun 25, 2024
8c0ff64
Change light mode to apply CSS variables to the body (#30839)
renchap Jun 25, 2024
2b43c05
chore(deps): update dependency aws-sdk-s3 to v1.154.0 (#30838)
renovate[bot] Jun 26, 2024
7a84b76
Drop favicon.ico generation (#30375)
ClearlyClaire Jun 26, 2024
528a7f5
Fix `Rails/ReversibleMigration` cop for `change_column` (#30835)
mjankowski Jun 26, 2024
51f581e
Fix `Rails/ReversibleMigration` cop for `remove` (#30833)
mjankowski Jun 26, 2024
863c470
Convert `<Directory>` to Typescript / function component (#30829)
renchap Jun 26, 2024
e89317d
Add hover cards in web UI (#30754)
Gargron Jun 26, 2024
3939352
Convert `<ColumnHeader>` to Typescript (#30849)
Gargron Jun 26, 2024
ad53b0a
Rely on built-in ruby private IP detection (#30848)
mjankowski Jun 27, 2024
f6390c3
Use flatware to parallelize CI specs (#30284)
mjankowski Jun 27, 2024
6d1c1fd
New Crowdin Translations (automated) (#30851)
github-actions[bot] Jun 27, 2024
096057b
Change `author_account` to be `authors` in REST API (#30846)
Gargron Jun 27, 2024
42adb6e
Add size limit for link preview URLs (#30854)
oneiros Jun 27, 2024
ff08d99
Catch encoding errors when creating link previews. (#30853)
oneiros Jun 27, 2024
b15a361
Stub `Vips::Error` when not using libvips (#30857)
ClearlyClaire Jun 27, 2024
836c047
Use vips setting instead of env var in media processing spec (#30859)
mjankowski Jun 27, 2024
03bbb74
fix(deps): update dependency prom-client to v15.1.3 (#30852)
renovate[bot] Jun 27, 2024
bc3737f
Add detail about running version on vips error failure (#30858)
mjankowski Jun 27, 2024
3225954
Fix browser window color on light theme (#30861)
vmstan Jun 27, 2024
0f3fef6
Change search modifiers to be case-insensitive (#30865)
Gargron Jun 27, 2024
ea6c455
Fix follow button in hover cards not working when signed out in web U…
Gargron Jun 27, 2024
6955843
Merge remote-tracking branch 'parent/main' into upstream-20240628
kmycode Jun 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
// to `null` after any other rule set it to something.
dependencyDashboardHeader: 'This issue lists Renovate updates and detected dependencies. Read the [Dependency Dashboard](https://docs.renovatebot.com/key-concepts/dashboard/) docs to learn more. Before approving any upgrade: read the description and comments in the [`renovate.json5` file](https://github.com/mastodon/mastodon/blob/main/.github/renovate.json5).',
postUpdateOptions: ['yarnDedupeHighest'],
lockFileMaintenance: {
enabled: true,
},
packageRules: [
{
// Require Dependency Dashboard Approval for major version bumps of these node packages
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,17 @@ jobs:
additional-system-dependencies: ffmpeg libpam-dev

- name: Load database schema
run: './bin/rails db:create db:schema:load db:seed'
run: |
bin/rails db:setup
bin/flatware fan bin/rails db:test:prepare

- run: bin/rspec
- run: bin/flatware rspec -r ./spec/flatware_helper.rb

- name: Upload coverage reports to Codecov
if: matrix.ruby-version == '.ruby-version'
uses: codecov/codecov-action@v4
with:
files: coverage/lcov/mastodon.lcov
files: coverage/lcov/*.lcov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
6 changes: 3 additions & 3 deletions .rubocop/rails.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
---
Rails/BulkChangeTable:
Enabled: false # Conflicts with strong_migrations features

Rails/FilePath:
EnforcedStyle: arguments

Expand All @@ -18,6 +21,3 @@ Rails/RakeEnvironment:

Rails/SkipsModelValidations:
Enabled: false

Rails/UnusedIgnoredColumns:
Enabled: false # Preserve ability to migrate from arbitrary old versions
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ gem 'json-ld'
gem 'json-ld-preloaded', '~> 3.2'
gem 'rdf-normalize', '~> 0.5'

gem 'private_address_check', '~> 0.5'

gem 'opentelemetry-api', '~> 1.2.5'

group :opentelemetry do
Expand All @@ -123,6 +121,9 @@ group :opentelemetry do
end

group :test do
# Enable usage of all available CPUs/cores during spec runs
gem 'flatware-rspec'

# Adds RSpec Error/Warning annotations to GitHub PRs on the Files tab
gem 'rspec-github', '~> 2.4', require: false

Expand Down
26 changes: 17 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ GEM
attr_required (1.0.2)
awrence (1.2.1)
aws-eventstream (1.3.0)
aws-partitions (1.940.0)
aws-sdk-core (3.197.0)
aws-partitions (1.947.0)
aws-sdk-core (3.199.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.83.0)
aws-sdk-core (~> 3, >= 3.197.0)
aws-sdk-kms (1.87.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.152.3)
aws-sdk-core (~> 3, >= 3.197.0)
aws-sdk-s3 (1.154.0)
aws-sdk-core (~> 3, >= 3.199.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.8)
aws-sigv4 (1.8.0)
Expand Down Expand Up @@ -264,6 +264,11 @@ GEM
ffi-compiler (1.3.2)
ffi (>= 1.15.5)
rake
flatware (2.3.2)
thor (< 2.0)
flatware-rspec (2.3.2)
flatware (= 2.3.2)
rspec (>= 3.6)
fog-core (2.4.0)
builder
excon (~> 0.71)
Expand Down Expand Up @@ -532,7 +537,7 @@ GEM
opentelemetry-instrumentation-excon (0.22.3)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-faraday (0.24.4)
opentelemetry-instrumentation-faraday (0.24.5)
opentelemetry-api (~> 1.0)
opentelemetry-instrumentation-base (~> 0.22.1)
opentelemetry-instrumentation-http (0.23.3)
Expand Down Expand Up @@ -595,7 +600,6 @@ GEM
actionmailer (>= 3)
net-smtp
premailer (~> 1.7, >= 1.7.9)
private_address_check (0.5.0)
propshaft (0.9.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
Expand Down Expand Up @@ -701,6 +705,10 @@ GEM
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.2.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.1)
Expand Down Expand Up @@ -933,6 +941,7 @@ DEPENDENCIES
faker (~> 3.2)
fast_blank (~> 1.0)
fastimage
flatware-rspec
fog-core (<= 2.4.0)
fog-openstack (~> 1.0)
fuubar (~> 2.5)
Expand Down Expand Up @@ -994,7 +1003,6 @@ DEPENDENCIES
pg (~> 1.5)
pghero
premailer-rails
private_address_check (~> 0.5)
propshaft
public_suffix (~> 6.0)
puma (~> 6.3)
Expand Down
61 changes: 61 additions & 0 deletions app/javascript/hooks/useLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useCallback } from 'react';

import { useHistory } from 'react-router-dom';

import { openURL } from 'mastodon/actions/search';
import { useAppDispatch } from 'mastodon/store';

const isMentionClick = (element: HTMLAnchorElement) =>
element.classList.contains('mention');

const isHashtagClick = (element: HTMLAnchorElement) =>
element.textContent?.[0] === '#' ||
element.previousSibling?.textContent?.endsWith('#');

export const useLinks = () => {
const history = useHistory();
const dispatch = useAppDispatch();

const handleHashtagClick = useCallback(
(element: HTMLAnchorElement) => {
const { textContent } = element;

if (!textContent) return;

history.push(`/tags/${textContent.replace(/^#/, '')}`);
},
[history],
);

const handleMentionClick = useCallback(
(element: HTMLAnchorElement) => {
dispatch(
openURL(element.href, history, () => {
window.location.href = element.href;
}),
);
},
[dispatch, history],
);

const handleClick = useCallback(
(e: React.MouseEvent) => {
const target = (e.target as HTMLElement).closest('a');

if (!target || e.button !== 0 || e.ctrlKey || e.metaKey) {
return;
}

if (isMentionClick(target)) {
e.preventDefault();
handleMentionClick(target);
} else if (isHashtagClick(target)) {
e.preventDefault();
handleHashtagClick(target);
}
},
[handleMentionClick, handleHashtagClick],
);

return handleClick;
};
29 changes: 29 additions & 0 deletions app/javascript/hooks/useTimeout.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useRef, useCallback, useEffect } from 'react';

export const useTimeout = () => {
const timeoutRef = useRef<ReturnType<typeof setTimeout>>();

const set = useCallback((callback: () => void, delay: number) => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
}

timeoutRef.current = setTimeout(callback, delay);
}, []);

const cancel = useCallback(() => {
if (timeoutRef.current) {
clearTimeout(timeoutRef.current);
timeoutRef.current = undefined;
}
}, []);

useEffect(
() => () => {
cancel();
},
[cancel],
);

return [set, cancel] as const;
};
62 changes: 0 additions & 62 deletions app/javascript/mastodon/actions/directory.js

This file was deleted.

37 changes: 37 additions & 0 deletions app/javascript/mastodon/actions/directory.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { List as ImmutableList } from 'immutable';

import { apiGetDirectory } from 'mastodon/api/directory';
import { createDataLoadingThunk } from 'mastodon/store/typed_functions';

import { fetchRelationships } from './accounts';
import { importFetchedAccounts } from './importer';

export const fetchDirectory = createDataLoadingThunk(
'directory/fetch',
async (params: Parameters<typeof apiGetDirectory>[0]) =>
apiGetDirectory(params),
(data, { dispatch }) => {
dispatch(importFetchedAccounts(data));
dispatch(fetchRelationships(data.map((x) => x.id)));

return { accounts: data };
},
);

export const expandDirectory = createDataLoadingThunk(
'directory/expand',
async (params: Parameters<typeof apiGetDirectory>[0], { getState }) => {
const loadedItems = getState().user_lists.getIn([
'directory',
'items',
]) as ImmutableList<unknown>;

return apiGetDirectory({ ...params, offset: loadedItems.size }, 20);
},
(data, { dispatch }) => {
dispatch(importFetchedAccounts(data));
dispatch(fetchRelationships(data.map((x) => x.id)));

return { accounts: data };
},
);
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/importer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export function importFetchedStatuses(statuses) {
pushUnique(polls, normalizePoll(status.poll, getState().getIn(['polls', status.poll.id])));
}

if (status.card?.author_account) {
pushUnique(accounts, status.card.author_account);
if (status.card) {
status.card.authors.forEach(author => author.account && pushUnique(accounts, author.account));
}
}

Expand Down
11 changes: 9 additions & 2 deletions app/javascript/mastodon/actions/importer/normalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ export function normalizeStatus(status, normalOldStatus) {
normalStatus.poll = status.poll.id;
}

if (status.card?.author_account) {
normalStatus.card = { ...status.card, author_account: status.card.author_account.id };
if (status.card) {
normalStatus.card = {
...status.card,
authors: status.card.authors.map(author => ({
...author,
accountId: author.account?.id,
account: undefined,
})),
};
}

if (status.filtered) {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/actions/trends.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const fetchTrendingLinks = () => (dispatch) => {
api()
.get('/api/v1/trends/links', { params: { limit: 20 } })
.then(({ data }) => {
dispatch(importFetchedAccounts(data.map(link => link.author_account).filter(account => !!account)));
dispatch(importFetchedAccounts(data.flatMap(link => link.authors.map(author => author.account)).filter(account => !!account)));
dispatch(fetchTrendingLinksSuccess(data));
})
.catch(err => dispatch(fetchTrendingLinksFail(err)));
Expand Down
Loading
Loading