From aed31b226996aa8248eed4c7023c2d24ded19baf Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 30 Dec 2021 20:55:10 +0100 Subject: [PATCH] Add slug-based list RSS endpoint for compatibility --- src/routes/rss.nim | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/routes/rss.nim b/src/routes/rss.nim index 552dc29..b27ad90 100644 --- a/src/routes/rss.nim +++ b/src/routes/rss.nim @@ -1,7 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-only -import asyncdispatch, strutils, tables, times, hashes, supersnappy +import asyncdispatch, strutils, tables, times, hashes, uri -import jester +import jester, supersnappy import router_utils, timeline import ../query @@ -107,7 +107,7 @@ proc createRssRouter*(cfg: Config) = var key = @"tab" & ":" & @"name" & ":" if @"tab" == "search": - key &= $hash(genQueryUrl(query)) & "/" + key &= $hash(genQueryUrl(query)) & ":" key &= getCursor() var rss = await getCachedRss(key) @@ -119,6 +119,23 @@ proc createRssRouter*(cfg: Config) = await cacheRss(key, rss) respRss(rss) + get "/@name/lists/@slug/rss": + cond cfg.enableRss + cond @"name" != "i" + let + slug = decodeUrl(@"slug") + list = await getCachedList(@"name", slug) + cursor = getCursor() + + if list.id.len == 0: + resp Http404, showError("List \"" & @"slug" & "\" not found", cfg) + + let url = "/i/lists/" & list.id & "/rss" + if cursor.len > 0: + redirect(url & "?cursor=" & encodeUrl(cursor, false)) + else: + redirect(url) + get "/i/lists/@id/rss": cond cfg.enableRss let