Skip to content

Commit 42b08a5

Browse files
committed
fix issue 1668, ImageDescriptionService can't get image description from twitter post with images
1 parent 8c7c83f commit 42b08a5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

packages/client-twitter/src/base.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,13 @@ export class ClientBase extends EventEmitter {
288288
hashtags: tweet.hashtags ?? tweet.legacy?.entities.hashtags,
289289
mentions:
290290
tweet.mentions ?? tweet.legacy?.entities.user_mentions,
291-
photos:
292-
tweet.photos ??
293-
tweet.legacy?.entities.media?.filter(
291+
photos: tweet.legacy?.entities?.media?.filter(
294292
(media) => media.type === "photo"
295-
) ??
296-
[],
293+
).map(media => ({
294+
id: media.id_str,
295+
url: media.media_url_https, // Store media_url_https as url
296+
alt_text: media.alt_text
297+
})) || [],
297298
thread: tweet.thread || [],
298299
urls: tweet.urls ?? tweet.legacy?.entities.urls,
299300
videos:
@@ -331,10 +332,13 @@ export class ClientBase extends EventEmitter {
331332
permanentUrl: `https://twitter.com/${tweet.core?.user_results?.result?.legacy?.screen_name}/status/${tweet.rest_id}`,
332333
hashtags: tweet.legacy?.entities?.hashtags || [],
333334
mentions: tweet.legacy?.entities?.user_mentions || [],
334-
photos:
335-
tweet.legacy?.entities?.media?.filter(
336-
(media) => media.type === "photo"
337-
) || [],
335+
photos: tweet.legacy?.entities?.media?.filter(
336+
(media) => media.type === "photo"
337+
).map(media => ({
338+
id: media.id_str,
339+
url: media.media_url_https, // Store media_url_https as url
340+
alt_text: media.alt_text
341+
})) || [],
338342
thread: tweet.thread || [],
339343
urls: tweet.legacy?.entities?.urls || [],
340344
videos:

0 commit comments

Comments
 (0)