Changeset 0a75356 in Klonkt for src/routes
- Timestamp:
- 06/26/2026 11:55:09 PM (2 months ago)
- Branches:
- main
- Children:
- 7e66e7e
- Parents:
- 9d34855
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r9d34855 r0a75356 693 693 }); 694 694 695 // Like / unlike a feed post — a toggle. Fetch request → JSON {on} (stay on the page, 696 // no banner); no-JS → redirect back. 695 697 router.post('/news/like', requireSiteManager, async (req, res) => { 696 698 const site = res.locals.site; 697 699 const note = (req.body.note || '').toString(); 700 let on = false; 698 701 if (site && note) { 699 try { await ActivityPubService.sendInteraction(site, 'like', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 700 ActivityPubService.markLiked(site.slug, note); 701 } 702 res.redirect('/news?success=' + encodeURIComponent('Geliket ⭐')); 703 }); 704 705 router.post('/news/unlike', requireSiteManager, async (req, res) => { 702 on = !ActivityPubService.getTimelineReaction(site.slug, note).liked; 703 try { await ActivityPubService.sendInteraction(site, on ? 'like' : 'unlike', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 704 if (on) ActivityPubService.markLiked(site.slug, note); else ActivityPubService.unmarkLiked(site.slug, note); 705 } 706 if (req.get('X-Requested-With') === 'fetch') return res.json({ ok: true, on }); 707 res.redirect('/news'); 708 }); 709 710 // Boost / unboost a feed post — a toggle. markBoosted also surfaces it in the Cirkel. 711 router.post('/news/boost', requireSiteManager, async (req, res) => { 706 712 const site = res.locals.site; 707 713 const note = (req.body.note || '').toString(); 714 let on = false; 708 715 if (site && note) { 709 try { await ActivityPubService.sendInteraction(site, 'unlike', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 710 ActivityPubService.unmarkLiked(site.slug, note); 711 } 712 res.redirect('/news?success=' + encodeURIComponent('Like ingetrokken')); 713 }); 714 715 router.post('/news/boost', requireSiteManager, async (req, res) => { 716 const site = res.locals.site; 717 const note = (req.body.note || '').toString(); 718 if (site && note) { 719 try { await ActivityPubService.sendInteraction(site, 'boost', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 720 ActivityPubService.markBoosted(site.slug, note); // also surface it in the Cirkel (mixed by date) 721 } 722 res.redirect('/news?success=' + encodeURIComponent('Geboost 🔁')); 723 }); 724 725 // Unboost (retract): send Undo(Announce) + clear the local flag. 726 router.post('/news/unboost', requireSiteManager, async (req, res) => { 727 const site = res.locals.site; 728 const note = (req.body.note || '').toString(); 729 if (site && note) { 730 try { await ActivityPubService.sendInteraction(site, 'unboost', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 731 ActivityPubService.unmarkBoosted(site.slug, note); 732 } 733 res.redirect('/news?success=' + encodeURIComponent('Boost ingetrokken')); 716 on = !ActivityPubService.getTimelineReaction(site.slug, note).boosted; 717 try { await ActivityPubService.sendInteraction(site, on ? 'boost' : 'unboost', note, (req.body.author || '').toString()); } catch (e) { /* ignore */ } 718 if (on) ActivityPubService.markBoosted(site.slug, note); else ActivityPubService.unmarkBoosted(site.slug, note); 719 } 720 if (req.get('X-Requested-With') === 'fetch') return res.json({ ok: true, on }); 721 res.redirect('/news'); 734 722 }); 735 723
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)