mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Fix android app chat
This commit is contained in:
parent
3a50c2091b
commit
a6614191bc
@ -98,7 +98,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
||||
.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<Props> = ({
|
||||
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<Props> = ({
|
||||
// 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(
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user