Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ nitter.conf
guest_accounts.json*
sessions.json*
dump.rdb
nitter.log
11 changes: 11 additions & 0 deletions src/routes/embed.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ proc createEmbedRouter*(cfg: Config) =

resp renderTweetEmbed(tweet, path, prefs, cfg, request)

get "/i/status/@id/embed":
let
tweet = await getGraphTweetResult(@"id")
prefs = cookiePrefs()
path = getPath()

if tweet == nil:
resp Http404

resp renderTweetEmbed(tweet, path, prefs, cfg, request)

get "/embed/Tweet.html":
let id = @"id"

Expand Down
51 changes: 51 additions & 0 deletions src/routes/status.nim
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,56 @@ proc createStatusRouter*(cfg: Config) =
get "/i/web/status/@id":
redirect("/i/status/" & @"id")

get "/i/status/@id/?":
let id = @"id"

if id.len > 19 or id.any(c => not c.isDigit):
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 19 should be extracted to a named constant to clarify that this represents the maximum length of a tweet ID.

Copilot uses AI. Check for mistakes.
resp Http404, showError("Invalid tweet ID", cfg)

let prefs = cookiePrefs()

# used for the infinite scroll feature
if @"scroll".len > 0:
let replies = await getReplies(id, getCursor())
if replies.content.len == 0:
resp Http404, ""
resp $renderReplies(replies, prefs, getPath())

let conv = await getTweet(id, getCursor())
if conv == nil:
echo "nil conv"
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug output should be removed or replaced with proper logging. Using echo for debugging in production code is not recommended.

Copilot uses AI. Check for mistakes.

if conv == nil or conv.tweet == nil or conv.tweet.id == 0:
var error = "Tweet not found"
if conv != nil and conv.tweet != nil and conv.tweet.tombstone.len > 0:
error = conv.tweet.tombstone
resp Http404, showError(error, cfg)

let
title = pageTitle(conv.tweet)
ogTitle = pageTitle(conv.tweet.user)
desc = conv.tweet.text

var
images = conv.tweet.photos
video = ""

if conv.tweet.video.isSome():
images = @[get(conv.tweet.video).thumb]
video = getVideoEmbed(cfg, conv.tweet.id)
elif conv.tweet.gif.isSome():
images = @[get(conv.tweet.gif).thumb]
video = getPicUrl(get(conv.tweet.gif).url)
elif conv.tweet.card.isSome():
let card = conv.tweet.card.get()
if card.image.len > 0:
images = @[card.image]
elif card.video.isSome():
images = @[card.video.get().thumb]

let html = renderConversation(conv, prefs, getPath() & "#m")
resp renderMain(html, request, cfg, prefs, title, desc, ogTitle,
images=images, video=video)

get "/@name/thread/@id/?":
redirect("/$1/status/$2" % [@"name", @"id"])