diff --git a/src/app_service/service/contacts/dto/status_update.nim b/src/app_service/service/contacts/dto/status_update.nim index 0d8813c6be..a9b4f3a7fc 100644 --- a/src/app_service/service/contacts/dto/status_update.nim +++ b/src/app_service/service/contacts/dto/status_update.nim @@ -1,8 +1,8 @@ import json include ../../../common/json_utils -type StatusType* {.pure.}= enum - Offline = 0, +type StatusType* {.pure.} = enum + Offline = 0 Online DoNotDisturb Idle diff --git a/src/app_service/service/settings/service.nim b/src/app_service/service/settings/service.nim index 39a158ac2c..b452037662 100644 --- a/src/app_service/service/settings/service.nim +++ b/src/app_service/service/settings/service.nim @@ -3,8 +3,10 @@ import chronicles, json, strutils, sequtils, tables, sugar import ../../common/[network_constants] import ../../../app/core/fleets/fleet_configuration import ../../../backend/settings as status_settings +import ../../../backend/status_update as status_update import ./dto/settings as settings_dto +import ../contacts/dto/status_update as status_update_dto import ../stickers/dto/stickers as stickers_dto import ../../../app/core/fleets/fleet_configuration @@ -294,10 +296,18 @@ proc getWalletRootAddress*(self: Service): string = return self.settings.walletRootAddress proc saveSendStatusUpdates*(self: Service, value: bool): bool = - if(self.saveSetting(KEY_SEND_STATUS_UPDATES, value)): - self.settings.sendStatusUpdates = value - return true - return false + var newStatus = StatusType.Online + if not value: + newStatus = StatusType.Offline + + try: + let r = status_update.setUserStatus(int(newStatus)) + if(self.saveSetting(KEY_SEND_STATUS_UPDATES, value)): + self.settings.sendStatusUpdates = value + return true + return false + except: + return false proc getSendStatusUpdates*(self: Service): bool = self.settings.sendStatusUpdates diff --git a/src/backend/status_update.nim b/src/backend/status_update.nim new file mode 100644 index 0000000000..6d8d21eb24 --- /dev/null +++ b/src/backend/status_update.nim @@ -0,0 +1,8 @@ +import json +import ./core, ./response_type + +export response_type + +proc setUserStatus*(newStatus: int): RpcResponse[JsonNode] {.raises: [Exception].} = + let payload = %* [newStatus, ""] + result = core.callPrivateRPC("wakuext_setUserStatus", payload)