SPB Git forge

spb/groupe-ka

Public

Groupe KA — site du holding + KA ID (compte unique & SSO des 7 plateformes). Next.js 16, SQLite, Google & Apple login.

81commits 1branches 0releases
89.2 MBsize
maindefault branch
22 days agolast push
TypeScript 70.4% HTML 18.4% JavaScript 4% Python 3.8% CSS 3.4%

feat(ka-id v2): le hub journalise favorite/unfavorite à la réception de /api/sso/favorites (features via item.meta) — couvre les plateformes sans instrumentation propre (vrai-prix, valoplex, toit-ka…)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Simon-Pierre Boucher committed 1 mo ago (Aug 26, 2026) parent 52cbd0c

1 changed file +16 −0

modified src/app/api/sso/favorites/route.ts +16 −0
@@ -14,6 +14,7 @@ import {
14 14 favoritesOf,
15 15 } from "@/lib/db";
16 16 import { verifyClientSig } from "@/lib/sso";
17 +import { ingestEvents, privacyOf } from "@/lib/kaid-data";
17 18
18 19 const clip = (v: unknown, max: number): string =>
19 20 typeof v === "string" ? v.trim().slice(0, max) : "";
@@ -35,6 +36,9 @@ export async function POST(req: NextRequest) {
35 36
36 37 if (body.action === "remove") {
37 38 removeFavorite(user.id, clientId, itemId);
39 + // signal négatif du moteur de préférences (KA ID v2)
40 + if (privacyOf(user.id).history)
41 + ingestEvents(user.id, clientId, [{ type: "unfavorite", entity_id: itemId }]);
38 42 return NextResponse.json({ ok: true, action: "remove" });
39 43 }
40 44 const title = clip(item.title, 200);
@@ -49,6 +53,18 @@ export async function POST(req: NextRequest) {
49 53 url: clip(item.url, 500) || undefined,
50 54 meta: item.meta,
51 55 });
56 + // signal fort du moteur de préférences (KA ID v2) — les features viennent
57 + // du meta du favori quand la plateforme les fournit
58 + if (privacyOf(user.id).history) {
59 + const meta = (item.meta ?? null) as Record<string, unknown> | null;
60 + const features =
61 + meta && typeof meta === "object"
62 + ? ((meta.features ?? meta) as Record<string, unknown>)
63 + : undefined;
64 + ingestEvents(user.id, clientId, [
65 + { type: "favorite", entity_id: itemId, features },
66 + ]);
67 + }
52 68 return NextResponse.json({ ok: true, action: "add" });
53 69 }
54 70
55 71