mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
If the saved tweet is a reply, we need to get the referenced tweet
This commit is contained in:
parent
220576235f
commit
5d70d04154
2 changed files with 7 additions and 23 deletions
|
|
@ -1,21 +0,0 @@
|
|||
export class GolangHandler {
|
||||
name = 'golangweekly'
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
shouldPrehandle = (url: URL, _dom: Document): boolean => {
|
||||
const host = this.name + '.com'
|
||||
// check if url ends with golangweekly.com
|
||||
return url.hostname.endsWith(host)
|
||||
}
|
||||
|
||||
prehandle = (url: URL, dom: Document): Promise<Document> => {
|
||||
const body = dom.querySelector('body')
|
||||
|
||||
// this removes the "Subscribe" button
|
||||
body?.querySelector('.el-splitbar')?.remove()
|
||||
// this removes the title
|
||||
body?.querySelector('.el-masthead')?.remove()
|
||||
|
||||
return Promise.resolve(dom)
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ export class TwitterHandler extends ContentHandler {
|
|||
if (!tweetId) {
|
||||
throw new Error('could not find tweet id in url')
|
||||
}
|
||||
const tweet = await getTweetById(tweetId)
|
||||
let tweet = await getTweetById(tweetId)
|
||||
const tweetData = tweet.data
|
||||
const authorId = tweetData.author_id
|
||||
const author = tweet.includes.users.filter((u) => (u.id = authorId))[0]
|
||||
|
|
@ -157,9 +157,14 @@ export class TwitterHandler extends ContentHandler {
|
|||
const title = _.escape(titleForAuthor(author))
|
||||
const authorImage = author.profile_image_url.replace('_normal', '_400x400')
|
||||
const description = _.escape(tweetData.text)
|
||||
const converstationId = tweetData.conversation_id
|
||||
if (converstationId !== tweetId) {
|
||||
// this is a reply, so we need to get the referenced tweet
|
||||
tweet = await getTweetById(converstationId)
|
||||
}
|
||||
|
||||
const tweets = [tweet]
|
||||
// check if tweet is a thread
|
||||
// we want to get the full thread
|
||||
const thread = await getTweetThread(
|
||||
tweetData.conversation_id,
|
||||
author.username
|
||||
|
|
|
|||
Loading…
Reference in a new issue