diff --git a/packages/content-handler/package.json b/packages/content-handler/package.json index 6f5c18197..e9a114ba6 100644 --- a/packages/content-handler/package.json +++ b/packages/content-handler/package.json @@ -31,6 +31,7 @@ "addressparser": "^1.0.1", "axios": "^0.27.2", "linkedom": "^0.14.16", + "lodash": "^4.17.21", "luxon": "^3.0.4", "puppeteer-core": "^19.1.1", "rfc2047": "^4.0.1", diff --git a/packages/content-handler/src/websites/twitter-handler.ts b/packages/content-handler/src/websites/twitter-handler.ts index 6075123b9..16fa054c2 100644 --- a/packages/content-handler/src/websites/twitter-handler.ts +++ b/packages/content-handler/src/websites/twitter-handler.ts @@ -2,6 +2,7 @@ import { ContentHandler, PreHandleResult } from '../content-handler' import axios from 'axios' import { DateTime } from 'luxon' import _ from 'underscore' +import { truncate } from 'lodash' import { Browser, BrowserContext } from 'puppeteer-core' interface TweetIncludes { @@ -135,7 +136,9 @@ const getTweetsByIds = async (ids: string[]): Promise => { } const titleForTweet = (author: { name: string }, text: string) => { - return `${author.name} on Twitter: ${text.replace(/http\S+/, '')}` + return `${author.name} on Twitter: ${truncate(text.replace(/http\S+/, ''), { + length: 100, + })}` } const tweetIdFromStatusUrl = (url: string): string | undefined => {