Add save-to-device export, server export route and an On other devices P2P list

This commit is contained in:
Claude
2026-10-01 18:53:00 +00:00
parent 08e95814e5
commit 02b337fcbc
10 changed files with 385 additions and 0 deletions

View File

@@ -69,3 +69,17 @@ test('views per day and window sums', async () => {
expect(s.content).toBe(1);
expect(s.devices).toBe(1);
});
test('listSharedContent: newest verified file per video, only with sharing holders counted', async () => {
const V = 'sharedVid01', C1 = 'c'.repeat(64), C2 = 'd'.repeat(64);
await P.createDevice({ deviceId: 'dev_00000000000000a1', secretHash: 'x', fingerprint: null, profile: null, now: T0 });
await P.createDevice({ deviceId: 'dev_00000000000000a2', secretHash: 'x', fingerprint: null, profile: null, now: T0 });
await P.touchDevice('dev_00000000000000a2', { now: T0, share: 0 });
await P.upsertContent({ cid: C1, videoId: V, size: 10, duration: 5, meta: { title: 'Old' }, origin: 'server', now: T0 });
await P.upsertContent({ cid: C2, videoId: V, size: 20, duration: 5, meta: { title: 'New' }, origin: 'intake', now: T0 + 5000 });
await P.upsertHolder({ cid: C2, deviceId: 'dev_00000000000000a1', now: T0 });
await P.upsertHolder({ cid: C2, deviceId: 'dev_00000000000000a2', now: T0 }); // does not share
const rows = (await P.listSharedContent(50)).filter((r) => r.video_id === V);
expect(rows.length).toBe(1);
expect(rows[0]).toMatchObject({ cid: C2, holders: 1 });
});