Browse Source

Also add replies to self

Twitter seems to do this for the main timeline
Thomas Dy 2 years ago
parent
commit
5dd23d8fe9
2 changed files with 9 additions and 5 deletions
  1. 8 4
      store.ts
  2. 1 1
      twitter.ts

+ 8 - 4
store.ts

@@ -90,10 +90,14 @@ export class SqliteStore extends Store {
       ORDER BY id DESC
     `, [ BigInt(authorId), BigInt(olderThanId), dateToEpoch(newerThan) ]);
 
-    return result.map(([ tweetStr ]) => {
-      const tweet = JSON.parse(tweetStr);
-      return TweetSchema.parse(tweet);
-    });
+    return result
+      .map(([ tweetStr ]) => {
+        const tweet = JSON.parse(tweetStr);
+        return TweetSchema.parse(tweet);
+      })
+      .filter(({ in_reply_to_user_id_str }) => {
+        return in_reply_to_user_id_str === null || in_reply_to_user_id_str === authorId;
+      });
   }
 
   getAuthorId(username: string): string | null {

+ 1 - 1
twitter.ts

@@ -64,6 +64,7 @@ const BaseTweetSchema = object({
       })),
     })),
   })),
+  in_reply_to_user_id_str: z.union([z.string(), z.null()]),
 });
 
 interface TweetRecurse {
@@ -87,7 +88,6 @@ export class TwitterClient {
     const options: Record<string, string> = {
       screen_name: username,
       trim_user: 'false',
-      exclude_replies: 'true',
       include_rts: 'true',
       tweet_mode: 'extended',
     };