Inbox as an app and push notifications
The Inbox can be installed as an app and each person with bos_crm_view turns on, on each device, “Notifications on this device” (“Notices” button in the Inbox bar). Class Builder_OS_CRM_Push (includes/modules/crm/class-builder-os-crm-push.php), loaded from Builder_OS_CRM_Inbox::load(): it only exists with the CRM loaded. Encryption in class-builder-os-crm-push-crypto.php.
PWA. Manifest at admin-ajax.php?action=bos_crm_manifest (also without a session: public data only, site name, icons —the site’s icon or BuilderOS’s—, start_url = Inbox, display: standalone) and service worker at admin-ajax.php?action=bos_crm_sw (text/javascript, no cache; template admin/js/builder-os-crm-sw.js with the translated texts prepended). Scope: <ruta de admin.php>?page=builder-os-crm (builder-os-crm* screens); the rest of the desktop is left out. It falls inside the script’s folder, so no Service-Worker-Allowed is sent. The SW doesn’t use the Cache API: everything goes to the network and there’s only an “Offline” page for navigations. Clicking the notice focuses the CRM window or opens the conversation’s URL (same origin only). The <head> of CRM screens adds the manifest and Safari meta tags (admin_head).
Keys and subscriptions. Web Push in pure PHP: VAPID P-256 keys created the first time, in the option builder_os_crm_push (public, private encrypted at rest with the plugin’s own secrets encryption, created). If the private key can no longer be decrypted (the site’s salts changed), new keys are created, all subscriptions are deleted and the bell notifies whoever sees the Inbox. Subscriptions go in the user meta bos_crm_push_subs (per device: endpoint, browser keys, label and date; the id is 16 hexadecimal characters of the endpoint’s SHA-256) and bos_crm_push_seen (bell ids already notified). Cap of 5 devices per person: going over removes the oldest. Only https endpoints, port 443, with no user or literal IP and from a known service (FCM, Mozilla, Apple, WNS) are accepted, a list filterable with builder_os_crm_push_hosts; it’s checked again before each send. A 404 or 410 response deletes the subscription; a 401 or 403 raises a bell notice (at most one a day).
What it notifies and when. An incoming message (builder_os_crm_message_received, in only) in one of the person’s conversations or an unassigned one they can see; a conversation assigned to them (builder_os_crm_conversation_assigned, unless they assign it to themselves); a conversation coming back from “snoozed” (builder_os_crm_conversation_woke); and new bell notices (a WP-Cron sweep builder_os_crm_push_scan every 10 minutes while there are subscribers and 15 s after a Builder_OS_Notifications::raise(); with several at once a single one goes out, “N new notices”; when the first device is activated, what was already there isn’t notified). Sending is a crm.push job in the queue (Builder_OS_Jobs, unique key per person and conversation) and at most one notification per conversation per minute to each person (transient bos_crm_push_t_<u>_<c>). With the CRM off, nothing goes out.
REST (builder-os/v1; all require bos_crm_view and a valid wp_rest nonce in X-WP-Nonce, only from the browser with a session): GET crm/push (support, public key, devices without endpoint or keys, cap), POST crm/push/subscribe (endpoint, 65-byte keys.p256dh, 16-byte keys.auth, label), POST crm/push/unsubscribe (id or endpoint) and POST crm/push/test (test notification, one every 10 s per person). Responses with Cache-Control: no-store; they never carry the private key or the endpoints. There are no MCP tools for this: subscriptions belong to a specific browser.
Privacy. The encrypted payload (aes128gcm, TTL 3600) only carries title, body (up to 80 characters, no HTML), url (the site’s own; otherwise the Inbox) and tag (bos-conv-<id>, also as Topic). Titles: “New message”, “A conversation was assigned to you” or “A snoozed conversation is back”; body is the contact’s name or, with no name, “Contact from <canal>”, never the phone or email. The message text, the preview or any other visitor text never goes out. On bell notices title is the notice’s title and body the site name. Nothing is written to any log.
Cleanup. When a person is deleted (delete_user) their metas are deleted; on uninstall, also the metas, the option, the cron event and the bos_crm_push_* transients. Without server support (OpenSSL EC, AES-GCM or secrets encryption) the feature is hidden and the box shows the reason. The “How notifications work” guide is registered as crm-push in the panel kit.
Hook. Filter builder_os_crm_push_hosts (see the hooks appendix).
Checklist (push notifications).
- The service worker’s scope is still only
?page=builder-os-crmand the SW doesn’t use the Cache API. - REST doesn’t return endpoints or the private key, and requires capability and nonce.
- The notification carries no message text, phone or email.
- A 410 deletes the subscription; it never exceeds one notification per conversation per minute or 5 devices per person.
- On iPhone and iPad the switch is explained outside the installed app (iOS 16.4 or later).