Changeset 952baf3 in Klonkt for src/services/guardianship/follows.js
- Timestamp:
- 08/07/2026 05:15:52 PM (5 weeks ago)
- Branches:
- main
- Children:
- ba76bf5
- Parents:
- f85b2c3 (diff), 0d5bd2c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/services/guardianship/follows.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/guardianship/follows.js
rf85b2c3 r952baf3 81 81 _r = { 82 82 ins: db.prepare(`INSERT OR IGNORE INTO ap_follow_reviews 83 (id, guardian_slug, ward_uri, ward_inbox, follower_uri, follower_handle, follower_icon, follow_json, created_at) 84 VALUES (?,?,?,?,?,?,?,?, CURRENT_TIMESTAMP)`), 83 (id, guardian_slug, ward_uri, ward_inbox, follower_uri, follower_handle, follower_icon, follow_json, 84 direction, target_uri, target_handle, created_at) 85 VALUES (?,?,?,?,?,?,?,?,?,?,?, CURRENT_TIMESTAMP)`), 85 86 get: db.prepare('SELECT * FROM ap_follow_reviews WHERE guardian_slug = ? AND id = ?'), 86 87 bySlug: db.prepare("SELECT * FROM ap_follow_reviews WHERE guardian_slug = ? AND status = 'pending' ORDER BY created_at DESC"), … … 91 92 } 92 93 94 /** 95 * De guardian-zijdige kopie van een gate-verzoek op een REMOTE ward. 96 * 97 * `direction` is niet cosmetisch (shaer-jdb). Bij een INKOMENDE is de follower 98 * iemand anders en de ward het doel. Bij een UITGAANDE is de ward zelf de 99 * follower en staat het doel in het Follow-object -- die werd hiervoor 100 * opgeslagen als "deze ward wil deze ward volgen", met het doel weggegooid. 101 */ 93 102 export function recordReview(guardianSlug, r) { 94 rstmts().ins.run(r.id, guardianSlug, r.wardUri, r.wardInbox || null, r.follower, r.followerHandle || null, r.followerIcon || null, r.followJson || null); 103 const richting = r.direction === 'outgoing' ? 'outgoing' : 'incoming'; 104 rstmts().ins.run(r.id, guardianSlug, r.wardUri, r.wardInbox || null, r.follower, r.followerHandle || null, 105 r.followerIcon || null, r.followJson || null, richting, r.target || null, r.targetHandle || null); 95 106 return rstmts().get.get(guardianSlug, r.id); 107 } 108 109 /** 110 * Een openstaande review als wachtrij-item, in dezelfde vorm die de clients al 111 * lezen (offers en outgoing-follows doen het net zo). 112 */ 113 export function reviewQueueItem(r, me, guardianCount) { 114 // guardianCount blijft WEG als we hem niet kennen. Bij een remote ward wordt 115 // de guardian-set op diens eigen server bijgehouden, en 0 sturen zou lezen als 116 // "dit kind heeft geen guardians" -- het tegenovergestelde van onbekend. 117 const stemmen = (() => { 118 try { return db.prepare('SELECT guardian_uri, decision FROM ap_pending_follow_approvals WHERE follow_id = ?').all(r.id); } 119 catch { return []; } 120 })(); 121 const uitgaand = r.direction === 'outgoing'; 122 return { 123 id: r.id, 124 type: 'Follow', 125 // Bij een uitgaande is de WARD de volger; bij een inkomende is dat de vreemde. 126 actor: uitgaand ? r.ward_uri : r.follower_uri, 127 object: uitgaand ? (r.target_uri || '') : r.ward_uri, 128 'shaer:direction': uitgaand ? 'outgoing' : 'incoming', 129 'shaer:ward': r.ward_uri, 130 'shaer:target': uitgaand ? (r.target_uri || undefined) : undefined, 131 'shaer:targetHandle': uitgaand ? (r.target_handle || undefined) : undefined, 132 'shaer:follower': uitgaand ? undefined : r.follower_uri, 133 'shaer:followerHandle': uitgaand ? undefined : (r.follower_handle || undefined), 134 'shaer:quorum': 'all', 135 'shaer:approvals': stemmen.filter((x) => x.decision === 'approve').length, 136 'shaer:guardianCount': guardianCount || undefined, 137 'shaer:myVote': stemmen.some((x) => x.guardian_uri === me), 138 published: r.created_at, 139 }; 140 } 141 142 /** De openstaande reviews van een guardian, per richting. */ 143 export function listReviewsByDirection(guardianSlug, direction) { 144 return listReviews(guardianSlug).filter((r) => (r.direction === 'outgoing' ? 'outgoing' : 'incoming') === direction); 96 145 } 97 146 export function getReview(guardianSlug, id) { return rstmts().get.get(guardianSlug, id); } … … 102 151 recordPending, getPending, listForWard, decide, remove, 103 152 recordReview, getReview, listReviews, removeReview, 153 listReviewsByDirection, reviewQueueItem, 104 154 };
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)