Skip to content

Commit

Permalink
update a few more things to get bluesky embeds working
Browse files Browse the repository at this point in the history
the preview is still trying to use GifPreview for some
reason?
  • Loading branch information
nick-funk committed Nov 28, 2024
1 parent 73e0ed0 commit 3d93f0d
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ const MediaPreview: FunctionComponent<Props> = ({
</Flex>

{/* Show the actual media. */}
{media.type === "external" ? (
{media.type === "external" && (
<ExternalMedia url={media.url} siteID={siteID} />
) : media.type === "twitter" ? (
)}
{media.type === "twitter" && (
<TwitterMedia url={media.url} siteID={siteID} />
) : media.type === "bsky" ? (
)}
{media.type === "bsky" && (
<BlueskyMedia url={media.url} siteID={siteID} />
) : media.type === "youtube" ? (
)}
{media.type === "youtube" && (
<YouTubeMedia url={media.url} siteID={siteID} isToggled={true} />
) : null}
)}
</HorizontalGutter>

{/* On extra small screens, move the remove button to the bottom! */}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { MediaSectionContainer_comment } from "coral-stream/__generated__/MediaS
import { MediaSectionContainer_settings } from "coral-stream/__generated__/MediaSectionContainer_settings.graphql";
import { MediaSectionContainerLocal } from "coral-stream/__generated__/MediaSectionContainerLocal.graphql";

import BlueskyMedia from "coral-stream/common/Media/BlueskyMedia";
import styles from "./MediaSectionContainer.css";

interface Props {
Expand Down Expand Up @@ -84,7 +85,9 @@ const MediaSectionContainer: FunctionComponent<Props> = ({
(media.__typename === "TwitterMedia" && !settings.media.twitter.enabled) ||
(media.__typename === "YouTubeMedia" && !settings.media.youtube.enabled) ||
(media.__typename === "GiphyMedia" && !settings.media.gifs.enabled) ||
(media.__typename === "ExternalMedia" && !settings.media.external.enabled)
(media.__typename === "ExternalMedia" &&
!settings.media.external.enabled) ||
(media.__typename === "BlueskyMedia" && !settings.media.bluesky.enabled)
) {
return null;
}
Expand All @@ -103,6 +106,9 @@ const MediaSectionContainer: FunctionComponent<Props> = ({
{media.__typename === "TwitterMedia" && (
<Localized id="comments-embedLinks-show-twitter">Show post</Localized>
)}
{media.__typename === "BlueskyMedia" && (
<Localized id="comments-embedLinks-show-bluesky">Show post</Localized>
)}
{media.__typename === "YouTubeMedia" && (
<Localized id="comments-embedLinks-show-youtube">
Show video
Expand Down Expand Up @@ -144,6 +150,11 @@ const MediaSectionContainer: FunctionComponent<Props> = ({
Hide post
</Localized>
)}
{media.__typename === "BlueskyMedia" && (
<Localized id="comments-embedLinks-hide-bluesky">
Hide post
</Localized>
)}
{media.__typename === "GiphyMedia" && (
<Localized id="comments-embedLinks-hide-gif">Hide GIF</Localized>
)}
Expand Down Expand Up @@ -178,6 +189,14 @@ const MediaSectionContainer: FunctionComponent<Props> = ({
isToggled={isToggled}
/>
)}
{media.__typename === "BlueskyMedia" && (
<BlueskyMedia
id={comment.id}
url={media.url}
siteID={comment.site.id}
isToggled={isToggled}
/>
)}
{media.__typename === "YouTubeMedia" && (
<YouTubeMedia
id={comment.id}
Expand Down Expand Up @@ -224,6 +243,10 @@ const enhanced = withFragmentContainer<Props>({
url
width
}
... on BlueskyMedia {
url
width
}
... on YouTubeMedia {
url
width
Expand All @@ -242,6 +265,9 @@ const enhanced = withFragmentContainer<Props>({
twitter {
enabled
}
bluesky {
enabled
}
youtube {
enabled
}
Expand Down
3 changes: 3 additions & 0 deletions locales/en-US/stream.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ comments-embedLinks-hide-youtube = Hide video
comments-embedLinks-show-twitter = Show post
comments-embedLinks-hide-twitter = Hide post
comments-embedLinks-show-bluesky = Show post
comments-embedLinks-hide-bluesky = Hide post
comments-embedLinks-show-external = Show image
comments-embedLinks-hide-external = Hide image
Expand Down
2 changes: 1 addition & 1 deletion server/src/core/server/app/handlers/api/oembed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { RequestHandler, TenantCoralRequest } from "coral-server/types/express";

const OEmbedQuerySchema = Joi.object().keys({
url: Joi.string().uri().required(),
type: Joi.string().allow("twitter", "youtube").only(),
type: Joi.string().allow("twitter", "youtube", "bsky").only(),
maxWidth: Joi.number().optional(),
commentID: Joi.string().optional(),
});
Expand Down
1 change: 0 additions & 1 deletion server/src/core/server/services/oembed/oembed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export async function fetchOEmbedResponse(
break;
}
case "bsky": {
console.log(url);
uri = `https://embed.bsky.app/oembed?url=${encodeURIComponent(url)}`;
break;
}
Expand Down

0 comments on commit 3d93f0d

Please sign in to comment.