mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Merge pull request #1494 from RoboSats/fix-android-app-chat
Fix android app chat
This commit is contained in:
commit
ec28fae097
@ -98,7 +98,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
|||||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||||
apiClient
|
apiClient
|
||||||
.get(url + basePath, `/api/chat/?order_id=${order.id}&offset=${lastIndex}`, {
|
.get(url + basePath, `/api/chat/?order_id=${order.id}&offset=${lastIndex}`, {
|
||||||
tokenSHA256: garage.getSlot()?.tokenSHA256 ?? '',
|
tokenSHA256: garage.getSlot()?.getRobot()?.tokenSHA256 ?? '',
|
||||||
})
|
})
|
||||||
.then((results: any) => {
|
.then((results: any) => {
|
||||||
if (results != null) {
|
if (results != null) {
|
||||||
@ -127,7 +127,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
|||||||
const onMessage = (dataFromServer: ServerMessage): void => {
|
const onMessage = (dataFromServer: ServerMessage): void => {
|
||||||
const slot = garage.getSlot();
|
const slot = garage.getSlot();
|
||||||
const robot = slot?.getRobot();
|
const robot = slot?.getRobot();
|
||||||
if (robot && dataFromServer != null) {
|
if (slot && robot && dataFromServer != null) {
|
||||||
// If we receive an encrypted message
|
// If we receive an encrypted message
|
||||||
if (dataFromServer.message.substring(0, 27) === `-----BEGIN PGP MESSAGE-----`) {
|
if (dataFromServer.message.substring(0, 27) === `-----BEGIN PGP MESSAGE-----`) {
|
||||||
void decryptMessage(
|
void decryptMessage(
|
||||||
@ -196,7 +196,7 @@ const EncryptedTurtleChat: React.FC<Props> = ({
|
|||||||
// If input string contains '#' send unencrypted and unlogged message
|
// If input string contains '#' send unencrypted and unlogged message
|
||||||
else if (value.substring(0, 1) === '#') {
|
else if (value.substring(0, 1) === '#') {
|
||||||
const { url, basePath } = federation
|
const { url, basePath } = federation
|
||||||
.getCoordinator(garage.getSlot()?.activeOrder?.shortAlias)
|
.getCoordinator(garage.getSlot()?.activeOrder?.shortAlias ?? '')
|
||||||
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
.getEndpoint(settings.network, origin, settings.selfhostedClient, hostUrl);
|
||||||
apiClient
|
apiClient
|
||||||
.post(
|
.post(
|
||||||
|
@ -144,9 +144,17 @@ public class NotificationsService extends Service {
|
|||||||
JSONObject slot = (JSONObject) slots.get(robotToken);
|
JSONObject slot = (JSONObject) slots.get(robotToken);
|
||||||
JSONObject robots = slot.getJSONObject("robots");
|
JSONObject robots = slot.getJSONObject("robots");
|
||||||
JSONObject coordinatorRobot;
|
JSONObject coordinatorRobot;
|
||||||
String shortAlias = slot.getString("activeShortAlias");
|
String shortAlias = "";
|
||||||
coordinatorRobot = robots.getJSONObject(shortAlias);
|
if (slot.has("activeShortAlias")) {
|
||||||
fetchNotifications(coordinatorRobot, shortAlias);
|
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) {
|
} catch (JSONException | InterruptedException e) {
|
||||||
Log.d("NotificationsService", "Error reading garage: " + e);
|
Log.d("NotificationsService", "Error reading garage: " + e);
|
||||||
|
Loading…
Reference in New Issue
Block a user