Browse Source

Fix empty pinned tweets when status wasn't found

Zed 4 years ago
parent
commit
d1a3e7ab58
2 changed files with 5 additions and 5 deletions
  1. 4 5
      src/parser.nim
  2. 1 0
      src/types.nim

+ 4 - 5
src/parser.nim

@@ -63,11 +63,6 @@ proc parseGraphListMembers*(js: JsonNode; cursor: string): Result[User] =
 
   if js.isNull: return
 
-  # result.top = js{"previous_cursor_str"}.getStr
-  # result.bottom = js{"next_cursor_str"}.getStr
-  # if result.bottom.len == 1:
-  #   result.bottom.setLen 0
-
   let root = js{"data", "list", "members_timeline", "timeline", "instructions"}
   for instruction in root:
     if instruction{"type"}.getStr == "TimelineAddEntries":
@@ -373,6 +368,10 @@ proc parseConversation*(js: JsonNode; tweetId: string): Conversation =
       result.replies.bottom = e.getCursor
 
 proc parseStatus*(js: JsonNode): Tweet =
+  with e, js{"errors"}:
+    if e.getError == tweetNotFound:
+      return
+
   result = parseTweet(js)
   if not result.isNil:
     result.user = parseUser(js{"user"})

+ 1 - 0
src/types.nim

@@ -41,6 +41,7 @@ type
     rateLimited = 88
     invalidToken = 89
     listIdOrSlug = 112
+    tweetNotFound = 144
     forbidden = 200
     badToken = 239
     noCsrf = 353