Ignore:
Timestamp:
07/19/2026 11:58:47 PM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
162c7a7
Parents:
8ed65a6
Message:

Feature: Messages "poll finished" notification (klonkt-demo-93o)

Closed own polls surface a poll_done item in Messages with the final tally (bar+pct per option, voter count), derived read-time from poll_json.closed via ownPollView. i18n msg.poll_done/msg.poll_total (NL/EN/DE). Tests in messages.test.js.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    r8ed65a6 r544e9c2  
    26912691    }
    26922692  } catch { /* ignore */ }
     2693  // Your own polls that have closed → a "results are in" item, derived read-time
     2694  // from poll_json (Scheduler marks closed=1) with the tally via ownPollView.
     2695  try {
     2696    const site = db.prepare('SELECT id FROM sites WHERE slug = ?').get(slug);
     2697    if (site) {
     2698      const polls = db.prepare(`
     2699        SELECT id, slug, title, poll_json FROM posts
     2700        WHERE site_id = ? AND poll_json IS NOT NULL
     2701          AND json_extract(poll_json, '$.closed') = 1
     2702          AND json_extract(poll_json, '$.endTime') IS NOT NULL
     2703        ORDER BY json_extract(poll_json, '$.endTime') DESC LIMIT 20`).all(site.id);
     2704      for (const p of polls) {
     2705        const view = ownPollView(p);
     2706        if (!view) continue;
     2707        let endTime = null; try { endTime = JSON.parse(p.poll_json).endTime; } catch { /* keep null */ }
     2708        out.push({ type: 'poll_done', post_slug: p.slug, post_title: p.title, poll: view, created_at: endTime || null });
     2709      }
     2710    }
     2711  } catch { /* ignore */ }
    26932712  // NaN-safe sort: one row with a missing/garbled created_at would otherwise make the
    26942713  // comparator return NaN and scramble the WHOLE ordering (seen live: follow rows landing
Note: See TracChangeset for help on using the changeset viewer.