Page MenuHomePhorge

D15343.1765054876.diff
No OneTemporary

Size
3 KB
Referenced Files
None
Subscribers
None

D15343.1765054876.diff

diff --git a/lib/shared/farcaster/farcaster-messages-types.js b/lib/shared/farcaster/farcaster-messages-types.js
--- a/lib/shared/farcaster/farcaster-messages-types.js
+++ b/lib/shared/farcaster/farcaster-messages-types.js
@@ -68,13 +68,36 @@
mimeType: t.maybe(t.String),
});
+type FarcasterMessageVideo = {
+ +type: 'video',
+ +url: string,
+ +sourceUrl: string,
+ +thumbnailUrl: string,
+ +width: number,
+ +height: number,
+ +duration: number,
+ ...
+};
+const farcasterMessageVideoValidator: TInterface<FarcasterMessageVideo> =
+ tShapeInexact({
+ type: t.enums.of(['video']),
+ url: t.String,
+ sourceUrl: t.String,
+ thumbnailUrl: t.String,
+ width: t.Number,
+ height: t.Number,
+ duration: t.Number,
+ });
+
type FarcasterMessageMetadata = {
+medias?: $ReadOnlyArray<FarcasterMessageMedia>,
+ +videos?: $ReadOnlyArray<FarcasterMessageVideo>,
...
};
const farcasterMessageMetadataValidator: TInterface<FarcasterMessageMetadata> =
tShapeInexact({
medias: t.maybe(t.list(farcasterMessageMediaValidator)),
+ videos: t.maybe(t.list(farcasterMessageVideoValidator)),
});
type FarcasterMentionMetadata = {
diff --git a/lib/utils/convert-farcaster-message-to-comm-messages.js b/lib/utils/convert-farcaster-message-to-comm-messages.js
--- a/lib/utils/convert-farcaster-message-to-comm-messages.js
+++ b/lib/utils/convert-farcaster-message-to-comm-messages.js
@@ -8,7 +8,7 @@
farcasterThreadIDFromConversationID,
userIDFromFID,
} from '../shared/id-utils.js';
-import type { Image } from '../types/media-types.js';
+import type { Image, Video } from '../types/media-types.js';
import { messageTypes } from '../types/message-types-enum.js';
import type { RawMessageInfo } from '../types/message-types.js';
@@ -45,21 +45,41 @@
if (
farcasterMessage.type === 'text' &&
- !!farcasterMessage?.metadata?.medias
+ (!!farcasterMessage?.metadata?.medias ||
+ !!farcasterMessage?.metadata?.videos)
) {
- const media = farcasterMessage.metadata.medias.map(
- med =>
+ const media: Array<Image | Video> =
+ farcasterMessage.metadata.medias?.map(
+ med =>
+ ({
+ id: uuid.v4(),
+ uri: med.staticRaster,
+ type: 'photo',
+ thumbHash: findThumbHash(med.staticRaster),
+ dimensions: {
+ height: med.height,
+ width: med.width,
+ },
+ }: Image),
+ ) || [];
+
+ for (const video of farcasterMessage.metadata?.videos ?? []) {
+ media.push(
({
+ type: 'video',
id: uuid.v4(),
- uri: med.staticRaster,
- type: 'photo',
- thumbHash: findThumbHash(med.staticRaster),
+ uri: video.url,
+ thumbnailID: uuid.v4(),
+ thumbnailURI: video.thumbnailUrl,
+ thumbnailThumbHash: null,
+ loop: false,
dimensions: {
- height: med.height,
- width: med.width,
+ width: video.width,
+ height: video.height,
},
- }: Image),
- );
+ }: Video),
+ );
+ }
const time = parseInt(farcasterMessage.serverTimestamp, 10);
const messages: Array<RawMessageInfo> = [
@@ -86,7 +106,7 @@
type: messageTypes.TEXT,
threadID,
creatorID,
- time,
+ time: time + 1,
text: captionText,
});
}

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 6, 9:01 PM (9 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5840827
Default Alt Text
D15343.1765054876.diff (3 KB)

Event Timeline