fix: broadcast update when changing status

Fixes #5798
This commit is contained in:
Richard Ramos 2022-05-25 08:46:13 -04:00 committed by Iuri Matias
parent 5967ce6ce8
commit 92d047173f
3 changed files with 24 additions and 6 deletions

View File

@ -1,8 +1,8 @@
import json import json
include ../../../common/json_utils include ../../../common/json_utils
type StatusType* {.pure.}= enum type StatusType* {.pure.} = enum
Offline = 0, Offline = 0
Online Online
DoNotDisturb DoNotDisturb
Idle Idle

View File

@ -3,8 +3,10 @@ import chronicles, json, strutils, sequtils, tables, sugar
import ../../common/[network_constants] import ../../common/[network_constants]
import ../../../app/core/fleets/fleet_configuration import ../../../app/core/fleets/fleet_configuration
import ../../../backend/settings as status_settings import ../../../backend/settings as status_settings
import ../../../backend/status_update as status_update
import ./dto/settings as settings_dto import ./dto/settings as settings_dto
import ../contacts/dto/status_update as status_update_dto
import ../stickers/dto/stickers as stickers_dto import ../stickers/dto/stickers as stickers_dto
import ../../../app/core/fleets/fleet_configuration import ../../../app/core/fleets/fleet_configuration
@ -294,10 +296,18 @@ proc getWalletRootAddress*(self: Service): string =
return self.settings.walletRootAddress return self.settings.walletRootAddress
proc saveSendStatusUpdates*(self: Service, value: bool): bool = proc saveSendStatusUpdates*(self: Service, value: bool): bool =
if(self.saveSetting(KEY_SEND_STATUS_UPDATES, value)): var newStatus = StatusType.Online
self.settings.sendStatusUpdates = value if not value:
return true newStatus = StatusType.Offline
return false
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 = proc getSendStatusUpdates*(self: Service): bool =
self.settings.sendStatusUpdates self.settings.sendStatusUpdates

View File

@ -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)