openvibers/openvibe.network Commits

Connect may push 'it is back' notifications (CON-17) (#535)

OP OpenVibers committed 11 days ago · efb4bf5d63 · 2 files, +19 −0

Changes

ddiff --git a/server/identity/principals.js b/server/identity/principals.js
iindex 4322262c..24276ef5 100644
---- a/server/identity/principals.js
++++ b/server/identity/principals.js
@@@ -665,6 +665,9 @@ const DEFAULT_GRANTS = [
// OpenVibe Connect (contracts 0.279.0, Website Connect v0): its account-event subscriptions at boot. It publishes
// nothing yet; export and deletion are above.
['connect', 'events.subscription.manage', 'openvibe.events', []],
++ // "Tell me when it's back" (CON-17, 11-02): one notification, as app connect, to a person who asked when a share's
++ // computer connects again. Nothing else of Network's notifications.
++ ['connect', 'network.notifications.push', SELF_AUDIENCE, ['connect']],
// OpenVibe.Report (contracts 0.237.0): it quotes Billing's read API and never computes money, so it holds the
// stats read and the per-subject balance read; it subscribes to live.stream.ended and the frame beacon at boot.
// It keeps nothing about people (no database and no account-data route), so it holds neither export nor deletion.
ddiff --git a/test/connect-notify-grant.test.js b/test/connect-notify-grant.test.js
nnew file mode 100644
iindex 00000000..0b5ce418
---- /dev/null
++++ b/test/connect-notify-grant.test.js
@@@ -0,0 +1,16 @@
++/**
++ * OpenVibe Connect's notification grant (CON-17, "tell me when it's back"): Connect pushes one notification as app
++ * connect to a person who asked, and holds nothing else of Network's notifications.
++ *
++ * node test/connect-notify-grant.test.js
++ */
++'use strict';
++const assert = require('assert');
++const contracts = require('openvibe-contracts');
++const principals = require('../server/identity/principals');
++
++const rows = principals.DEFAULT_GRANTS.filter((g) => g[0] === 'connect' && g[2] === principals.SELF_AUDIENCE && /^network\.notifications\./.test(g[1]));
++assert.deepStrictEqual(rows.map((g) => [g[1], g[3]]), [['network.notifications.push', ['connect']]], 'connect pushes as its own app only, and holds nothing else of Network\'s notifications');
++const cap = contracts.capabilities.get('network.notifications.push');
++assert.ok(cap && cap.status === 'active', 'an active capability');
++console.log('connect notify grant: ok');