Changeset 3bbf73d in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 08/10/2026 02:43:16 PM (4 weeks ago)
- Branches:
- main
- Children:
- f0a33e1
- Parents:
- f549cf5
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
rf549cf5 r3bbf73d 4210 4210 // visibility 'direct'. Een publiek antwoord is geen gesprek en hoort niet als 4211 4211 // gezicht in de hemel. 4212 const GESPREK_UNIE= `4212 const CONVERSATION_UNION = ` 4213 4213 SELECT m.actor_uri AS other, COALESCE(m.published, m.created_at) AS stamp, 4214 'in' AS richting, m.object_uri AS ref4214 'in' AS direction, m.object_uri AS ref 4215 4215 FROM ap_mentions m 4216 4216 WHERE m.slug = @slug AND m.actor_uri IS NOT NULL AND m.actor_uri <> '' 4217 4217 UNION ALL 4218 4218 SELECT j.value AS other, o.created_at AS stamp, 4219 ' uit' AS richting, o.id AS ref4219 'out' AS direction, o.id AS ref 4220 4220 FROM ap_outbox o 4221 4221 JOIN json_each(COALESCE(NULLIF(o.to_actors, ''), json_array(o.to_actor))) j … … 4233 4233 try { 4234 4234 return db.prepare(` 4235 SELECT other, stamp, richting, ref FROM (4235 SELECT other, stamp, direction, ref FROM ( 4236 4236 SELECT *, ROW_NUMBER() OVER (PARTITION BY other ORDER BY stamp DESC, ref DESC) AS rn 4237 FROM (${ GESPREK_UNIE})4237 FROM (${CONVERSATION_UNION}) 4238 4238 ) WHERE rn = 1 4239 4239 ORDER BY stamp DESC, ref DESC`).all({ slug }); … … 4260 4260 * ontbreekt alleen iets in het midden. 4261 4261 */ 4262 const cursor Van= (r) => (r ? `${r.stamp}|${r.ref}` : null);4262 const cursorOf = (r) => (r ? `${r.stamp}|${r.ref}` : null); 4263 4263 4264 4264 export function conversationHistory(slug, other, { before = null, limit = 60 } = {}) { 4265 4265 try { 4266 4266 const n = Math.min(Math.max(parseInt(limit, 10) || 60, 1), 200); 4267 const knip = String(before || '').indexOf('|');4268 const bStamp = before && knip > 0 ? String(before).slice(0, knip) : null;4269 const bRef = before && knip > 0 ? String(before).slice(knip + 1) : null;4270 const r ijen= db.prepare(`4271 SELECT other, stamp, richting, ref FROM (${GESPREK_UNIE})4267 const sep = String(before || '').indexOf('|'); 4268 const bStamp = before && sep > 0 ? String(before).slice(0, sep) : null; 4269 const bRef = before && sep > 0 ? String(before).slice(sep + 1) : null; 4270 const rows = db.prepare(` 4271 SELECT other, stamp, direction, ref FROM (${CONVERSATION_UNION}) 4272 4272 WHERE other = @other 4273 4273 AND (@bStamp IS NULL OR stamp < @bStamp OR (stamp = @bStamp AND ref < @bRef)) 4274 4274 ORDER BY stamp DESC, ref DESC LIMIT @n`).all({ slug, other, bStamp, bRef, n: n + 1 }); 4275 const m eer = rijen.length > n;4276 const uit = meer ? rijen.slice(0, n) : rijen;4277 return { r ijen: uit, meer, oudste: cursorVan(uit[uit.length - 1]) };4278 } catch { return { r ijen: [], meer: false, oudste: null }; }4275 const more = rows.length > n; 4276 const page = more ? rows.slice(0, n) : rows; 4277 return { rows: page, more, oldest: cursorOf(page[page.length - 1]) }; 4278 } catch { return { rows: [], more: false, oldest: null }; } 4279 4279 } 4280 4280 4281 4281 // De kolommen die een bericht tot kaart maken. Een constante, want de 4282 // gesprekslezing haalt dezelfde r ijenop: twee lijsten die uiteenlopen leveren4282 // gesprekslezing haalt dezelfde rows op: twee lijsten die uiteenlopen leveren 4283 4283 // een kaart die op de ene plek een plaatje heeft en op de andere niet. 4284 const BERICHT_KOLOMMEN= `4284 const MESSAGE_COLUMNS = ` 4285 4285 m.object_uri, m.note_url, m.actor_uri, m.actor_name, m.actor_handle, m.actor_icon, m.actor_url, 4286 4286 m.content, m.published, m.created_at, m.wave, m.help_request, … … 4293 4293 try { 4294 4294 const gaten = lijst.map(() => '?').join(','); 4295 return db.prepare(`SELECT ${ BERICHT_KOLOMMEN} FROM ap_mentions m4295 return db.prepare(`SELECT ${MESSAGE_COLUMNS} FROM ap_mentions m 4296 4296 WHERE m.slug = ? AND m.object_uri IN (${gaten})`).all(slug, ...lijst); 4297 4297 } catch { return []; } … … 4301 4301 try { 4302 4302 return db.prepare(` 4303 SELECT ${ BERICHT_KOLOMMEN}4303 SELECT ${MESSAGE_COLUMNS} 4304 4304 FROM ap_mentions m 4305 4305 WHERE m.slug = ?
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)