Changeset 86e6a45 in Klonkt for src/services/guardianship/queues.js
- Timestamp:
- 08/08/2026 07:24:44 AM (5 weeks ago)
- Branches:
- main
- Children:
- a9ede28
- Parents:
- 0b0cd54
- git-author:
- Robin <roboburr@…> (08/08/2026 07:24:42 AM)
- git-committer:
- roboburr <roboburr@…> (08/08/2026 07:24:44 AM)
- File:
-
- 1 edited
-
src/services/guardianship/queues.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/queues.js
r0b0cd54 r86e6a45 16 16 import * as gated from './gated.js'; 17 17 import * as gatereq from './gatereq.js'; 18 import * as help from './help.js'; 19 import db from '../../config/database.js'; 18 20 import * as handshake from './handshake.js'; 19 21 … … 116 118 } 117 119 118 export default { offersCollection, followsCollection, outgoingFollowsCollection, wardsCollection, guardiansCollection, wardGates, wardGuardianStatuses };120 export default { offersCollection, followsCollection, outgoingFollowsCollection, wardsCollection, guardiansCollection, helpCollection, helpItemsFor, wardGates, wardGuardianStatuses }; 119 121 120 122 // ── Wat er voor een ward gated is (shaer-ahy.1) ───────────────────────── … … 179 181 }); 180 182 } 183 184 185 // ── Hulpvragen met hun staat (shaer-lgo, shaer-ahy.1) ─────────────────── 186 // 187 // De PWA had dit al; de apps kregen alleen de losse notes uit de feed en wisten 188 // dus NIET of er al iemand op af was. Daarom bleef een afgehandeld verzoek daar 189 // gewoon staan -- Barts melding. De staat wordt hier een keer berekend, zoals bij 190 // wardGates: twee berekeningen zouden twee guardians een ander beeld geven van 191 // hetzelfde kind. 192 193 /** De hulpvragen van deze guardian, met wie erop af is en of het dicht is. */ 194 export function helpItemsFor(slug, limit = 50) { 195 let rijen = []; 196 try { 197 rijen = db.prepare( 198 `SELECT object_uri, actor_uri, actor_name, actor_handle, actor_icon, content, published, created_at 199 FROM ap_mentions WHERE slug = ? AND help_request = 1 ORDER BY created_at DESC LIMIT ?`, 200 ).all(slug, limit); 201 } catch { return []; } 202 const staat = help.statusFor(rijen.map((r) => r.object_uri)); 203 const mijn = new Set(relations.listWards(slug).map((w) => w.other_uri)); 204 return rijen.map((r) => ({ 205 ...r, 206 // Bij twijfel OPEN. Een hulpvraag die er afgehandeld uitziet terwijl hij dat 207 // niet is, is de gevaarlijke fout -- niet andersom. 208 state: help.withWardship( 209 staat.get(r.object_uri) || { open: true, pickedUpBy: [], handled: null, ageMs: null }, 210 mijn.has(r.actor_uri), 211 ), 212 })); 213 } 214 215 /** Dezelfde vragen als collectie voor de apps (5.2.1). */ 216 export function helpCollection(id, slug) { 217 const items = helpItemsFor(slug).map((h) => ({ 218 id: h.object_uri, 219 type: 'Note', 220 attributedTo: h.actor_uri, 221 'shaer:handle': h.actor_handle || undefined, 222 content: h.content || '', 223 published: h.published || h.created_at, 224 'shaer:helpRequest': true, 225 // De staat als platte velden: een app hoeft hem niet af te leiden, en kan 226 // hem dus ook niet anders afleiden dan het paneel. 227 'shaer:open': h.state.open, 228 'shaer:handledBy': h.state.handled ? (h.state.handled.handle || h.state.handled.uri) : undefined, 229 'shaer:handledAt': h.state.handled ? h.state.handled.at : undefined, 230 'shaer:pickedUpBy': h.state.pickedUpBy.map((p) => p.handle || p.uri), 231 'shaer:formerWard': h.state.formerWard || undefined, 232 })); 233 return collection(id, items); 234 }
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)