Changeset 5a6a457 in Klonkt for src/services/Scheduler.js
- Timestamp:
- 06/25/2026 05:15:48 AM (3 months ago)
- Branches:
- main
- Children:
- d7526bd
- Parents:
- 99234c3
- File:
-
- 1 edited
-
src/services/Scheduler.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/Scheduler.js
r99234c3 r5a6a457 10 10 import db from '../config/database.js'; 11 11 import HtmlSanitizerService from './HtmlSanitizerService.js'; 12 import ActivityPubService from './ActivityPubService.js'; 12 13 13 14 export function flipScheduledPosts() { 14 15 try { 15 16 const due = db.prepare(` 16 SELECT p.id, p.title, p.content, u.username 17 SELECT p.id, p.site_id, p.slug, p.title, p.content, p.cover_image_url, p.fan_only, 18 p.published_at, p.publish_at, p.created_at, u.username 17 19 FROM posts p JOIN users u ON u.id = p.author_id 18 20 WHERE p.status = 'scheduled' AND p.publish_at IS NOT NULL AND datetime(p.publish_at) <= datetime('now') … … 23 25 ); 24 26 const fts = db.prepare('INSERT INTO posts_fts(content, title, author, post_id) VALUES (?, ?, ?, ?)'); 27 const siteStmt = db.prepare('SELECT * FROM sites WHERE id = ?'); 25 28 for (const p of due) { 26 29 upd.run(p.id); 27 30 try { fts.run(HtmlSanitizerService.toPlainText(p.content || ''), p.title || '', p.username || '', p.id); } catch { /* FTS failure is non-fatal */ } 31 // ActivityPub: federate the now-published post to followers. 32 if (!p.fan_only) { 33 try { 34 const site = siteStmt.get(p.site_id); 35 if (site) { 36 ActivityPubService.deliverCreate(site, { 37 id: p.id, slug: p.slug, title: p.title || p.slug, 38 content: p.content, cover_image_url: p.cover_image_url || null, 39 published_at: p.published_at || p.publish_at, created_at: p.created_at, 40 }).catch(() => { /* best-effort */ }); 41 } 42 } catch { /* non-fatal */ } 43 } 28 44 } 29 45 return due.length;
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)