From 35dd0229bcf3ad26b51f7ca0c4a580918a0b650c Mon Sep 17 00:00:00 2001 From: Louis Grasset Date: Fri, 20 Oct 2023 14:00:35 +0200 Subject: [PATCH 1/2] chore(auth): remove doubled parenthesis in logs --- src/helpers/auth/auth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/auth/auth.ts b/src/helpers/auth/auth.ts index 16edd91..e21e95c 100644 --- a/src/helpers/auth/auth.ts +++ b/src/helpers/auth/auth.ts @@ -32,7 +32,7 @@ export const handleTwitterAuth = async (client: Scraper) => { } else { // Handle restoration failure await client.login(TWITTER_USERNAME, TWITTER_PASSWORD); - console.log('🦤 client: ✔ connected (using credentials))'); + console.log('🦤 client: ✔ connected (using credentials)'); } // Save session From ad09230b39b4b930bd99bc81142f445780fcd408 Mon Sep 17 00:00:00 2001 From: Louis Grasset Date: Fri, 20 Oct 2023 14:01:07 +0200 Subject: [PATCH 2/2] fix(blueksky): upload image without alt text --- src/services/bluesky-sender.service.ts | 19 ++++++++++--------- src/types/media.ts | 2 ++ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/services/bluesky-sender.service.ts b/src/services/bluesky-sender.service.ts index 3fa2001..ac8d33a 100644 --- a/src/services/bluesky-sender.service.ts +++ b/src/services/bluesky-sender.service.ts @@ -1,4 +1,4 @@ -import { AppBskyEmbedRecord, BskyAgent,ComAtprotoRepoUploadBlob } from '@atproto/api'; +import { AppBskyEmbedRecord, BskyAgent } from '@atproto/api'; import { Ora } from 'ora'; import { VOID } from '../constants.js'; @@ -6,7 +6,7 @@ import { getCache } from '../helpers/cache/index.js'; import { savePostToCache } from '../helpers/cache/save-post-to-cache.js'; import { parseBlobForBluesky } from '../helpers/medias/parse-blob-for-bluesky.js'; import { getPostExcerpt } from '../helpers/post/get-post-excerpt.js'; -import { Media, Platform } from '../types/index.js'; +import { BlueskyMediaAttachment, Media, Platform } from '../types/index.js'; import { BlueskyPost } from '../types/post.js'; import { mediaDownloaderService } from './index.js'; @@ -21,7 +21,7 @@ export const blueskySenderService = async (client: BskyAgent | null, post: Blues } // Medias - const mediaAttachments: Array = []; + const mediaAttachments: BlueskyMediaAttachment[] = []; for (const media of medias) { if (!media.url) { continue; @@ -44,10 +44,11 @@ export const blueskySenderService = async (client: BskyAgent | null, post: Blues await client.uploadBlob(blobData, { encoding: mimeType }) .then(async mediaSent => { - mediaAttachments.push({ - ...mediaSent, - ...{ alt_text: media.type === 'image' ? media.alt_text : '' } - }); + const m : BlueskyMediaAttachment = { ...mediaSent }; + if(media.type === 'image' && media.alt_text) { + m.alt_text = media.alt_text; + } + mediaAttachments.push(m); }) .catch(err => { log.fail(err); @@ -72,7 +73,7 @@ export const blueskySenderService = async (client: BskyAgent | null, post: Blues $type: 'app.bsky.embed.recordWithMedia', media: { $type: 'app.bsky.embed.images', - images: mediaAttachments.length ? mediaAttachments.map(i => ({ alt: i.alt_text, image: i.data.blob.original })) : undefined + images: mediaAttachments.length ? mediaAttachments.map(i => ({ alt: i.alt_text ?? '', image: i.data.blob.original })) : undefined }, record: { $type: 'app.bsky.embed.record', @@ -107,7 +108,7 @@ export const blueskySenderService = async (client: BskyAgent | null, post: Blues if (mediaAttachments.length) { data.embed = { $type: 'app.bsky.embed.images', - images: mediaAttachments.length ? mediaAttachments.map(i => ({ alt: i.alt_text, image: i.data.blob.original })) : undefined + images: mediaAttachments.length ? mediaAttachments.map(i => ({ alt: i.alt_text ?? '', image: i.data.blob.original })) : undefined }; } } diff --git a/src/types/media.ts b/src/types/media.ts index 25389ce..e3cf6e3 100644 --- a/src/types/media.ts +++ b/src/types/media.ts @@ -1,3 +1,5 @@ +import { ComAtprotoRepoUploadBlob } from '@atproto/api'; import { Photo, Video } from '@the-convocation/twitter-scraper/dist/tweets.js'; export type Media = Photo & { type: 'image' } | Video & { type: 'video' } +export type BlueskyMediaAttachment = ComAtprotoRepoUploadBlob.Response & { alt_text?: string | undefined}