Merge pull request #1291 from omnivore-app/sywhb-patch-1

Get tweet thread by conversation_id
This commit is contained in:
Hongbo Wu 2022-10-10 09:52:30 +08:00 committed by GitHub
commit 220576235f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -47,6 +47,7 @@ COPY --from=builder /app/packages/api/node_modules /app/packages/api/node_module
COPY --from=builder /app/node_modules /app/node_modules
COPY --from=builder /app/package.json /app/package.json
COPY --from=builder /app/packages/text-to-speech/ /app/packages/text-to-speech/
COPY --from=builder /app/packages/content-handler/ /app/packages/content-handler/
EXPOSE 8080
CMD ["yarn", "workspace", "@omnivore/api", "start"]

View file

@ -37,7 +37,7 @@ interface TweetData {
type: string
id: string
}[]
conversation_id: number
conversation_id: string
attachments?: {
media_keys: string[]
}
@ -74,7 +74,7 @@ const getTweetFields = () => {
// unroll recent tweet thread
const getTweetThread = async (
id: string,
conversationId: string,
username: string
): Promise<TweetThread> => {
const BASE_ENDPOINT = 'https://api.twitter.com/2/tweets/search/recent'
@ -82,7 +82,7 @@ const getTweetThread = async (
BASE_ENDPOINT +
'?query=' +
encodeURIComponent(
`conversation_id:${id} from:${username} to:${username}`
`conversation_id:${conversationId} from:${username} to:${username}`
) +
getTweetFields() +
'&max_results=100'
@ -160,7 +160,10 @@ export class TwitterHandler extends ContentHandler {
const tweets = [tweet]
// check if tweet is a thread
const thread = await getTweetThread(tweetId, author.username)
const thread = await getTweetThread(
tweetData.conversation_id,
author.username
)
if (thread.meta.result_count > 0) {
// tweets are in reverse chronological order in the thread
for (const t of thread.data.reverse()) {