diff --git a/package.json b/package.json index bb06d34b..eb998c6e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bluebubbles-server", - "version": "0.1.5", + "version": "0.1.6", "description": "", "main": "./dist/main.js", "scripts": { diff --git a/src/main/server/databases/imessage/entity/Message.ts b/src/main/server/databases/imessage/entity/Message.ts index e6076853..ef6b2fea 100644 --- a/src/main/server/databases/imessage/entity/Message.ts +++ b/src/main/server/databases/imessage/entity/Message.ts @@ -430,6 +430,7 @@ export const getMessageResponse = async (tableData: Message, withBlurhash = true isArchived: tableData.isArchived, cacheRoomnames: tableData.cacheRoomnames, isAudioMessage: tableData.isAudioMessage, + hasDdResults: tableData.hasDdResults, datePlayed: tableData.datePlayed ? tableData.datePlayed.getTime() : null, itemType: tableData.itemType, groupTitle: tableData.groupTitle, diff --git a/src/main/server/helpers/actions.ts b/src/main/server/helpers/actions.ts index 9c2cd55c..813641d9 100644 --- a/src/main/server/helpers/actions.ts +++ b/src/main/server/helpers/actions.ts @@ -58,7 +58,7 @@ export class ActionHandler { await FileSystem.startMessages(); // We need offsets here due to iMessage's save times being a bit off for some reason - const now = new Date(new Date().getTime() - 3000).getTime(); // With 3 second offset + const now = new Date(new Date().getTime() - 10000).getTime(); // With 10 second offset await FileSystem.executeAppleScript( sendMessage( chatGuid, diff --git a/src/main/server/services/ngrok/index.ts b/src/main/server/services/ngrok/index.ts index 31ab6d21..3133b144 100644 --- a/src/main/server/services/ngrok/index.ts +++ b/src/main/server/services/ngrok/index.ts @@ -1,3 +1,4 @@ +import { app } from "electron"; import { Server } from "@server/index"; import { connect, disconnect, kill, authtoken } from "ngrok"; @@ -119,7 +120,7 @@ export class NgrokService { tries += 1; // Set the wait time based on which try we are attempting - const wait = tries > 1 ? 5000 * tries : 1000; + const wait = tries > 1 ? 2000 * tries : 1000; Server().log(`Attempting to restart ngrok (attempt ${tries}; ${wait} ms delay)`); connected = await this.restartHandler(wait); } @@ -131,6 +132,12 @@ export class NgrokService { Server().log(`Failed to connect to ngrok after ${maxTries} tries`); } + if (tries >= maxTries) { + Server().log("Reached maximum retry attempts for Ngrok. Force restarting app..."); + app.relaunch({ args: process.argv.slice(1).concat(["--relaunch"]) }); + app.exit(0); + } + return connected; } diff --git a/src/main/server/services/socket/index.ts b/src/main/server/services/socket/index.ts index 28a89764..64711305 100644 --- a/src/main/server/services/socket/index.ts +++ b/src/main/server/services/socket/index.ts @@ -687,6 +687,24 @@ export class SocketService { } ); + /** + * Tells all clients that a chat is read + */ + socket.on("toggle-chat-read-status", (params, cb): void => { + // Make sure we have all the required data + if (!params?.chatGuid) return respond(cb, "error", createBadRequestResponse("No chat GUID provided!")); + if (!params?.status) return respond(cb, "error", createBadRequestResponse("No chat status provided!")); + + // Send the notification out to all clients + Server().emitMessage("chat-read-status-changed", { + chatGuid: params.chatGuid, + status: params.status + }); + + // Return null so Typescript doesn't yell at us + return null; + }); + socket.on("disconnect", reason => { Server().log(`Client ${socket.id} disconnected! Reason: ${reason}`); }); diff --git a/src/main/server/types.ts b/src/main/server/types.ts index 01778f46..5ac80005 100644 --- a/src/main/server/types.ts +++ b/src/main/server/types.ts @@ -59,6 +59,7 @@ export type MessageResponse = { isServiceMessage: boolean; isForward: boolean; isArchived: boolean; + hasDdResults: boolean; cacheRoomnames: string | null; isAudioMessage: boolean; datePlayed: number | null;