add daily discussion thread permalink

This commit is contained in:
keyan 2023-06-19 14:40:24 -05:00
parent 3e4161ae8c
commit cc6dc8c68b
3 changed files with 23 additions and 0 deletions

View File

@ -107,6 +107,10 @@ module.exports = withPWA({
source: '/guide', source: '/guide',
destination: '/items/81862' destination: '/items/81862'
}, },
{
source: '/daily',
destination: '/api/daily'
},
{ {
source: '/.well-known/lnurlp/:username', source: '/.well-known/lnurlp/:username',
destination: '/api/lnurlp/:username' destination: '/api/lnurlp/:username'

17
pages/api/daily.js Normal file
View File

@ -0,0 +1,17 @@
import models from '../../api/models'
export default async (_, res) => {
// get the latest daily discussion thread
// this should probably be made more generic
// eg if the title changes this will break
// ... but this will need to change when we have more subs anyway
const [{ id }] = await models.$queryRaw(`
SELECT id
FROM "Item"
WHERE "pinId" IS NOT NULL
AND title = 'Daily discussion thread'
ORDER BY created_at DESC
LIMIT 1`)
res.redirect(`/items/${id}`)
}

View File

@ -0,0 +1,2 @@
UPDATE users SET name = 'daily_squatter' WHERE name = 'daily';
INSERT INTO "users" ("name") VALUES ('daily');