Merge branch 'rm-rumble-embeds' into 'main'

Remove support for Rumble video embeds

See merge request soapbox-pub/soapbox!2716
environments/review-main-yi2y9f/deployments/3980
Alex Gleason 1 year ago
commit a59b9d563d

@ -1,95 +0,0 @@
{
"id": "108046244464677537",
"created_at": "2022-03-30T15:40:53.287Z",
"in_reply_to_id": null,
"in_reply_to_account_id": null,
"sensitive": false,
"spoiler_text": "",
"visibility": "public",
"language": null,
"uri": "https://truthsocial.com/users/alex/statuses/108046244464677537",
"url": "https://truthsocial.com/@alex/108046244464677537",
"replies_count": 0,
"reblogs_count": 0,
"favourites_count": 0,
"favourited": false,
"reblogged": false,
"muted": false,
"bookmarked": false,
"pinned": false,
"content": "",
"reblog": null,
"application": {
"name": "Soapbox FE",
"website": "https://soapbox.pub/"
},
"account": {
"id": "107759994408336377",
"username": "alex",
"acct": "alex",
"display_name": "Alex Gleason",
"locked": false,
"bot": false,
"discoverable": null,
"group": false,
"created_at": "2022-02-08T00:00:00.000Z",
"note": "<p>Launching Truth Social</p>",
"url": "https://truthsocial.com/@alex",
"avatar": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/759/994/408/336/377/original/119cb0dd1fa615b7.png",
"avatar_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/759/994/408/336/377/original/119cb0dd1fa615b7.png",
"header": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/759/994/408/336/377/original/31f62b0453ccf554.png",
"header_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/759/994/408/336/377/original/31f62b0453ccf554.png",
"followers_count": 4713,
"following_count": 43,
"statuses_count": 7,
"last_status_at": "2022-03-30",
"verified": true,
"location": "Texas",
"website": "https://soapbox.pub/",
"emojis": [],
"fields": []
},
"media_attachments": [
{
"id": "108046243948255335",
"type": "video",
"url": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/media_attachments/files/108/046/243/948/255/335/original/3b17ce701c0d6f08.mp4",
"preview_url": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/cache/preview_cards/images/000/543/912/original/e1fcf6ace01d9ded.jpg",
"external_video_id": "vwfnq9",
"remote_url": null,
"preview_remote_url": null,
"text_url": "https://truthsocial.com/media/SpbYvqKIT2VubC9FFn0",
"meta": {
"original": {
"width": 988,
"height": 556,
"frame_rate": "60/1",
"duration": 1.949025,
"bitrate": 402396
}
},
"description": null,
"blurhash": null
}
],
"mentions": [],
"tags": [],
"emojis": [],
"card": {
"url": "https://rumble.com/vz1trd-video-upload-for-108046244464677537.html?mref=ummtf&mc=3nvg0",
"title": "Video upload for 108046244464677537",
"description": "",
"type": "video",
"author_name": "hostid1",
"author_url": "https://rumble.com/user/hostid1",
"provider_name": "Rumble.com",
"provider_url": "https://rumble.com/",
"html": "<iframe src=\"https://rumble.com/embed/vwfnq9/\" width=\"988\" height=\"556\" frameborder=\"0\" title=\"Video upload for 108046244464677537\" allowfullscreen=\"\"></iframe>",
"width": 988,
"height": 556,
"image": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/cache/preview_cards/images/000/543/912/original/e1fcf6ace01d9ded.jpg",
"embed_url": "",
"blurhash": "UQH1;m~8sks,%M~9?DRk-mRnR+xs9cWVj[bH"
},
"poll": null
}

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React from 'react';
import { openModal } from 'soapbox/actions/modals';
import AttachmentThumbs from 'soapbox/components/attachment-thumbs';
@ -7,8 +7,7 @@ import PlaceholderCard from 'soapbox/features/placeholder/components/placeholder
import Card from 'soapbox/features/status/components/card';
import Bundle from 'soapbox/features/ui/components/bundle';
import { MediaGallery, Video, Audio } from 'soapbox/features/ui/util/async-components';
import { useAppDispatch, useSettings } from 'soapbox/hooks';
import { addAutoPlay } from 'soapbox/utils/media';
import { useAppDispatch } from 'soapbox/hooks';
import type { List as ImmutableList } from 'immutable';
import type VideoType from 'soapbox/features/video';
@ -36,22 +35,12 @@ const StatusMedia: React.FC<IStatusMedia> = ({
onToggleVisibility = () => { },
}) => {
const dispatch = useAppDispatch();
const settings = useSettings();
const shouldAutoPlayVideo = settings.get('autoPlayVideo');
const [mediaWrapperWidth, setMediaWrapperWidth] = useState<number | undefined>(undefined);
const size = status.media_attachments.size;
const firstAttachment = status.media_attachments.first();
let media: JSX.Element | null = null;
const setRef = (c: HTMLDivElement): void => {
if (c) {
setMediaWrapperWidth(c.offsetWidth);
}
};
const renderLoadingMediaGallery = (): JSX.Element => {
return <div className='media_gallery' style={{ height: '285px' }} />;
};
@ -80,45 +69,22 @@ const StatusMedia: React.FC<IStatusMedia> = ({
} else if (size === 1 && firstAttachment.type === 'video') {
const video = firstAttachment;
if (video.external_video_id && status.card) {
const getHeight = (): number => {
const width = Number(video.meta.getIn(['original', 'width']));
const height = Number(video.meta.getIn(['original', 'height']));
return Number(mediaWrapperWidth) / (width / height);
};
const height = getHeight();
media = (
<div className='status-card horizontal compact interactive status-card--video'>
<div
ref={setRef}
className='status-card__image status-card-video'
style={height ? { height } : undefined}
dangerouslySetInnerHTML={{
__html: shouldAutoPlayVideo ? addAutoPlay(status.card.html) : status.card.html,
}}
media = (
<Bundle fetchComponent={Video} loading={renderLoadingVideoPlayer}>
{(Component: typeof VideoType) => (
<Component
preview={video.preview_url}
blurhash={video.blurhash}
src={video.url}
alt={video.description}
aspectRatio={Number(video.meta.getIn(['original', 'aspect']))}
height={285}
visible={showMedia}
inline
/>
</div>
);
} else {
media = (
<Bundle fetchComponent={Video} loading={renderLoadingVideoPlayer}>
{(Component: typeof VideoType) => (
<Component
preview={video.preview_url}
blurhash={video.blurhash}
src={video.url}
alt={video.description}
aspectRatio={Number(video.meta.getIn(['original', 'aspect']))}
height={285}
visible={showMedia}
inline
/>
)}
</Bundle>
);
}
)}
</Bundle>
);
} else if (size === 1 && firstAttachment.type === 'audio') {
const attachment = firstAttachment;

@ -196,10 +196,6 @@ const Preferences = () => {
<SettingToggle settings={settings} settingPath={['autoPlayGif']} onChange={onToggleChange} />
</ListItem>
<ListItem label={<FormattedMessage id='preferences.fields.auto_play_video_label' defaultMessage='Auto-play videos' />}>
<SettingToggle settings={settings} settingPath={['autoPlayVideo']} onChange={onToggleChange} />
</ListItem>
{features.spoilers && <ListItem label={<FormattedMessage id='preferences.fields.expand_spoilers_label' defaultMessage='Always expand posts marked with content warnings' />}>
<SettingToggle settings={settings} settingPath={['expandSpoilers']} onChange={onToggleChange} />
</ListItem>}

@ -22,7 +22,6 @@ const MOCK_STATUSES: any[] = [
require('soapbox/__fixtures__/pleroma-status-vertical-video-without-metadata.json'),
require('soapbox/__fixtures__/pleroma-status-with-poll-with-emojis.json'),
require('soapbox/__fixtures__/pleroma-quote-of-quote-post.json'),
require('soapbox/__fixtures__/truthsocial-status-with-external-video.json'),
require('soapbox/__fixtures__/truthsocial-status-in-moderation.json'),
];

@ -198,10 +198,4 @@ describe('normalizeStatus()', () => {
expect(card.type).toEqual('link');
expect(card.provider_url).toEqual('https://soapbox.pub');
});
it('preserves Truth Social external_video_id', () => {
const status = require('soapbox/__fixtures__/truthsocial-status-with-external-video.json');
const result = normalizeStatus(status);
expect(result.media_attachments.get(0)?.external_video_id).toBe('vwfnq9');
});
});

@ -15,7 +15,6 @@ import { mergeDefined } from 'soapbox/utils/normalizers';
export const AttachmentRecord = ImmutableRecord({
blurhash: undefined,
description: '',
external_video_id: null as string | null, // TruthSocial
id: '',
meta: ImmutableMap(),
pleroma: ImmutableMap(),

@ -15,7 +15,6 @@ const blurhashSchema = z.string().superRefine((value, ctx) => {
const baseAttachmentSchema = z.object({
blurhash: blurhashSchema.nullable().catch(null),
description: z.string().catch(''),
external_video_id: z.string().optional().catch(undefined), // TruthSocial
id: z.string(),
pleroma: z.object({
mime_type: z.string().regex(/^\w+\/[-+.\w]+$/),

Loading…
Cancel
Save