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

Merge upstream changes up to d20a5c3ec9ed40a991245fe32d0acb6187dd48c4 #2720

Merged
merged 24 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a5c808e
Fix issue with post-create scripts failing on local docker (#28402)
juliusrajala May 24, 2024
6a75e1c
Fix `createDataLoadingThunk` to allow actions without arguments (#30439)
renchap May 27, 2024
404e203
chore(deps): update dependency simple_form to v5.3.1 (#30416)
renovate[bot] May 27, 2024
564ebfe
Remove hard reference from status pin validator spec (#30432)
mjankowski May 27, 2024
3750e80
Enable stricter Typescript options (#30435)
renchap May 27, 2024
1034f13
chore(deps): update devdependencies (non-major) (#30442)
renovate[bot] May 27, 2024
e5c3dc3
New Crowdin Translations (automated) (#30421)
github-actions[bot] May 27, 2024
1548064
chore(deps): update dependency @types/react to v18.3.3 (#30441)
renovate[bot] May 27, 2024
0ef5dc2
fix(deps): update dependency jsdom to v24.1.0 (#30431)
renovate[bot] May 27, 2024
87156f5
Enable Style/StringConcatenation (#30428)
nschonni May 27, 2024
c61e356
Add `Status::MEDIA_ATTACHMENTS_LIMIT` configuration constant (#30433)
mjankowski May 27, 2024
ed99923
chore(deps): update eslint (non-major) (#30444)
renovate[bot] May 27, 2024
32c30bf
New Crowdin Translations (automated) (#30452)
github-actions[bot] May 28, 2024
4a77e47
Consolidate account scopes for `LOWER` (index using) username/domain …
mjankowski May 28, 2024
128987e
Add support for `fediverse:creator` OpenGraph tag (#30398)
Gargron May 28, 2024
5d7d239
Fix leaking Elasticsearch connections in Sidekiq processes (#30450)
ClearlyClaire May 29, 2024
36fe8f8
Change `ids` param to `id` in `/api/v1/statuses` and `/api/v1/account…
ClearlyClaire May 29, 2024
4172931
chore(deps): update dependency faker to v3.4.1 (#30463)
renovate[bot] May 29, 2024
6eea832
New Crowdin Translations (automated) (#30464)
github-actions[bot] May 29, 2024
d20a5c3
Fix: remove broken OAuth Application vacuuming & throttle OAuth Appli…
ThisIsMissEm May 29, 2024
c827a98
Merge commit 'd20a5c3ec9ed40a991245fe32d0acb6187dd48c4' into glitch-s…
ClearlyClaire May 29, 2024
6b4c182
[Glitch] Fix `createDataLoadingThunk` to allow actions without arguments
renchap May 27, 2024
2e3d6e4
[Glitch] Enable stricter Typescript options
renchap May 27, 2024
4069fae
[Glitch] Add support for `fediverse:creator` OpenGraph tag
Gargron May 28, 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
1 change: 1 addition & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ version: '3'

services:
app:
working_dir: /workspaces/mastodon/
build:
context: .
dockerfile: Dockerfile
Expand Down
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,6 @@ Style/SafeNavigation:
Exclude:
- 'app/models/concerns/account/finder_concern.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Exclude:
- 'config/initializers/paperclip.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: WordRegex.
# SupportedStyles: percent, brackets
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ GEM
tzinfo
excon (0.110.0)
fabrication (2.31.0)
faker (3.3.1)
faker (3.4.1)
i18n (>= 1.8.11, < 2)
faraday (1.10.3)
faraday-em_http (~> 1.0)
Expand Down Expand Up @@ -425,7 +425,7 @@ GEM
mime-types-data (3.2024.0507)
mini_mime (1.1.5)
mini_portile2 (2.8.6)
minitest (5.23.0)
minitest (5.23.1)
msgpack (1.7.2)
multi_json (1.15.0)
multipart-post (2.4.0)
Expand Down Expand Up @@ -799,7 +799,7 @@ GEM
thor (>= 0.20, < 3.0)
simple-navigation (4.4.0)
activesupport (>= 2.3.2)
simple_form (5.3.0)
simple_form (5.3.1)
actionpack (>= 5.2)
activemodel (>= 5.2)
simplecov (0.22.0)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ def relationships(**options)
end

def account_ids
Array(accounts_params[:ids]).uniq.map(&:to_i)
Array(accounts_params[:id]).uniq.map(&:to_i)
end

def accounts_params
params.permit(ids: [])
params.permit(id: [])
end

def account_params
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/api/v1/conversations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def set_conversation
def paginated_conversations
AccountConversation.where(account: current_account)
.includes(
account: :account_stat,
account: [:account_stat, user: :role],
last_status: [
:media_attachments,
:status_stat,
:tags,
{
preview_cards_status: :preview_card,
active_mentions: [account: :account_stat],
account: :account_stat,
preview_cards_status: { preview_card: { author_account: [:account_stat, user: :role] } },
active_mentions: :account,
account: [:account_stat, user: :role],
},
]
)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ def check_statuses_limit
end

def status_ids
Array(statuses_params[:ids]).uniq.map(&:to_i)
Array(statuses_params[:id]).uniq.map(&:to_i)
end

def statuses_params
params.permit(ids: [])
params.permit(id: [])
end

def status_params
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/entrypoints/public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ window.addEventListener('message', (e) => {
{
type: 'setHeight',
id: data.id,
height: document.getElementsByTagName('html')[0].scrollHeight,
height: document.getElementsByTagName('html')[0]?.scrollHeight,
},
'*',
);
Expand Down Expand Up @@ -135,7 +135,7 @@ function loaded() {
);
};
const todayFormat = new IntlMessageFormat(
localeData['relative_format.today'] || 'Today at {time}',
localeData['relative_format.today'] ?? 'Today at {time}',
locale,
);

Expand Down Expand Up @@ -288,13 +288,13 @@ function loaded() {
if (statusEl.dataset.spoiler === 'expanded') {
statusEl.dataset.spoiler = 'folded';
this.textContent = new IntlMessageFormat(
localeData['status.show_more'] || 'Show more',
localeData['status.show_more'] ?? 'Show more',
locale,
).format() as string;
} else {
statusEl.dataset.spoiler = 'expanded';
this.textContent = new IntlMessageFormat(
localeData['status.show_less'] || 'Show less',
localeData['status.show_less'] ?? 'Show less',
locale,
).format() as string;
}
Expand All @@ -316,8 +316,8 @@ function loaded() {

const message =
statusEl.dataset.spoiler === 'expanded'
? localeData['status.show_less'] || 'Show less'
: localeData['status.show_more'] || 'Show more';
? localeData['status.show_less'] ?? 'Show less'
: localeData['status.show_more'] ?? 'Show more';
spoilerLink.textContent = new IntlMessageFormat(
message,
locale,
Expand Down
9 changes: 8 additions & 1 deletion app/javascript/entrypoints/remote_interaction_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const fetchInteractionURLFailure = () => {
);
};

const isValidDomain = (value: string) => {
const isValidDomain = (value: unknown) => {
if (typeof value !== 'string') return false;

const url = new URL('https:///path');
url.hostname = value;
return url.hostname === value;
Expand Down Expand Up @@ -124,6 +126,11 @@ const fromAcct = (acct: string) => {
const domain = segments[1];
const fallbackTemplate = `https://${domain}/authorize_interaction?uri={uri}`;

if (!domain) {
fetchInteractionURLFailure();
return;
}

axios
.get(`https://${domain}/.well-known/webfinger`, {
params: { resource: `acct:${acct}` },
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/flavours/glitch/components/animated_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ export const AnimatedNumber: React.FC<Props> = ({ value, obfuscate }) => {
<span
key={key}
style={{
position: direction * style.y > 0 ? 'absolute' : 'static',
transform: `translateY(${style.y * 100}%)`,
position:
direction * (style.y ?? 0) > 0 ? 'absolute' : 'static',
transform: `translateY(${(style.y ?? 0) * 100}%)`,
}}
>
{obfuscate ? (
Expand Down
7 changes: 5 additions & 2 deletions app/javascript/flavours/glitch/components/hashtag_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
);

return Object.values(groups).map((tags) => {
if (tags.length === 1) return tags[0];
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- we know that the array has at least one element
const firstTag = tags[0]!;

if (tags.length === 1) return firstTag;

// The best match is the one where we have the less difference between upper and lower case letter count
const best = minBy(tags, (tag) => {
Expand All @@ -66,7 +69,7 @@ function uniqueHashtagsWithCaseHandling(hashtags: string[]) {
return Math.abs(lowerCase - upperCase);
});

return best ?? tags[0];
return best ?? firstTag;
});
}

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/components/short_number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ShortNumberCounter: React.FC<ShortNumberCounterProps> = ({ value }) => {

const count = (
<FormattedNumber
value={rawNumber}
value={rawNumber ?? 0}
maximumFractionDigits={maxFractionDigits}
/>
);
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/flavours/glitch/entrypoints/public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ window.addEventListener('message', (e) => {
{
type: 'setHeight',
id: data.id,
height: document.getElementsByTagName('html')[0].scrollHeight,
height: document.getElementsByTagName('html')[0]?.scrollHeight,
},
'*',
);
Expand Down Expand Up @@ -135,7 +135,7 @@ function loaded() {
);
};
const todayFormat = new IntlMessageFormat(
localeData['relative_format.today'] || 'Today at {time}',
localeData['relative_format.today'] ?? 'Today at {time}',
locale,
);

Expand Down Expand Up @@ -288,13 +288,13 @@ function loaded() {
if (statusEl.dataset.spoiler === 'expanded') {
statusEl.dataset.spoiler = 'folded';
this.textContent = new IntlMessageFormat(
localeData['status.show_more'] || 'Show more',
localeData['status.show_more'] ?? 'Show more',
locale,
).format() as string;
} else {
statusEl.dataset.spoiler = 'expanded';
this.textContent = new IntlMessageFormat(
localeData['status.show_less'] || 'Show less',
localeData['status.show_less'] ?? 'Show less',
locale,
).format() as string;
}
Expand All @@ -316,8 +316,8 @@ function loaded() {

const message =
statusEl.dataset.spoiler === 'expanded'
? localeData['status.show_less'] || 'Show less'
: localeData['status.show_more'] || 'Show more';
? localeData['status.show_less'] ?? 'Show less'
: localeData['status.show_more'] ?? 'Show more';
spoilerLink.textContent = new IntlMessageFormat(
message,
locale,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ const fetchInteractionURLFailure = () => {
);
};

const isValidDomain = (value: string) => {
const isValidDomain = (value: unknown) => {
if (typeof value !== 'string') return false;

const url = new URL('https:///path');
url.hostname = value;
return url.hostname === value;
Expand Down Expand Up @@ -124,6 +126,11 @@ const fromAcct = (acct: string) => {
const domain = segments[1];
const fallbackTemplate = `https://${domain}/authorize_interaction?uri={uri}`;

if (!domain) {
fetchInteractionURLFailure();
return;
}

axios
.get(`https://${domain}/.well-known/webfinger`, {
params: { resource: `acct:${acct}` },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const emojis: Emojis = {};

// decompress
Object.keys(shortCodesToEmojiData).forEach((shortCode) => {
const [_filenameData, searchData] = shortCodesToEmojiData[shortCode];
const emojiData = shortCodesToEmojiData[shortCode];
if (!emojiData) return;

const [_filenameData, searchData] = emojiData;
const [native, short_names, search, unified] = searchData;

emojis[shortCode] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ function processEmojiMapData(
Object.keys(shortCodesToEmojiData).forEach(
(shortCode: ShortCodesToEmojiDataKey) => {
if (shortCode === undefined) return;
const [filenameData, _searchData] = shortCodesToEmojiData[shortCode];

const emojiData = shortCodesToEmojiData[shortCode];
if (!emojiData) return;
const [filenameData, _searchData] = emojiData;
filenameData.forEach((emojiMapData) => {
processEmojiMapData(emojiMapData, shortCode);
});
Expand Down
31 changes: 26 additions & 5 deletions app/javascript/flavours/glitch/features/status/components/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import DescriptionIcon from '@/material-icons/400-24px/description-fill.svg?react';
import OpenInNewIcon from '@/material-icons/400-24px/open_in_new.svg?react';
import PlayArrowIcon from '@/material-icons/400-24px/play_arrow-fill.svg?react';
import { Avatar } from 'flavours/glitch/components/avatar';
import { Blurhash } from 'flavours/glitch/components/blurhash';
import { Icon } from 'flavours/glitch/components/icon';
import { Permalink } from 'flavours/glitch/components/permalink';
import { RelativeTimestamp } from 'flavours/glitch/components/relative_timestamp';
import { useBlurhash } from 'flavours/glitch/initial_state';
import { decode as decodeIDNA } from 'flavours/glitch/utils/idna';
Expand Down Expand Up @@ -46,6 +48,20 @@ const addAutoPlay = html => {
return html;
};

const MoreFromAuthor = ({ author }) => (
<div className='more-from-author'>
<svg viewBox='0 0 79 79' className='logo logo--icon' role='img'>
<use xlinkHref='#logo-symbol-icon' />
</svg>

<FormattedMessage id='link_preview.more_from_author' defaultMessage='More from {name}' values={{ name: <Permalink href={author.get('url')} to={`/@${author.get('acct')}`}><Avatar account={author} size={16} /> {author.get('display_name')}</Permalink> }} />
</div>
);

MoreFromAuthor.propTypes = {
author: ImmutablePropTypes.map,
};

export default class Card extends PureComponent {

static propTypes = {
Expand Down Expand Up @@ -126,6 +142,7 @@ export default class Card extends PureComponent {
const interactive = card.get('type') === 'video';
const language = card.get('language') || '';
const largeImage = (card.get('image')?.length > 0 && card.get('width') > card.get('height')) || interactive;
const showAuthor = !!card.get('author_account');

const description = (
<div className='status-card__content'>
Expand All @@ -136,7 +153,7 @@ export default class Card extends PureComponent {

<strong className='status-card__title' title={card.get('title')} lang={language}>{card.get('title')}</strong>

{card.get('author_name').length > 0 ? <span className='status-card__author'><FormattedMessage id='link_preview.author' defaultMessage='By {name}' values={{ name: <strong>{card.get('author_name')}</strong> }} /></span> : <span className='status-card__description' lang={language}>{card.get('description')}</span>}
{!showAuthor && (card.get('author_name').length > 0 ? <span className='status-card__author'><FormattedMessage id='link_preview.author' defaultMessage='By {name}' values={{ name: <strong>{card.get('author_name')}</strong> }} /></span> : <span className='status-card__description' lang={language}>{card.get('description')}</span>)}
</div>
);

Expand Down Expand Up @@ -225,10 +242,14 @@ export default class Card extends PureComponent {
}

return (
<a href={card.get('url')} className={classNames('status-card', { expanded: largeImage })} target='_blank' rel='noopener noreferrer' ref={this.setRef}>
{embed}
{description}
</a>
<>
<a href={card.get('url')} className={classNames('status-card', { expanded: largeImage, bottomless: showAuthor })} target='_blank' rel='noopener noreferrer' ref={this.setRef}>
{embed}
{description}
</a>

{showAuthor && <MoreFromAuthor author={card.get('author_account')} />}
</>
);
}

Expand Down
5 changes: 3 additions & 2 deletions app/javascript/flavours/glitch/store/middlewares/sounds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ export const soundsMiddleware = (): Middleware<
if (isActionWithMetaSound(action)) {
const sound = action.meta.sound;

if (sound && Object.hasOwn(soundCache, sound)) {
play(soundCache[sound]);
if (sound) {
const s = soundCache[sound];
if (s) play(s);
}
}

Expand Down
Loading