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 0226bbe5165a53658b29e46ddbef6a10507fdc8c #2843

Merged
merged 40 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e09f9f8
Fix alt text modal styling (#31844)
vmstan Sep 10, 2024
e6f5b36
Update dependency express to v4.20.0 (#31836)
renovate[bot] Sep 10, 2024
9e12fa2
Update dependency propshaft to v1 (#31832)
renovate[bot] Sep 10, 2024
a3215c0
Change inner borders in media galleries in web UI (#31852)
Gargron Sep 11, 2024
cee71b9
Remove `fa_` prefix from status visibility icon method (#31846)
mjankowski Sep 11, 2024
9769ffd
Update dependency aws-sdk-s3 to v1.161.0 (#31853)
renovate[bot] Sep 11, 2024
cdcd834
Add coverage for `AnnualReport::*` source child classes (#31849)
mjankowski Sep 11, 2024
2babfaf
New Crowdin Translations (automated) (#31855)
github-actions[bot] Sep 11, 2024
a27f7f4
Update typescript-eslint monorepo to v8 (major) (#31231)
renovate[bot] Sep 11, 2024
7d53ca5
New Crowdin Translations (automated) (#31878)
github-actions[bot] Sep 12, 2024
f2a92c2
Fix notifications re-rendering spuriously in web UI (#31879)
Gargron Sep 12, 2024
3d46f47
Change embedded posts to use web UI (#31766)
Gargron Sep 12, 2024
ab763c4
Ignore `undefined` as canonical url (#31882)
oneiros Sep 12, 2024
24ef825
Change design of embed modal in web UI (#31801)
Gargron Sep 12, 2024
c35ea59
Fix security context sometimes not being added in LD-Signed activitie…
ClearlyClaire Sep 12, 2024
5f782f9
Autofocus primary button in modals (#31883)
ClearlyClaire Sep 12, 2024
a496aea
Change form-action Content-Security-Policy directive to be more restr…
ClearlyClaire Sep 12, 2024
17c57c4
Add coverage for title/limit validations in `List` model (#31869)
mjankowski Sep 12, 2024
8cdc148
Handle invalid visibility (#31571)
c960657 Sep 12, 2024
4aa6003
Move redirect/base body class to view (#31796)
mjankowski Sep 12, 2024
f3c4874
Remove unused `statuses#embed` body class assignment (#31787)
mjankowski Sep 12, 2024
1b6a82b
Fix invalid date searches returning 503 (#31526)
notchairmk Sep 12, 2024
207c073
Remove debug output in migration controller spec (#31886)
mjankowski Sep 12, 2024
a269ff9
Fix review history and action modal styling (#31864)
vmstan Sep 12, 2024
cc3cf9c
Update dependency aws-sdk-s3 to v1.162.0 (#31875)
renovate[bot] Sep 12, 2024
0226bbe
Update dependency express to v4.21.0 (#31877)
renovate[bot] Sep 12, 2024
90d7a4b
Merge commit 'a27f7f4e561c9d2fe21d984059603d2f500c005b' into glitch-s…
ClearlyClaire Sep 12, 2024
eb28472
[Glitch] Fix alt text modal styling
vmstan Sep 10, 2024
196b141
[Glitch] Change inner borders in media galleries in web UI
Gargron Sep 11, 2024
17e3a12
[Glitch] Update typescript-eslint monorepo to v8 (major)
renovate[bot] Sep 11, 2024
caaa412
Merge commit 'f2a92c2d22345568ca7f47ee1d1d70de53eb547d' into glitch-s…
ClearlyClaire Sep 12, 2024
2d31cdb
[Glitch] Fix notifications re-rendering spuriously in web UI
Gargron Sep 12, 2024
3465d39
Merge commit '24ef8255b3f9b44cb54f49bc78fe3382a7070b1a' into glitch-s…
ClearlyClaire Sep 12, 2024
e705ec1
[Glitch] Change embedded posts to use web UI
Gargron Sep 12, 2024
bd68d2a
[Glitch] Change design of embed modal in web UI
Gargron Sep 12, 2024
83b553c
Merge commit '0226bbe5165a53658b29e46ddbef6a10507fdc8c' into glitch-s…
ClearlyClaire Sep 12, 2024
afd3953
[Glitch] Autofocus primary button in modals
ClearlyClaire Sep 12, 2024
9b1ecf7
[Glitch] Fix review history and action modal styling
vmstan Sep 12, 2024
4050beb
Fix detailed status timestamp link target not being the original URL
ClearlyClaire Sep 12, 2024
427ed60
Fix link handling within detailed status contents
ClearlyClaire Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ module.exports = defineConfig({
],

parserOptions: {
project: true,
projectService: true,
tsconfigRootDir: __dirname,
},

Expand Down
16 changes: 8 additions & 8 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.970.0)
aws-sdk-core (3.203.0)
aws-partitions (1.974.0)
aws-sdk-core (3.205.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.89.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-kms (1.91.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.160.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-s3 (1.162.0)
aws-sdk-core (~> 3, >= 3.205.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
Expand Down Expand Up @@ -601,7 +601,7 @@ GEM
actionmailer (>= 3)
net-smtp
premailer (~> 1.7, >= 1.7.9)
propshaft (0.9.1)
propshaft (1.0.0)
actionpack (>= 7.0.0)
activesupport (>= 7.0.0)
rack
Expand Down Expand Up @@ -691,7 +691,7 @@ GEM
redlock (1.3.2)
redis (>= 3.0.0, < 6.0)
regexp_parser (2.9.2)
reline (0.5.9)
reline (0.5.10)
io-console (~> 0.5)
request_store (1.6.0)
rack (>= 1.4)
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/concerns/web_app_controller_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ module WebAppControllerConcern

before_action :redirect_unauthenticated_to_permalinks!
before_action :set_app_body_class

content_security_policy do |p|
policy = ContentSecurityPolicy.new

if policy.sso_host.present?
p.form_action policy.sso_host
else
p.form_action :none
end
end
end

def skip_csrf_meta_tags?
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/redirect/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Redirect::BaseController < ApplicationController
vary_by 'Accept-Language'

before_action :set_resource
before_action :set_app_body_class

def show
@redirect_path = ActivityPub::TagManager.instance.url_for(@resource)
Expand All @@ -14,10 +13,6 @@ def show

private

def set_app_body_class
@body_classes = 'app-body'
end

def set_resource
raise NotImplementedError
end
Expand Down
5 changes: 0 additions & 5 deletions app/controllers/statuses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class StatusesController < ApplicationController
before_action :require_account_signature!, only: [:show, :activity], if: -> { request.format == :json && authorized_fetch_mode? }
before_action :set_status
before_action :redirect_to_original, only: :show
before_action :set_body_classes, only: :embed

after_action :set_link_headers

Expand Down Expand Up @@ -51,10 +50,6 @@ def embed

private

def set_body_classes
@body_classes = 'with-modals'
end

def set_link_headers
response.headers['Link'] = LinkHeader.new(
[[ActivityPub::TagManager.instance.uri_for(@status), [%w(rel alternate), %w(type application/activity+json)]]]
Expand Down
8 changes: 0 additions & 8 deletions app/helpers/accounts_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ def acct(account)
end
end

def account_action_button(account)
return if account.memorial? || account.moved?

link_to ActivityPub::TagManager.instance.url_for(account), class: 'button logo-button', target: '_new' do
safe_join([logo_as_symbol, t('accounts.follow')])
end
end

def hide_followers_count?(account)
Setting.hide_followers_count || account.user&.settings&.[]('hide_followers_count')
end
Expand Down
36 changes: 0 additions & 36 deletions app/helpers/media_component_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,6 @@ def render_media_gallery_component(status, **options)
end
end

def render_card_component(status, **options)
component_params = {
sensitive: sensitive_viewer?(status, current_account),
card: serialize_status_card(status).as_json,
}.merge(**options)

react_component :card, component_params
end

def render_poll_component(status, **options)
component_params = {
disabled: true,
poll: serialize_status_poll(status).as_json,
}.merge(**options)

react_component :poll, component_params do
render partial: 'statuses/poll', locals: { status: status, poll: status.preloadable_poll, autoplay: prefers_autoplay? }
end
end

private

def serialize_media_attachment(attachment)
Expand All @@ -86,22 +66,6 @@ def serialize_media_attachment(attachment)
)
end

def serialize_status_card(status)
ActiveModelSerializers::SerializableResource.new(
status.preview_card,
serializer: REST::PreviewCardSerializer
)
end

def serialize_status_poll(status)
ActiveModelSerializers::SerializableResource.new(
status.preloadable_poll,
serializer: REST::PollSerializer,
scope: current_user,
scope_name: :current_user
)
end

def sensitive_viewer?(status, account)
if !account.nil? && account.id == status.account_id
status.sensitive
Expand Down
20 changes: 9 additions & 11 deletions app/helpers/statuses_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ module StatusesHelper
EMBEDDED_CONTROLLER = 'statuses'
EMBEDDED_ACTION = 'embed'

VISIBLITY_ICONS = {
public: 'globe',
unlisted: 'lock_open',
private: 'lock',
direct: 'alternate_email',
}.freeze

def nothing_here(extra_classes = '')
content_tag(:div, class: "nothing-here #{extra_classes}") do
t('accounts.nothing_here')
Expand Down Expand Up @@ -57,17 +64,8 @@ def stream_link_target
embedded_view? ? '_blank' : nil
end

def fa_visibility_icon(status)
case status.visibility
when 'public'
material_symbol 'globe'
when 'unlisted'
material_symbol 'lock_open'
when 'private'
material_symbol 'lock'
when 'direct'
material_symbol 'alternate_email'
end
def visibility_icon(status)
VISIBLITY_ICONS[status.visibility.to_sym]
end

def embedded_view?
Expand Down
74 changes: 74 additions & 0 deletions app/javascript/entrypoints/embed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import './public-path';
import { createRoot } from 'react-dom/client';

import { afterInitialRender } from 'mastodon/../hooks/useRenderSignal';

import { start } from '../mastodon/common';
import { Status } from '../mastodon/features/standalone/status';
import { loadPolyfills } from '../mastodon/polyfills';
import ready from '../mastodon/ready';

start();

function loaded() {
const mountNode = document.getElementById('mastodon-status');

if (mountNode) {
const attr = mountNode.getAttribute('data-props');

if (!attr) return;

const props = JSON.parse(attr) as { id: string; locale: string };
const root = createRoot(mountNode);

root.render(<Status {...props} />);
}
}

function main() {
ready(loaded).catch((error: unknown) => {
console.error(error);
});
}

loadPolyfills()
.then(main)
.catch((error: unknown) => {
console.error(error);
});

interface SetHeightMessage {
type: 'setHeight';
id: string;
height: number;
}

function isSetHeightMessage(data: unknown): data is SetHeightMessage {
if (
data &&
typeof data === 'object' &&
'type' in data &&
data.type === 'setHeight'
)
return true;
else return false;
}

window.addEventListener('message', (e) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- typings are not correct, it can be null in very rare cases
if (!e.data || !isSetHeightMessage(e.data) || !window.parent) return;

const data = e.data;

// We use a timeout to allow for the React page to render before calculating the height
afterInitialRender(() => {
window.parent.postMessage(
{
type: 'setHeight',
id: data.id,
height: document.getElementsByTagName('html')[0]?.scrollHeight,
},
'*',
);
});
});
37 changes: 0 additions & 37 deletions app/javascript/entrypoints/public.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,43 +37,6 @@ const messages = defineMessages({
},
});

interface SetHeightMessage {
type: 'setHeight';
id: string;
height: number;
}

function isSetHeightMessage(data: unknown): data is SetHeightMessage {
if (
data &&
typeof data === 'object' &&
'type' in data &&
data.type === 'setHeight'
)
return true;
else return false;
}

window.addEventListener('message', (e) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- typings are not correct, it can be null in very rare cases
if (!e.data || !isSetHeightMessage(e.data) || !window.parent) return;

const data = e.data;

ready(() => {
window.parent.postMessage(
{
type: 'setHeight',
id: data.id,
height: document.getElementsByTagName('html')[0]?.scrollHeight,
},
'*',
);
}).catch((e: unknown) => {
console.error('Error in setHeightMessage postMessage', e);
});
});

function loaded() {
const { messages: localeData } = getLocale();

Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/actions/markers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const synchronouslySubmitMarkers = createAppAsyncThunk(
client.setRequestHeader('Content-Type', 'application/json');
client.setRequestHeader('Authorization', `Bearer ${accessToken}`);
client.send(JSON.stringify(params));
} catch (e) {
} catch {
// Do not make the BeforeUnload handler error out
}
},
Expand Down
6 changes: 4 additions & 2 deletions app/javascript/flavours/glitch/actions/statuses.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ export function fetchStatusRequest(id, skipLoading) {
};
}

export function fetchStatus(id, forceFetch = false) {
export function fetchStatus(id, forceFetch = false, alsoFetchContext = true) {
return (dispatch, getState) => {
const skipLoading = !forceFetch && getState().getIn(['statuses', id], null) !== null;

dispatch(fetchContext(id));
if (alsoFetchContext) {
dispatch(fetchContext(id));
}

if (skipLoading) {
return;
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/actions/streaming.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async function refreshHomeTimelineAndNotification(dispatch, getState) {
// TODO: polling for merged notifications
try {
await dispatch(pollRecentGroupNotifications());
} catch (error) {
} catch {
// TODO
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/flavours/glitch/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function start() {

try {
Rails.start();
} catch (e) {
} catch {
// If called twice
}
}
Loading
Loading