Changeset c9c6a2d in Klonkt for src/routes/posts.js
- Timestamp:
- 06/21/2026 06:38:24 PM (3 months ago)
- Branches:
- main
- Children:
- 9a34d31
- Parents:
- d41f4be
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
rd41f4be rc9c6a2d 10 10 import { renderPage } from '../middleware/render.js'; 11 11 import { recordPageview, recordPostView } from '../services/StatsService.js'; 12 import { notify } from '../services/NotificationService.js'; 12 13 import PermissionsService from '../services/PermissionsService.js'; 13 14 import MarkdownService from '../services/MarkdownService.js'; … … 405 406 router.post('/posts/:id/like', requireAuth, (req, res) => { 406 407 const userId = req.session.user.id; 407 const post = db.prepare('SELECT id, status FROM posts WHERE id = ?').get(req.params.id);408 const post = db.prepare('SELECT id, status, slug, title, author_id FROM posts WHERE id = ?').get(req.params.id); 408 409 if (!post) return res.status(404).send('Post niet gevonden'); 409 410 if (post.status !== 'published') return res.status(403).send('Niet beschikbaar'); … … 414 415 } else { 415 416 db.prepare('INSERT OR IGNORE INTO post_likes (post_id, user_id) VALUES (?, ?)').run(post.id, userId); 417 // Melding voor de post-auteur (notify slaat jezelf-liken over). 418 notify({ 419 userId: post.author_id, actorId: userId, actorName: req.session.user.username, type: 'like', 420 postSlug: post.slug, postTitle: post.title, url: (res.locals.siteUrlBase || '') + '/' + post.slug, 421 }); 416 422 } 417 423 const likeCount = db.prepare('SELECT COUNT(*) AS c FROM post_likes WHERE post_id = ?').get(post.id).c;
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)