From a070ccb8cb5d81b323582c10620d217f9b72d1e2 Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 14:30:30 -0400 Subject: [PATCH 1/6] fix: disk access permissions --- packages/server/src/server/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/server/src/server/index.ts b/packages/server/src/server/index.ts index 4cb38560..3e1ebade 100644 --- a/packages/server/src/server/index.ts +++ b/packages/server/src/server/index.ts @@ -144,8 +144,15 @@ class BlueBubblesServer extends EventEmitter { region: string | null; get hasDiskAccess(): boolean { - const status = getAuthStatus("full-disk-access"); - return status === "authorized"; + // The default value is whether or not our DB is connected. + // If it's null, we still default to true because on macOS < 10.14, + // there are no FullDiskAccess options. + let status = this.iMessageRepo?.db?.isInitialized ?? true; + if (isMinMojave) { + status = (getAuthStatus("full-disk-access") === "authorized"); + } + + return status; } get hasAccessibilityAccess(): boolean { @@ -658,7 +665,7 @@ class BlueBubblesServer extends EventEmitter { } // Log if we dont have accessibility access - if (this.iMessageRepo?.db) { + if (this.hasDiskAccess) { this.log("Full-disk access permissions are enabled"); } else { this.log("Full-disk access permissions are required!", "error"); From 74c85ad47fde9c009e5b4fab4d48ebf499f0bafc Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 14:30:41 -0400 Subject: [PATCH 2/6] fix: ROWID issue when creating a chat --- .../server/src/server/api/v1/interfaces/chatInterface.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/server/src/server/api/v1/interfaces/chatInterface.ts b/packages/server/src/server/api/v1/interfaces/chatInterface.ts index 207e827d..5b3a18bf 100644 --- a/packages/server/src/server/api/v1/interfaces/chatInterface.ts +++ b/packages/server/src/server/api/v1/interfaces/chatInterface.ts @@ -203,7 +203,10 @@ export class ChatInterface { } const chat = chats[0]; - chat.messages = [sentMessage]; + if (sentMessage) { + chat.messages = [sentMessage]; + } + return chat; } From ec56ceddb0ec8fdd092213c9a299798be83892f6 Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 14:34:32 -0400 Subject: [PATCH 3/6] better disk access detection/consistency --- packages/server/src/server/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/server/index.ts b/packages/server/src/server/index.ts index 3e1ebade..24f680f8 100644 --- a/packages/server/src/server/index.ts +++ b/packages/server/src/server/index.ts @@ -972,7 +972,7 @@ class BlueBubblesServer extends EventEmitter { * we will emit a message to the socket, as well as the FCM server */ private startChatListeners() { - if (!this.iMessageRepo?.db) { + if (!this.hasDiskAccess) { AlertsInterface.create( "info", "Restart the app once 'Full Disk Access' and 'Accessibility' permissions are enabled" From 9418830356677a635f8167c4afd262b105f21947 Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 14:37:40 -0400 Subject: [PATCH 4/6] version bump --- package.json | 2 +- packages/server/package.json | 2 +- packages/ui/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index af2ae774..cc029d25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bluebubbles-server", - "version": "1.2.2", + "version": "1.2.3", "description": "BlueBubbles Server is the app that powers the BlueBubbles app ecosystem", "private": true, "workspaces": [ diff --git a/packages/server/package.json b/packages/server/package.json index bb146f13..ae6672ab 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@bluebubbles/server", - "version": "1.2.2", + "version": "1.2.3", "main": "./dist/main.js", "license": "Apache-2.0", "author": { diff --git a/packages/ui/package.json b/packages/ui/package.json index 68584e31..c45099e7 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@bluebubbles/ui", - "version": "1.2.2", + "version": "1.2.3", "homepage": "./", "license": "Apache-2.0", "scripts": { From cac396e6a2e89a42bf4143552aae49a19c30f94a Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 16:04:07 -0400 Subject: [PATCH 5/6] fix: outgoing error listener --- .../databases/imessage/listeners/outgoingMessageListener.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/server/src/server/databases/imessage/listeners/outgoingMessageListener.ts b/packages/server/src/server/databases/imessage/listeners/outgoingMessageListener.ts index 9b4b5ce7..3c8f1715 100644 --- a/packages/server/src/server/databases/imessage/listeners/outgoingMessageListener.ts +++ b/packages/server/src/server/databases/imessage/listeners/outgoingMessageListener.ts @@ -127,9 +127,8 @@ export class OutgoingMessageListener extends ChangeListener { // Reject the corresponding promise. // This will emit a message send error - const success = Server().messageManager.reject("message-send-error", entry); - Server().log( - `Errored Msg -> ${cacheName} -> ${(entry.text ?? "").substring(0, 25)} -> ${success}`, + const success = await Server().messageManager.reject("message-send-error", entry); + Server().log(`Errored Msg -> ${cacheName} -> ${entry.contentString()} -> ${success} (Code: ${entry.error})`, "debug" ); From 1b972291a0896797f9f2f410a7f479c420c3a79a Mon Sep 17 00:00:00 2001 From: zlshames Date: Sun, 28 Aug 2022 16:04:20 -0400 Subject: [PATCH 6/6] fix: better full disk access detection --- packages/server/src/server/index.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/server/src/server/index.ts b/packages/server/src/server/index.ts index 24f680f8..d3c0a46d 100644 --- a/packages/server/src/server/index.ts +++ b/packages/server/src/server/index.ts @@ -144,12 +144,21 @@ class BlueBubblesServer extends EventEmitter { region: string | null; get hasDiskAccess(): boolean { - // The default value is whether or not our DB is connected. - // If it's null, we still default to true because on macOS < 10.14, - // there are no FullDiskAccess options. - let status = this.iMessageRepo?.db?.isInitialized ?? true; + // As long as we've tried to initialize the DB, we know if we do/do not have access. + const dbInit: boolean | null = this.iMessageRepo?.db?.isInitialized; + if (dbInit != null) return dbInit; + + // If we've never initialized the DB, and just want to detect if we have access, + // we can check the permissions using node-mac-permissions. However, default to true, + // if the macOS version is under Mojave. + let status = true; if (isMinMojave) { - status = (getAuthStatus("full-disk-access") === "authorized"); + const authStatus = getAuthStatus("full-disk-access"); + if (authStatus === 'authorized') { + status = true; + } else { + this.log(`FullDiskAccess Permission Status: ${authStatus}`, 'debug'); + } } return status;