Skip to content

Commit

Permalink
Merge pull request #72 from BlueBubblesApp/zach/dev
Browse files Browse the repository at this point in the history
Zach/dev
  • Loading branch information
zlshames authored Oct 23, 2020
2 parents 6500a49 + 1a4547e commit c71a635
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluebubbles-server",
"version": "0.1.5",
"version": "0.1.6",
"description": "",
"main": "./dist/main.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/main/server/databases/imessage/entity/Message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/main/server/helpers/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion src/main/server/services/ngrok/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { app } from "electron";
import { Server } from "@server/index";
import { connect, disconnect, kill, authtoken } from "ngrok";

Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}

Expand Down
18 changes: 18 additions & 0 deletions src/main/server/services/socket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
});
Expand Down
1 change: 1 addition & 0 deletions src/main/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type MessageResponse = {
isServiceMessage: boolean;
isForward: boolean;
isArchived: boolean;
hasDdResults: boolean;
cacheRoomnames: string | null;
isAudioMessage: boolean;
datePlayed: number | null;
Expand Down

0 comments on commit c71a635

Please sign in to comment.