Fix crash when generating RSS for invalid user

This commit is contained in:
Zed 2019-10-07 15:52:44 +02:00
parent 2955b8982e
commit 8fcdfa744a
2 changed files with 6 additions and 3 deletions

View File

@ -10,7 +10,8 @@ include "../views/rss.nimf"
proc showRss*(name: string; query: Query): Future[string] {.async.} = proc showRss*(name: string; query: Query): Future[string] {.async.} =
let (profile, timeline, _) = await fetchSingleTimeline(name, "", getAgent(), query) let (profile, timeline, _) = await fetchSingleTimeline(name, "", getAgent(), query)
return renderTimelineRss(timeline.content, profile) if timeline != nil:
return renderTimelineRss(timeline, profile)
template respRss*(rss: typed) = template respRss*(rss: typed) =
if rss.len == 0: if rss.len == 0:

View File

@ -57,7 +57,7 @@
#end for #end for
#end proc #end proc
# #
#proc renderTimelineRss*(tweets: seq[Tweet]; profile: Profile): string = #proc renderTimelineRss*(timeline: Timeline; profile: Profile): string =
#let prefs = Prefs(replaceTwitter: hostname) #let prefs = Prefs(replaceTwitter: hostname)
#result = "" #result = ""
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
@ -76,7 +76,9 @@
<width>128</width> <width>128</width>
<height>128</height> <height>128</height>
</image> </image>
${renderRssTweets(tweets, prefs)} #if timeline != nil:
${renderRssTweets(timeline.content, prefs)}
#end if
</channel> </channel>
</rss> </rss>
#end proc #end proc