mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #1291 from omnivore-app/sywhb-patch-1
Get tweet thread by conversation_id
This commit is contained in:
commit
220576235f
2 changed files with 8 additions and 4 deletions
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue