Skip to content

Commit

Permalink
Merge pull request #2939 from ClearlyClaire/glitch-soc/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream changes up to e1d7efa
  • Loading branch information
ClearlyClaire authored Jan 14, 2025
2 parents f950b97 + 09bd5aa commit ae49d73
Show file tree
Hide file tree
Showing 88 changed files with 1,463 additions and 267 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ RUN \
libpq-dev \
libssl-dev \
libtool \
libyaml-dev \
meson \
nasm \
pkg-config \
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ gem 'twitter-text', '~> 3.1.0'
gem 'tzinfo-data', '~> 1.2023'
gem 'webauthn', '~> 3.0'
gem 'webpacker', '~> 5.4'
gem 'webpush', github: 'ClearlyClaire/webpush', ref: 'f14a4d52e201128b1b00245d11b6de80d6cfdcd9'
gem 'webpush', github: 'mastodon/webpush', ref: '9631ac63045cfabddacc69fc06e919b4c13eb913'

gem 'json-ld'
gem 'json-ld-preloaded', '~> 3.2'
Expand Down Expand Up @@ -125,7 +125,7 @@ group :test do
gem 'flatware-rspec'

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

# RSpec helpers for email specs
gem 'email_spec'
Expand Down
14 changes: 7 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
GIT
remote: https://github.com/ClearlyClaire/webpush.git
revision: f14a4d52e201128b1b00245d11b6de80d6cfdcd9
ref: f14a4d52e201128b1b00245d11b6de80d6cfdcd9
remote: https://github.com/mastodon/webpush.git
revision: 9631ac63045cfabddacc69fc06e919b4c13eb913
ref: 9631ac63045cfabddacc69fc06e919b4c13eb913
specs:
webpush (0.3.8)
webpush (1.1.0)
hkdf (~> 0.2)
jwt (~> 2.0)

Expand Down Expand Up @@ -555,7 +555,7 @@ GEM
opentelemetry-api (~> 1.0)
orm_adapter (0.5.0)
ostruct (0.6.1)
ox (2.14.19)
ox (2.14.20)
bigdecimal (>= 3.0)
parallel (1.26.3)
parser (3.3.6.0)
Expand Down Expand Up @@ -690,7 +690,7 @@ GEM
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-github (2.4.0)
rspec-github (3.0.0)
rspec-core (~> 3.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
Expand Down Expand Up @@ -994,7 +994,7 @@ DEPENDENCIES
redis (~> 4.5)
redis-namespace (~> 1.10)
rqrcode (~> 2.2)
rspec-github (~> 2.4)
rspec-github (~> 3.0)
rspec-rails (~> 7.0)
rspec-sidekiq (~> 5.0)
rubocop
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/activitypub/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def set_type

def collection_presenter
ActivityPub::CollectionPresenter.new(
id: account_collection_url(@account, params[:id]),
id: ActivityPub::TagManager.instance.collection_uri_for(@account, params[:id]),
type: @type,
size: @size,
items: @items
Expand Down
8 changes: 2 additions & 6 deletions app/controllers/activitypub/outboxes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ def outbox_presenter
end
end

def outbox_url(**)
if params[:account_username].present?
account_outbox_url(@account, **)
else
instance_actor_outbox_url(**)
end
def outbox_url(...)
ActivityPub::TagManager.instance.outbox_uri_for(@account, ...)
end

def next_page
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/v1/push/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create
endpoint: subscription_params[:endpoint],
key_p256dh: subscription_params[:keys][:p256dh],
key_auth: subscription_params[:keys][:auth],
standard: subscription_params[:standard] || false,
data: data_params,
user_id: current_user.id,
access_token_id: doorkeeper_token.id
Expand Down Expand Up @@ -55,7 +56,7 @@ def check_push_subscription
end

def subscription_params
params.require(:subscription).permit(:endpoint, keys: [:auth, :p256dh])
params.require(:subscription).permit(:endpoint, :standard, keys: [:auth, :p256dh])
end

def data_params
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/api/web/push_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def set_push_subscription
end

def subscription_params
@subscription_params ||= params.require(:subscription).permit(:endpoint, keys: [:auth, :p256dh])
@subscription_params ||= params.require(:subscription).permit(:standard, :endpoint, keys: [:auth, :p256dh])
end

def web_push_subscription_params
Expand All @@ -76,6 +76,7 @@ def web_push_subscription_params
endpoint: subscription_params[:endpoint],
key_auth: subscription_params[:keys][:auth],
key_p256dh: subscription_params[:keys][:p256dh],
standard: subscription_params[:standard] || false,
user_id: active_session.user_id,
}
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/follower_accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def page_requested?
end

def page_url(page)
account_followers_url(@account, page: page) unless page.nil?
ActivityPub::TagManager.instance.followers_uri_for(@account, page: page) unless page.nil?
end

def next_page_url
Expand Down
4 changes: 3 additions & 1 deletion app/helpers/theme_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ def active_custom_stylesheet
end

def cached_custom_css_digest
Rails.cache.read(:setting_digest_custom_css)
Rails.cache.fetch(:setting_digest_custom_css) do
Setting.custom_css&.then { |content| Digest::SHA256.hexdigest(content) }
end
end

def theme_color_for(theme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const unsubscribe = ({ registration, subscription }) =>
subscription ? subscription.unsubscribe().then(() => registration) : registration;

const sendSubscriptionToBackend = (subscription) => {
const params = { subscription };
const params = { subscription: { ...subscription.toJSON(), standard: true } };

if (me) {
const data = pushNotificationsSetting.get(me);
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/api_types/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BaseApiAccountJSON {
avatar_static: string;
bot: boolean;
created_at: string;
discoverable: boolean;
discoverable?: boolean;
indexable: boolean;
display_name: string;
emojis: ApiCustomEmojiJSON[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AddPhotoAlternateIcon from '@/material-icons/400-24px/add_photo_alternate
import EditIcon from '@/material-icons/400-24px/edit.svg?react';
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
import { updateAccount } from 'flavours/glitch/actions/accounts';
import { closeOnboarding } from 'flavours/glitch/actions/onboarding';
import { Button } from 'flavours/glitch/components/button';
import { Column } from 'flavours/glitch/components/column';
import { ColumnHeader } from 'flavours/glitch/components/column_header';
Expand Down Expand Up @@ -58,7 +59,9 @@ export const Profile: React.FC<{
);
const [avatar, setAvatar] = useState<File>();
const [header, setHeader] = useState<File>();
const [discoverable, setDiscoverable] = useState(true);
const [discoverable, setDiscoverable] = useState(
account?.discoverable ?? true,
);
const [isSaving, setIsSaving] = useState(false);
const [errors, setErrors] = useState<ApiAccountErrors>();
const avatarFileRef = createRef<HTMLInputElement>();
Expand Down Expand Up @@ -132,6 +135,7 @@ export const Profile: React.FC<{
)
.then(() => {
history.push('/start/follows');
dispatch(closeOnboarding());
return '';
})
// eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
Expand Down
13 changes: 9 additions & 4 deletions app/javascript/flavours/glitch/features/ui/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const mapStateToProps = state => ({
hicolorPrivacyIcons: state.getIn(['local_settings', 'hicolor_privacy_icons']),
moved: state.getIn(['accounts', me, 'moved']) && state.getIn(['accounts', state.getIn(['accounts', me, 'moved'])]),
firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION,
newAccount: !state.getIn(['accounts', me, 'note']) && !state.getIn(['accounts', me, 'bot']) && state.getIn(['accounts', me, 'following_count'], 0) === 0 && state.getIn(['accounts', me, 'statuses_count'], 0) === 0,
username: state.getIn(['accounts', me, 'username']),
});

Expand Down Expand Up @@ -144,6 +145,7 @@ class SwitchingColumnsArea extends PureComponent {
children: PropTypes.node,
location: PropTypes.object,
singleColumn: PropTypes.bool,
forceOnboarding: PropTypes.bool,
};

UNSAFE_componentWillMount () {
Expand Down Expand Up @@ -174,14 +176,16 @@ class SwitchingColumnsArea extends PureComponent {
};

render () {
const { children, singleColumn } = this.props;
const { children, singleColumn, forceOnboarding } = this.props;
const { signedIn } = this.props.identity;
const pathName = this.props.location.pathname;

let redirect;

if (signedIn) {
if (singleColumn) {
if (forceOnboarding) {
redirect = <Redirect from='/' to='/start' exact />;
} else if (singleColumn) {
redirect = <Redirect from='/' to='/home' exact />;
} else {
redirect = <Redirect from='/' to='/deck/getting-started' exact />;
Expand Down Expand Up @@ -292,6 +296,7 @@ class UI extends PureComponent {
moved: PropTypes.map,
layout: PropTypes.string.isRequired,
firstLaunch: PropTypes.bool,
newAccount: PropTypes.bool,
username: PropTypes.string,
...WithRouterPropTypes,
};
Expand Down Expand Up @@ -615,7 +620,7 @@ class UI extends PureComponent {

render () {
const { draggingOver } = this.state;
const { children, isWide, location, layout, moved } = this.props;
const { children, isWide, location, layout, moved, firstLaunch, newAccount } = this.props;

const className = classNames('ui', {
'wide': isWide,
Expand Down Expand Up @@ -662,7 +667,7 @@ class UI extends PureComponent {

<Header />

<SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'}>
<SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'} forceOnboarding={firstLaunch && newAccount}>
{children}
</SwitchingColumnsArea>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const unsubscribe = ({ registration, subscription }) =>
subscription ? subscription.unsubscribe().then(() => registration) : registration;

const sendSubscriptionToBackend = (subscription) => {
const params = { subscription };
const params = { subscription: { ...subscription.toJSON(), standard: true } };

if (me) {
const data = pushNotificationsSetting.get(me);
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/api_types/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BaseApiAccountJSON {
avatar_static: string;
bot: boolean;
created_at: string;
discoverable: boolean;
discoverable?: boolean;
indexable: boolean;
display_name: string;
emojis: ApiCustomEmojiJSON[];
Expand Down
6 changes: 5 additions & 1 deletion app/javascript/mastodon/features/onboarding/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import AddPhotoAlternateIcon from '@/material-icons/400-24px/add_photo_alternate
import EditIcon from '@/material-icons/400-24px/edit.svg?react';
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
import { updateAccount } from 'mastodon/actions/accounts';
import { closeOnboarding } from 'mastodon/actions/onboarding';
import { Button } from 'mastodon/components/button';
import { Column } from 'mastodon/components/column';
import { ColumnHeader } from 'mastodon/components/column_header';
Expand Down Expand Up @@ -58,7 +59,9 @@ export const Profile: React.FC<{
);
const [avatar, setAvatar] = useState<File>();
const [header, setHeader] = useState<File>();
const [discoverable, setDiscoverable] = useState(true);
const [discoverable, setDiscoverable] = useState(
account?.discoverable ?? true,
);
const [isSaving, setIsSaving] = useState(false);
const [errors, setErrors] = useState<ApiAccountErrors>();
const avatarFileRef = createRef<HTMLInputElement>();
Expand Down Expand Up @@ -132,6 +135,7 @@ export const Profile: React.FC<{
)
.then(() => {
history.push('/start/follows');
dispatch(closeOnboarding());
return '';
})
// eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
Expand Down
13 changes: 9 additions & 4 deletions app/javascript/mastodon/features/ui/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const mapStateToProps = state => ({
hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0,
canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']),
firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION,
newAccount: !state.getIn(['accounts', me, 'note']) && !state.getIn(['accounts', me, 'bot']) && state.getIn(['accounts', me, 'following_count'], 0) === 0 && state.getIn(['accounts', me, 'statuses_count'], 0) === 0,
username: state.getIn(['accounts', me, 'username']),
});

Expand Down Expand Up @@ -135,6 +136,7 @@ class SwitchingColumnsArea extends PureComponent {
children: PropTypes.node,
location: PropTypes.object,
singleColumn: PropTypes.bool,
forceOnboarding: PropTypes.bool,
};

UNSAFE_componentWillMount () {
Expand Down Expand Up @@ -165,14 +167,16 @@ class SwitchingColumnsArea extends PureComponent {
};

render () {
const { children, singleColumn } = this.props;
const { children, singleColumn, forceOnboarding } = this.props;
const { signedIn } = this.props.identity;
const pathName = this.props.location.pathname;

let redirect;

if (signedIn) {
if (singleColumn) {
if (forceOnboarding) {
redirect = <Redirect from='/' to='/start' exact />;
} else if (singleColumn) {
redirect = <Redirect from='/' to='/home' exact />;
} else {
redirect = <Redirect from='/' to='/deck/getting-started' exact />;
Expand Down Expand Up @@ -276,6 +280,7 @@ class UI extends PureComponent {
intl: PropTypes.object.isRequired,
layout: PropTypes.string.isRequired,
firstLaunch: PropTypes.bool,
newAccount: PropTypes.bool,
username: PropTypes.string,
...WithRouterPropTypes,
};
Expand Down Expand Up @@ -568,7 +573,7 @@ class UI extends PureComponent {

render () {
const { draggingOver } = this.state;
const { children, isComposing, location, layout } = this.props;
const { children, isComposing, location, layout, firstLaunch, newAccount } = this.props;

const handlers = {
help: this.handleHotkeyToggleHelp,
Expand Down Expand Up @@ -597,7 +602,7 @@ class UI extends PureComponent {
<div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef}>
<Header />

<SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'}>
<SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'} forceOnboarding={firstLaunch && newAccount}>
{children}
</SwitchingColumnsArea>

Expand Down
Loading

0 comments on commit ae49d73

Please sign in to comment.