Changeset 3d37c67 in Klonkt for src/routes
- Timestamp:
- 06/26/2026 11:38:25 PM (2 months ago)
- Branches:
- main
- Children:
- 2f42b60
- Parents:
- 3289a64
- File:
-
- 1 edited
-
src/routes/posts.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/routes/posts.js
r3289a64 r3d37c67 502 502 liked: !!req.query.liked, 503 503 boosted: !!req.query.boosted, 504 reacted: (site && uri) ? ActivityPubService.getMyReactions(site.slug, uri) : { liked: false, boosted: false }, 504 505 siteTitle: site ? site.title : '', 505 506 }); 506 507 }); 507 508 508 // ⭐ Like a remote post from your own site (the star flow lands here).509 // ⭐ Like / unlike a remote post from your own site (toggle on the interact page). 509 510 router.post('/authorize_interaction/like', requireSiteManager, (req, res) => { 510 511 const site = res.locals.site; 511 512 const uri = (req.body.uri || '').toString(); 512 513 if (site && uri) { 514 const on = !ActivityPubService.getMyReactions(site.slug, uri).liked; 513 515 ActivityPubService.resolveRemoteNote(uri) 514 .then((note) => note && ActivityPubService.sendInteraction(site, 'like', note.object_uri || uri, note.actor_uri))516 .then((note) => note && ActivityPubService.sendInteraction(site, on ? 'like' : 'unlike', note.object_uri || uri, note.actor_uri)) 515 517 .catch((e) => console.warn('[AP] remote like failed:', e.message)); 516 } 517 res.redirect('/authorize_interaction?liked=1&uri=' + encodeURIComponent(uri)); 518 }); 519 520 // 🔁 Boost a remote post from your own site. Also flags it for the Cirkel 521 // (markBoosted is a no-op if the post isn't in your timeline). 518 ActivityPubService.setMyReaction(site.slug, uri, 'like', on); 519 } 520 res.redirect('/authorize_interaction?uri=' + encodeURIComponent(uri)); 521 }); 522 523 // 🔁 Boost / unboost a remote post from your own site (toggle on the interact page). 524 // Also flags it for the Cirkel (markBoosted is a no-op if the post isn't in your timeline). 522 525 router.post('/authorize_interaction/boost', requireSiteManager, (req, res) => { 523 526 const site = res.locals.site; 524 527 const uri = (req.body.uri || '').toString(); 525 528 if (site && uri) { 529 const on = !ActivityPubService.getMyReactions(site.slug, uri).boosted; 526 530 ActivityPubService.resolveRemoteNote(uri) 527 531 .then((note) => { 528 532 if (!note) return; 529 533 const id = note.object_uri || uri; 530 return Promise.resolve(ActivityPubService.sendInteraction(site, 'boost', id, note.actor_uri))531 .then(() => ActivityPubService.markBoosted(site.slug, id));534 return Promise.resolve(ActivityPubService.sendInteraction(site, on ? 'boost' : 'unboost', id, note.actor_uri)) 535 .then(() => on ? ActivityPubService.markBoosted(site.slug, id) : ActivityPubService.unmarkBoosted(site.slug, id)); 532 536 }) 533 537 .catch((e) => console.warn('[AP] remote boost failed:', e.message)); 534 } 535 res.redirect('/authorize_interaction?boosted=1&uri=' + encodeURIComponent(uri)); 538 ActivityPubService.setMyReaction(site.slug, uri, 'boost', on); 539 } 540 res.redirect('/authorize_interaction?uri=' + encodeURIComponent(uri)); 536 541 }); 537 542
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)