Skip to content

Commit ca204e6

Browse files
Merge pull request #3014 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes up to aa57534
2 parents d5d5501 + d5ff3ee commit ca204e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+188
-71
lines changed

.rubocop_todo.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp`
3-
# using RuboCop version 1.73.2.
3+
# using RuboCop version 1.75.0.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -45,7 +45,7 @@ Style/FetchEnvVar:
4545
- 'lib/tasks/repo.rake'
4646

4747
# This cop supports safe autocorrection (--autocorrect).
48-
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns.
48+
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
4949
# SupportedStyles: annotated, template, unannotated
5050
# AllowedMethods: redirect
5151
Style/FormatStringToken:
@@ -73,7 +73,6 @@ Style/MapToHash:
7373
# AllowedMethods: respond_to_missing?
7474
Style/OptionalBooleanParameter:
7575
Exclude:
76-
- 'app/helpers/json_ld_helper.rb'
7776
- 'app/lib/admin/system_check/message.rb'
7877
- 'app/lib/request.rb'
7978
- 'app/lib/webfinger.rb'

Gemfile.lock

+7-5
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ GEM
580580
ox (2.14.22)
581581
bigdecimal (>= 3.0)
582582
parallel (1.26.3)
583-
parser (3.3.7.2)
583+
parser (3.3.7.3)
584584
ast (~> 2.4.1)
585585
racc
586586
parslet (2.0.0)
@@ -600,6 +600,7 @@ GEM
600600
net-smtp
601601
premailer (~> 1.7, >= 1.7.9)
602602
prettyprint (0.2.0)
603+
prism (1.4.0)
603604
prometheus_exporter (2.2.0)
604605
webrick
605606
propshaft (1.1.0)
@@ -733,19 +734,20 @@ GEM
733734
rspec-mocks (~> 3.0)
734735
sidekiq (>= 5, < 9)
735736
rspec-support (3.13.2)
736-
rubocop (1.74.0)
737+
rubocop (1.75.1)
737738
json (~> 2.3)
738739
language_server-protocol (~> 3.17.0.2)
739740
lint_roller (~> 1.1.0)
740741
parallel (~> 1.10)
741742
parser (>= 3.3.0.2)
742743
rainbow (>= 2.2.2, < 4.0)
743744
regexp_parser (>= 2.9.3, < 3.0)
744-
rubocop-ast (>= 1.38.0, < 2.0)
745+
rubocop-ast (>= 1.43.0, < 2.0)
745746
ruby-progressbar (~> 1.7)
746747
unicode-display_width (>= 2.4.0, < 4.0)
747-
rubocop-ast (1.38.1)
748-
parser (>= 3.3.1.0)
748+
rubocop-ast (1.43.0)
749+
parser (>= 3.3.7.2)
750+
prism (~> 1.4)
749751
rubocop-capybara (2.22.1)
750752
lint_roller (~> 1.1)
751753
rubocop (~> 1.72, >= 1.72.1)

app/javascript/flavours/glitch/components/edited_timestamp/index.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FormattedMessage, injectIntl } from 'react-intl';
66
import { connect } from 'react-redux';
77

88
import { openModal } from 'flavours/glitch/actions/modal';
9+
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
910
import InlineAccount from 'flavours/glitch/components/inline_account';
1011
import { RelativeTimestamp } from 'flavours/glitch/components/relative_timestamp';
1112

@@ -60,12 +61,12 @@ class EditedTimestamp extends PureComponent {
6061
};
6162

6263
render () {
63-
const { timestamp, intl, statusId } = this.props;
64+
const { timestamp, statusId } = this.props;
6465

6566
return (
6667
<DropdownMenu statusId={statusId} renderItem={this.renderItem} scrollable renderHeader={this.renderHeader} onItemClick={this.handleItemClick}>
6768
<button className='dropdown-menu__text-button'>
68-
<FormattedMessage id='status.edited' defaultMessage='Edited {date}' values={{ date: <span className='animated-number'>{intl.formatDate(timestamp, { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' })}</span> }} />
69+
<FormattedMessage id='status.edited' defaultMessage='Edited {date}' values={{ date: <FormattedDateWrapper className='animated-number' value={timestamp} month='short' day='2-digit' hour='2-digit' minute='2-digit' /> }} />
6970
</button>
7071
</DropdownMenu>
7172
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { ComponentProps } from 'react';
2+
3+
import { FormattedDate } from 'react-intl';
4+
5+
export const FormattedDateWrapper = (
6+
props: ComponentProps<typeof FormattedDate> & { className?: string },
7+
) => (
8+
<FormattedDate {...props}>
9+
{(date) => (
10+
<time dateTime={tryIsoString(props.value)} className={props.className}>
11+
{date}
12+
</time>
13+
)}
14+
</FormattedDate>
15+
);
16+
17+
const tryIsoString = (date?: string | number | Date): string => {
18+
if (!date) {
19+
return '';
20+
}
21+
try {
22+
return new Date(date).toISOString();
23+
} catch {
24+
return date.toString();
25+
}
26+
};

app/javascript/flavours/glitch/features/account_timeline/components/account_header.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
} from 'flavours/glitch/components/badge';
3737
import { Button } from 'flavours/glitch/components/button';
3838
import { CopyIconButton } from 'flavours/glitch/components/copy_icon_button';
39+
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
3940
import { Icon } from 'flavours/glitch/components/icon';
4041
import { IconButton } from 'flavours/glitch/components/icon_button';
4142
import { LoadingIndicator } from 'flavours/glitch/components/loading_indicator';
@@ -951,11 +952,12 @@ export const AccountHeader: React.FC<{
951952
/>
952953
</dt>
953954
<dd>
954-
{intl.formatDate(account.created_at, {
955-
year: 'numeric',
956-
month: 'short',
957-
day: '2-digit',
958-
})}
955+
<FormattedDateWrapper
956+
value={account.created_at}
957+
year='numeric'
958+
month='short'
959+
day='2-digit'
960+
/>
959961
</dd>
960962
</dl>
961963

app/javascript/flavours/glitch/features/privacy_policy/index.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { useState, useEffect } from 'react';
22

3-
import {
4-
FormattedMessage,
5-
FormattedDate,
6-
useIntl,
7-
defineMessages,
8-
} from 'react-intl';
3+
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
94

105
import { Helmet } from 'react-helmet';
116

127
import { apiGetPrivacyPolicy } from 'flavours/glitch/api/instance';
138
import type { ApiPrivacyPolicyJSON } from 'flavours/glitch/api_types/instance';
149
import { Column } from 'flavours/glitch/components/column';
10+
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
1511
import { Skeleton } from 'flavours/glitch/components/skeleton';
1612

1713
const messages = defineMessages({
@@ -58,7 +54,7 @@ const PrivacyPolicy: React.FC<{
5854
date: loading ? (
5955
<Skeleton width='10ch' />
6056
) : (
61-
<FormattedDate
57+
<FormattedDateWrapper
6258
value={response?.updated_at}
6359
year='numeric'
6460
month='short'

app/javascript/flavours/glitch/features/status/components/detailed_status.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { CSSProperties } from 'react';
77
import React, { useState, useRef, useCallback } from 'react';
88

9-
import { FormattedDate, FormattedMessage } from 'react-intl';
9+
import { FormattedMessage } from 'react-intl';
1010

1111
import classNames from 'classnames';
1212
import { Link } from 'react-router-dom';
@@ -16,6 +16,7 @@ import AttachmentList from 'flavours/glitch/components/attachment_list';
1616
import { ContentWarning } from 'flavours/glitch/components/content_warning';
1717
import EditedTimestamp from 'flavours/glitch/components/edited_timestamp';
1818
import { FilterWarning } from 'flavours/glitch/components/filter_warning';
19+
import { FormattedDateWrapper } from 'flavours/glitch/components/formatted_date';
1920
import type { StatusLike } from 'flavours/glitch/components/hashtag_bar';
2021
import { getHashtagBarForStatus } from 'flavours/glitch/components/hashtag_bar';
2122
import { IconLogo } from 'flavours/glitch/components/logo';
@@ -413,7 +414,7 @@ export const DetailedStatus: React.FC<{
413414
target='_blank'
414415
rel='noopener noreferrer'
415416
>
416-
<FormattedDate
417+
<FormattedDateWrapper
417418
value={new Date(status.get('created_at') as string)}
418419
year='numeric'
419420
month='short'

app/javascript/mastodon/components/edited_timestamp/index.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { FormattedMessage, injectIntl } from 'react-intl';
66
import { connect } from 'react-redux';
77

88
import { openModal } from 'mastodon/actions/modal';
9+
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
910
import InlineAccount from 'mastodon/components/inline_account';
1011
import { RelativeTimestamp } from 'mastodon/components/relative_timestamp';
1112

@@ -60,12 +61,12 @@ class EditedTimestamp extends PureComponent {
6061
};
6162

6263
render () {
63-
const { timestamp, intl, statusId } = this.props;
64+
const { timestamp, statusId } = this.props;
6465

6566
return (
6667
<DropdownMenu statusId={statusId} renderItem={this.renderItem} scrollable renderHeader={this.renderHeader} onItemClick={this.handleItemClick}>
6768
<button className='dropdown-menu__text-button'>
68-
<FormattedMessage id='status.edited' defaultMessage='Edited {date}' values={{ date: <span className='animated-number'>{intl.formatDate(timestamp, { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit' })}</span> }} />
69+
<FormattedMessage id='status.edited' defaultMessage='Edited {date}' values={{ date: <FormattedDateWrapper className='animated-number' value={timestamp} month='short' day='2-digit' hour='2-digit' minute='2-digit' /> }} />
6970
</button>
7071
</DropdownMenu>
7172
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { ComponentProps } from 'react';
2+
3+
import { FormattedDate } from 'react-intl';
4+
5+
export const FormattedDateWrapper = (
6+
props: ComponentProps<typeof FormattedDate> & { className?: string },
7+
) => (
8+
<FormattedDate {...props}>
9+
{(date) => (
10+
<time dateTime={tryIsoString(props.value)} className={props.className}>
11+
{date}
12+
</time>
13+
)}
14+
</FormattedDate>
15+
);
16+
17+
const tryIsoString = (date?: string | number | Date): string => {
18+
if (!date) {
19+
return '';
20+
}
21+
try {
22+
return new Date(date).toISOString();
23+
} catch {
24+
return date.toString();
25+
}
26+
};

app/javascript/mastodon/features/account_timeline/components/account_header.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
FollowingCounter,
3838
StatusesCounter,
3939
} from 'mastodon/components/counters';
40+
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
4041
import { Icon } from 'mastodon/components/icon';
4142
import { IconButton } from 'mastodon/components/icon_button';
4243
import { LoadingIndicator } from 'mastodon/components/loading_indicator';
@@ -938,11 +939,12 @@ export const AccountHeader: React.FC<{
938939
/>
939940
</dt>
940941
<dd>
941-
{intl.formatDate(account.created_at, {
942-
year: 'numeric',
943-
month: 'short',
944-
day: '2-digit',
945-
})}
942+
<FormattedDateWrapper
943+
value={account.created_at}
944+
year='numeric'
945+
month='short'
946+
day='2-digit'
947+
/>
946948
</dd>
947949
</dl>
948950

app/javascript/mastodon/features/privacy_policy/index.tsx

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { useState, useEffect } from 'react';
22

3-
import {
4-
FormattedMessage,
5-
FormattedDate,
6-
useIntl,
7-
defineMessages,
8-
} from 'react-intl';
3+
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
94

105
import { Helmet } from 'react-helmet';
116

127
import { apiGetPrivacyPolicy } from 'mastodon/api/instance';
138
import type { ApiPrivacyPolicyJSON } from 'mastodon/api_types/instance';
149
import { Column } from 'mastodon/components/column';
10+
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
1511
import { Skeleton } from 'mastodon/components/skeleton';
1612

1713
const messages = defineMessages({
@@ -58,7 +54,7 @@ const PrivacyPolicy: React.FC<{
5854
date: loading ? (
5955
<Skeleton width='10ch' />
6056
) : (
61-
<FormattedDate
57+
<FormattedDateWrapper
6258
value={response?.updated_at}
6359
year='numeric'
6460
month='short'

app/javascript/mastodon/features/status/components/detailed_status.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { CSSProperties } from 'react';
77
import { useState, useRef, useCallback } from 'react';
88

9-
import { FormattedDate, FormattedMessage } from 'react-intl';
9+
import { FormattedMessage } from 'react-intl';
1010

1111
import classNames from 'classnames';
1212
import { Link } from 'react-router-dom';
@@ -16,6 +16,7 @@ import { AnimatedNumber } from 'mastodon/components/animated_number';
1616
import { ContentWarning } from 'mastodon/components/content_warning';
1717
import EditedTimestamp from 'mastodon/components/edited_timestamp';
1818
import { FilterWarning } from 'mastodon/components/filter_warning';
19+
import { FormattedDateWrapper } from 'mastodon/components/formatted_date';
1920
import type { StatusLike } from 'mastodon/components/hashtag_bar';
2021
import { getHashtagBarForStatus } from 'mastodon/components/hashtag_bar';
2122
import { Icon } from 'mastodon/components/icon';
@@ -388,7 +389,7 @@ export const DetailedStatus: React.FC<{
388389
target='_blank'
389390
rel='noopener noreferrer'
390391
>
391-
<FormattedDate
392+
<FormattedDateWrapper
392393
value={new Date(status.get('created_at') as string)}
393394
year='numeric'
394395
month='short'

app/javascript/mastodon/locales/fr-CA.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"block_modal.show_less": "Afficher moins",
120120
"block_modal.show_more": "Afficher plus",
121121
"block_modal.they_cant_mention": "Il ne peut pas vous mentionner ou vous suivre.",
122-
"block_modal.they_cant_see_posts": "Il peut toujours voir vos messages, mais vous ne verrez pas les siens.",
122+
"block_modal.they_cant_see_posts": "Il ne peut plus voir vos messages et vous ne verrez plus les siens.",
123123
"block_modal.they_will_know": "Il peut voir qu'il est bloqué.",
124124
"block_modal.title": "Bloquer le compte ?",
125125
"block_modal.you_wont_see_mentions": "Vous ne verrez pas les messages qui le mentionne.",

app/javascript/mastodon/locales/fr.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"block_modal.show_less": "Afficher moins",
120120
"block_modal.show_more": "Afficher plus",
121121
"block_modal.they_cant_mention": "Il ne peut pas vous mentionner ou vous suivre.",
122-
"block_modal.they_cant_see_posts": "Il peut toujours voir vos messages, mais vous ne verrez pas les siens.",
122+
"block_modal.they_cant_see_posts": "Il ne peut plus voir vos messages et vous ne verrez plus les siens.",
123123
"block_modal.they_will_know": "Il peut voir qu'il est bloqué.",
124124
"block_modal.title": "Bloquer le compte ?",
125125
"block_modal.you_wont_see_mentions": "Vous ne verrez pas les messages qui le mentionne.",

app/javascript/mastodon/locales/ko.json

+1
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,7 @@
874874
"tabs_bar.notifications": "알림",
875875
"terms_of_service.effective_as_of": "{date}부터 적용됨",
876876
"terms_of_service.title": "이용 약관",
877+
"terms_of_service.upcoming_changes_on": "{date}에 예정된 변경사항",
877878
"time_remaining.days": "{number} 일 남음",
878879
"time_remaining.hours": "{number} 시간 남음",
879880
"time_remaining.minutes": "{number} 분 남음",

app/lib/request.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def open(host, *args)
260260
outer_e = nil
261261
port = args.first
262262

263-
addresses = [] # rubocop:disable Lint/UselessAssignment -- TODO: https://github.com/rubocop/rubocop/issues/13395
263+
addresses = []
264264
begin
265265
addresses = [IPAddr.new(host)]
266266
rescue IPAddr::InvalidAddressError

app/models/trends/links.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ def trend_class
3333
def register(status, at_time = Time.now.utc)
3434
original_status = status.proper
3535

36-
return unless (original_status.public_visibility? && status.public_visibility?) &&
36+
return unless original_status.public_visibility? &&
37+
status.public_visibility? &&
3738
!(original_status.account.silenced? || status.account.silenced?) &&
3839
!(original_status.spoiler_text? || original_status.sensitive?)
3940

app/services/concerns/payloadable.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def serialize_payload(record, serializer, options = {})
1717
payload = ActiveModelSerializers::SerializableResource.new(record, options.merge(serializer: serializer, adapter: ActivityPub::Adapter)).as_json
1818
object = record.respond_to?(:virtual_object) ? record.virtual_object : record
1919

20-
if (object.respond_to?(:sign?) && object.sign?) && signer && (always_sign || signing_enabled?)
20+
if object.respond_to?(:sign?) && object.sign? && signer && (always_sign || signing_enabled?)
2121
ActivityPub::LinkedDataSignature.new(payload).sign!(signer, sign_with: sign_with)
2222
else
2323
payload

0 commit comments

Comments
 (0)