diff --git a/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx b/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx index f897a3af..259d4a4d 100644 --- a/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx +++ b/frontend/src/components/TradeBox/EncryptedChat/EncryptedTurtleChat/index.tsx @@ -98,7 +98,7 @@ const EncryptedTurtleChat: React.FC = ({ .getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl); apiClient .get(url + basePath, `/api/chat/?order_id=${order.id}&offset=${lastIndex}`, { - tokenSHA256: garage.getSlot()?.tokenSHA256 ?? '', + tokenSHA256: garage.getSlot()?.getRobot()?.tokenSHA256 ?? '', }) .then((results: any) => { if (results != null) { @@ -127,7 +127,7 @@ const EncryptedTurtleChat: React.FC = ({ const onMessage = (dataFromServer: ServerMessage): void => { const slot = garage.getSlot(); const robot = slot?.getRobot(); - if (robot && dataFromServer != null) { + if (slot && robot && dataFromServer != null) { // If we receive an encrypted message if (dataFromServer.message.substring(0, 27) === `-----BEGIN PGP MESSAGE-----`) { void decryptMessage( @@ -196,7 +196,7 @@ const EncryptedTurtleChat: React.FC = ({ // If input string contains '#' send unencrypted and unlogged message else if (value.substring(0, 1) === '#') { const { url, basePath } = federation - .getCoordinator(garage.getSlot()?.activeOrder?.shortAlias) + .getCoordinator(garage.getSlot()?.activeOrder?.shortAlias ?? '') .getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl); apiClient .post( diff --git a/mobile/android/app/src/main/java/com/robosats/NotificationsService.java b/mobile/android/app/src/main/java/com/robosats/NotificationsService.java index 59046d18..f9c87490 100644 --- a/mobile/android/app/src/main/java/com/robosats/NotificationsService.java +++ b/mobile/android/app/src/main/java/com/robosats/NotificationsService.java @@ -144,9 +144,17 @@ public class NotificationsService extends Service { JSONObject slot = (JSONObject) slots.get(robotToken); JSONObject robots = slot.getJSONObject("robots"); JSONObject coordinatorRobot; - String shortAlias = slot.getString("activeShortAlias"); - coordinatorRobot = robots.getJSONObject(shortAlias); - fetchNotifications(coordinatorRobot, shortAlias); + String shortAlias = ""; + if (slot.has("activeShortAlias")) { + shortAlias = slot.getString("activeShortAlias"); + } else if (slot.has("activeOrder") && !slot.isNull("activeOrder")) { + JSONObject activeOrder = slot.getJSONObject("activeOrder"); + shortAlias = activeOrder.getString("shortAlias"); + } + if (!shortAlias.isBlank()) { + coordinatorRobot = robots.getJSONObject(shortAlias); + fetchNotifications(coordinatorRobot, shortAlias); + } } } catch (JSONException | InterruptedException e) { Log.d("NotificationsService", "Error reading garage: " + e);