@7365admin1/layer-common 4.5.1-staging.301 → 4.5.1-staging.302
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -732,6 +732,7 @@ const {
|
|
|
732
732
|
makeIntercomCall,
|
|
733
733
|
finalizeIntercomCall,
|
|
734
734
|
ensureSipAccount,
|
|
735
|
+
notifyIntercomCall,
|
|
735
736
|
} = useHidAmico();
|
|
736
737
|
|
|
737
738
|
const activeTab = ref<IntercomTab>("intercom");
|
|
@@ -1442,8 +1443,10 @@ async function disconnectWebPhone() {
|
|
|
1442
1443
|
|
|
1443
1444
|
async function startWebCall() {
|
|
1444
1445
|
webPhoneActionLoading.value = true;
|
|
1446
|
+
const destination = webPhoneForm.destination;
|
|
1445
1447
|
try {
|
|
1446
|
-
await webPhone.call(
|
|
1448
|
+
await webPhone.call(destination);
|
|
1449
|
+
void ringResidentPhone(destination);
|
|
1447
1450
|
} catch (error: unknown) {
|
|
1448
1451
|
showMessage(getErrorMessage(error), "error");
|
|
1449
1452
|
} finally {
|
|
@@ -1451,6 +1454,50 @@ async function startWebCall() {
|
|
|
1451
1454
|
}
|
|
1452
1455
|
}
|
|
1453
1456
|
|
|
1457
|
+
/**
|
|
1458
|
+
* Wake the called resident's mobile so they are there to answer.
|
|
1459
|
+
*
|
|
1460
|
+
* Deliberately fired AFTER the INVITE and never awaited. The SIP leg is the
|
|
1461
|
+
* call: it is already ringing by the time this runs, and a resident whose
|
|
1462
|
+
* phone is asleep is the only thing this fixes. So a failure here is logged
|
|
1463
|
+
* and dropped rather than shown — telling the operator "call failed" for a
|
|
1464
|
+
* call that is ringing would be worse than a silent miss.
|
|
1465
|
+
*
|
|
1466
|
+
* A destination with no resident behind it (a staff extension, an external SIP
|
|
1467
|
+
* address) comes back `notified: false` with a reason and is not an error.
|
|
1468
|
+
*/
|
|
1469
|
+
async function ringResidentPhone(destination: string) {
|
|
1470
|
+
if (!props.org || !props.site) return;
|
|
1471
|
+
|
|
1472
|
+
try {
|
|
1473
|
+
// No `readerId`: this call came from the web phone, not a door station.
|
|
1474
|
+
// The reader selected in the table above is whatever the operator happens
|
|
1475
|
+
// to be looking at, and sending it would tell the resident's app the call
|
|
1476
|
+
// arrived at a door it never touched.
|
|
1477
|
+
await notifyIntercomCall(props.site, {
|
|
1478
|
+
orgId: props.org,
|
|
1479
|
+
destination,
|
|
1480
|
+
callId: createCallId(),
|
|
1481
|
+
});
|
|
1482
|
+
} catch (error: unknown) {
|
|
1483
|
+
console.warn("[intercom] could not send the incoming-call push", error);
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
/**
|
|
1488
|
+
* A per-call id, so a second push for the same call replaces the first on the
|
|
1489
|
+
* resident's lock screen rather than stacking a second ringing card.
|
|
1490
|
+
* `randomUUID` needs a secure context, which the web phone already requires —
|
|
1491
|
+
* getUserMedia does not run without one — but the fallback keeps a call from
|
|
1492
|
+
* failing on that account alone.
|
|
1493
|
+
*/
|
|
1494
|
+
function createCallId() {
|
|
1495
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
1496
|
+
return crypto.randomUUID();
|
|
1497
|
+
}
|
|
1498
|
+
return `call-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1454
1501
|
async function answerWebCall() {
|
|
1455
1502
|
webPhoneActionLoading.value = true;
|
|
1456
1503
|
try {
|
|
@@ -541,6 +541,29 @@ export default function useHidAmico() {
|
|
|
541
541
|
);
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Wake the resident's phone for a call the web phone has just placed.
|
|
546
|
+
*
|
|
547
|
+
* The SIP INVITE is the call and travels over the WebSocket, not through the
|
|
548
|
+
* API; this only rings the resident's mobile so somebody is there to answer
|
|
549
|
+
* it. It is therefore fired after the INVITE and never awaited in a way that
|
|
550
|
+
* could fail the call — see `startWebCall` in `HidIntercomManagement.vue`.
|
|
551
|
+
*
|
|
552
|
+
* `notified: false` with a reason is a normal response, not an error: staff
|
|
553
|
+
* extensions and external SIP addresses have no resident behind them.
|
|
554
|
+
*/
|
|
555
|
+
function notifyIntercomCall(
|
|
556
|
+
siteId: string,
|
|
557
|
+
payload: { orgId: string; destination: string; callId: string; readerId?: string },
|
|
558
|
+
) {
|
|
559
|
+
return useNuxtApp().$api<{
|
|
560
|
+
data: { notified: boolean; delivered?: number; reason?: string };
|
|
561
|
+
}>(
|
|
562
|
+
`${basePath}/sites/${siteId}/intercom/notify-call`,
|
|
563
|
+
{ method: "POST", body: payload },
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
544
567
|
function getPermissionCandidates(
|
|
545
568
|
siteId: string,
|
|
546
569
|
query: {
|
|
@@ -613,6 +636,7 @@ export default function useHidAmico() {
|
|
|
613
636
|
makeIntercomCall,
|
|
614
637
|
finalizeIntercomCall,
|
|
615
638
|
ensureSipAccount,
|
|
639
|
+
notifyIntercomCall,
|
|
616
640
|
getSitePermissions,
|
|
617
641
|
getPermissionCandidates,
|
|
618
642
|
updateSitePermissions,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.5.1-staging.
|
|
5
|
+
"version": "4.5.1-staging.302",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|