From 1e71923f6d09d11ddc49afdc6bce8a8757ea989f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 19 Sep 2023 13:10:57 -0500 Subject: [PATCH] Remove support for Rumble video embeds --- ...ruthsocial-status-with-external-video.json | 95 ------------------- src/components/status-media.tsx | 68 ++++--------- src/features/preferences/index.tsx | 4 - src/features/test-timeline/index.tsx | 1 - src/normalizers/__tests__/status.test.ts | 6 -- src/normalizers/attachment.ts | 1 - src/schemas/attachment.ts | 1 - 7 files changed, 17 insertions(+), 159 deletions(-) delete mode 100644 src/__fixtures__/truthsocial-status-with-external-video.json diff --git a/src/__fixtures__/truthsocial-status-with-external-video.json b/src/__fixtures__/truthsocial-status-with-external-video.json deleted file mode 100644 index eb61501927..0000000000 --- a/src/__fixtures__/truthsocial-status-with-external-video.json +++ /dev/null @@ -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": "

Launching Truth Social

", - "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": "", - "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 -} diff --git a/src/components/status-media.tsx b/src/components/status-media.tsx index 192a4c169f..99329f297d 100644 --- a/src/components/status-media.tsx +++ b/src/components/status-media.tsx @@ -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 = ({ onToggleVisibility = () => { }, }) => { const dispatch = useAppDispatch(); - const settings = useSettings(); - const shouldAutoPlayVideo = settings.get('autoPlayVideo'); - - const [mediaWrapperWidth, setMediaWrapperWidth] = useState(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
; }; @@ -80,45 +69,22 @@ const StatusMedia: React.FC = ({ } 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 = ( -
-
+ {(Component: typeof VideoType) => ( + -
- ); - } else { - media = ( - - {(Component: typeof VideoType) => ( - - )} - - ); - } + )} + + ); } else if (size === 1 && firstAttachment.type === 'audio') { const attachment = firstAttachment; diff --git a/src/features/preferences/index.tsx b/src/features/preferences/index.tsx index cd10fd45ac..84f84ba43f 100644 --- a/src/features/preferences/index.tsx +++ b/src/features/preferences/index.tsx @@ -196,10 +196,6 @@ const Preferences = () => { - }> - - - {features.spoilers && }> } diff --git a/src/features/test-timeline/index.tsx b/src/features/test-timeline/index.tsx index 136d0d3242..1601dc1652 100644 --- a/src/features/test-timeline/index.tsx +++ b/src/features/test-timeline/index.tsx @@ -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'), ]; diff --git a/src/normalizers/__tests__/status.test.ts b/src/normalizers/__tests__/status.test.ts index 0024a212cb..05dd29e6aa 100644 --- a/src/normalizers/__tests__/status.test.ts +++ b/src/normalizers/__tests__/status.test.ts @@ -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'); - }); }); diff --git a/src/normalizers/attachment.ts b/src/normalizers/attachment.ts index f5e00135e8..b63337adca 100644 --- a/src/normalizers/attachment.ts +++ b/src/normalizers/attachment.ts @@ -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(), diff --git a/src/schemas/attachment.ts b/src/schemas/attachment.ts index 3df39d5423..502de94e16 100644 --- a/src/schemas/attachment.ts +++ b/src/schemas/attachment.ts @@ -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]+$/),