fix(@desktop/notifications): move notifications settings to `status-go`

Fixes #5649
This commit is contained in:
Sale Djenic 2022-05-10 15:15:56 +02:00 committed by saledjenic
parent 72c389ba09
commit aeba272ae4
14 changed files with 1010 additions and 750 deletions

View File

@ -47,6 +47,7 @@ type
notificationsManager*: NotificationsManager
# Global
appSettingsVariant: QVariant
localAppSettingsVariant: QVariant
localAccountSettingsVariant: QVariant
localAccountSensitiveSettingsVariant: QVariant
@ -111,18 +112,21 @@ proc connect(self: AppController) =
proc newAppController*(statusFoundation: StatusFoundation): AppController =
result = AppController()
result.statusFoundation = statusFoundation
result.notificationsManager = newNotificationsManager(statusFoundation.events)
# Preparing settings service to be exposed later as global QObject
result.settingsService = settings_service.newService()
result.appSettingsVariant = newQVariant(result.settingsService)
result.notificationsManager = newNotificationsManager(statusFoundation.events, result.settingsService)
# Global
result.localAppSettingsVariant = newQVariant(singletonInstance.localAppSettings)
result.localAccountSettingsVariant = newQVariant(singletonInstance.localAccountSettings)
result.localAccountSensitiveSettingsVariant = newQVariant(singletonInstance.localAccountSensitiveSettings)
result.userProfileVariant = newQVariant(singletonInstance.userProfile)
result.globalUtilsVariant = newQVariant(singletonInstance.utils)
result.globalUtilsVariant = newQVariant(singletonInstance.utils)
# Services
result.generalService = general_service.newService()
result.settingsService = settings_service.newService()
result.generalService = general_service.newService()
result.nodeConfigurationService = node_configuration_service.newService(statusFoundation.fleetConfiguration,
result.settingsService)
result.keychainService = keychain_service.newService(statusFoundation.events)
@ -237,6 +241,7 @@ proc delete*(self: AppController) =
self.mainModule.delete
self.languageService.delete
self.appSettingsVariant.delete
self.localAppSettingsVariant.delete
self.localAccountSettingsVariant.delete
self.localAccountSensitiveSettingsVariant.delete
@ -314,12 +319,10 @@ proc load(self: AppController) =
self.ensService.init()
self.gifService.init()
# Accessible after user login
singletonInstance.engine.setRootContextProperty("appSettings", self.appSettingsVariant)
singletonInstance.engine.setRootContextProperty("globalUtils", self.globalUtilsVariant)
let pubKey = self.settingsService.getPublicKey()
singletonInstance.localAccountSensitiveSettings.setFileName(pubKey)
singletonInstance.engine.setRootContextProperty("localAccountSensitiveSettings", self.localAccountSensitiveSettingsVariant)
self.buildAndRegisterLocalAccountSensitiveSettings()
self.buildAndRegisterUserProfile()

View File

@ -3,6 +3,7 @@ import NimQml, json, chronicles
import ../../global/app_signals
import ../../global/global_singleton
import ../eventemitter
import ../../../app_service/service/settings/service as settings_service
import details
export details
@ -39,15 +40,17 @@ type
QtObject:
type NotificationsManager* = ref object of QObject
events: EventEmitter
settingsService: settings_service.Service
osNotification: StatusOSNotification
soundManager: StatusSoundManager
notificationSetUp: bool
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails)
proc setup(self: NotificationsManager, events: EventEmitter) =
proc setup(self: NotificationsManager, events: EventEmitter, settingsService: settings_service.Service) =
self.QObject.setup
self.events = events
self.settingsService = settingsService
proc delete*(self: NotificationsManager) =
if self.notificationSetUp:
@ -55,9 +58,9 @@ QtObject:
self.soundManager.delete
self.QObject.delete
proc newNotificationsManager*(events: EventEmitter): NotificationsManager =
proc newNotificationsManager*(events: EventEmitter, settingsService: settings_service.Service): NotificationsManager =
new(result, delete)
result.setup(events)
result.setup(events, settingsService)
proc init*(self: NotificationsManager) =
self.osNotification = newStatusOSNotification()
@ -145,27 +148,6 @@ QtObject:
sectionId: sectionId)
self.processNotification(title, message, details)
proc getExemptions(self: NotificationsManager, id: string): JsonNode =
# This proc returns exemptions as json object for the passed `id` if there are no set exemptions,
# json object with the default values will be returned.
let allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
result = %* {
EXEMPTION_KEY_MUTE_ALL_MESSAGES: false,
EXEMPTION_KEY_PERSONAL_MENTIONS: LSS_VALUE_NOTIF_SEND_ALERTS,
EXEMPTION_KEY_GLOBAL_MENTIONS: LSS_VALUE_NOTIF_SEND_ALERTS,
EXEMPTION_KEY_OTHER_MESSAGES: LSS_VALUE_NOTIF_SEND_TURN_OFF
}
if(allExemptions.contains(id)):
let obj = allExemptions[id]
if(obj.contains(EXEMPTION_KEY_MUTE_ALL_MESSAGES)):
result[EXEMPTION_KEY_MUTE_ALL_MESSAGES] = obj[EXEMPTION_KEY_MUTE_ALL_MESSAGES]
if(obj.contains(EXEMPTION_KEY_PERSONAL_MENTIONS)):
result[EXEMPTION_KEY_PERSONAL_MENTIONS] = obj[EXEMPTION_KEY_PERSONAL_MENTIONS]
if(obj.contains(EXEMPTION_KEY_GLOBAL_MENTIONS)):
result[EXEMPTION_KEY_GLOBAL_MENTIONS] = obj[EXEMPTION_KEY_GLOBAL_MENTIONS]
if(obj.contains(EXEMPTION_KEY_OTHER_MESSAGES)):
result[EXEMPTION_KEY_OTHER_MESSAGES] = obj[EXEMPTION_KEY_OTHER_MESSAGES]
proc notificationCheck(self: NotificationsManager, title: string, message: string, details: NotificationDetails,
notificationWay: string) =
var data = NotificationArgs(title: title, message: message, details: details)
@ -183,7 +165,7 @@ QtObject:
details.notificationType == NotificationType.NewContactRequest or
details.notificationType == NotificationType.IdentityVerificationRequest):
if(notificationWay == LSS_VALUE_NOTIF_SEND_DELIVER_QUIETLY):
if(notificationWay == VALUE_NOTIF_DELIVER_QUIETLY):
return
if((details.notificationType == NotificationType.NewMessage or
@ -200,17 +182,17 @@ QtObject:
if(not appIsActive or details.notificationType == NotificationType.TestNotification):
# Check anonymity level
if(singletonInstance.localAccountSensitiveSettings.getNotificationMessagePreviewSetting() == PREVIEW_ANONYMOUS):
if(self.settingsService.getNotificationMessagePreview() == PREVIEW_ANONYMOUS):
data.title = "Status"
data.message = "You have a new message"
elif(singletonInstance.localAccountSensitiveSettings.getNotificationMessagePreviewSetting() == PREVIEW_NAME_ONLY):
elif(self.settingsService.getNotificationMessagePreview() == PREVIEW_NAME_ONLY):
data.message = "You have a new message"
let identifier = $(details.toJsonNode())
debug "Add OS notification", title=data.title, message=data.message, identifier=identifier
self.showOSNotification(data.title, data.message, identifier)
if(singletonInstance.localAccountSensitiveSettings.getNotificationSoundsEnabled()):
self.soundManager.setPlayerVolume(singletonInstance.localAccountSensitiveSettings.getVolume())
if(self.settingsService.getNotificationSoundsEnabled()):
self.soundManager.setPlayerVolume(self.settingsService.getNotificationVolume())
self.soundManager.playSound(NOTIFICATION_SOUND)
proc processNotification(self: NotificationsManager, title: string, message: string, details: NotificationDetails) =
@ -225,76 +207,76 @@ QtObject:
# - https://drive.google.com/file/d/1L_9c2CMObcDcSuhVUu97s9-_26gtutES/view
# - https://drive.google.com/file/d/1KmG7lJDJIx6R_HJWeFvMYT2wk32RoTJQ/view
if(not singletonInstance.localAccountSensitiveSettings.getNotifSettingAllowNotifications()):
if(not self.settingsService.getNotifSettingAllowNotifications()):
return
# In case of contact request
if(details.notificationType == NotificationType.NewContactRequest):
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingContactRequests() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingContactRequests())
if(self.settingsService.getNotifSettingContactRequests() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingContactRequests())
return
# In case of identity verification request
elif(details.notificationType == NotificationType.IdentityVerificationRequest):
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingIdentityVerificationRequests() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingIdentityVerificationRequests())
if(self.settingsService.getNotifSettingIdentityVerificationRequests() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingIdentityVerificationRequests())
return
# In case of new message (regardless it's message with mention or not)
elif(details.notificationType == NotificationType.NewMessage or
details.notificationType == NotificationType.NewMessageWithPersonalMention or
details.notificationType == NotificationType.NewMessageWithGlobalMention):
if(singletonInstance.localAccountSensitiveSettings.getNotifSettingAllMessages() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingAllMessages())
if(self.settingsService.getNotifSettingAllMessages() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingAllMessages())
return
let messageBelongsToCommunity = details.isCommunitySection
if(messageBelongsToCommunity):
let exemptionObj = self.getExemptions(details.sectionId)
if(exemptionObj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool):
let exemptions = self.settingsService.getNotifSettingExemptions(details.sectionId)
if(exemptions.muteAllMessages):
return
if(details.notificationType == NotificationType.NewMessageWithPersonalMention and
exemptionObj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr)
exemptions.personalMentions != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, exemptions.personalMentions)
return
if(details.notificationType == NotificationType.NewMessageWithGlobalMention and
exemptionObj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr)
exemptions.globalMentions != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, exemptions.globalMentions)
return
if(details.notificationType == NotificationType.NewMessage and
exemptionObj[EXEMPTION_KEY_OTHER_MESSAGES].getStr != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, exemptionObj[EXEMPTION_KEY_OTHER_MESSAGES].getStr)
exemptions.otherMessages != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, exemptions.otherMessages)
return
return
else:
if(details.isOneToOne or details.isGroupChat):
let exemptionObj = self.getExemptions(details.chatId)
if(exemptionObj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool):
let exemptions = self.settingsService.getNotifSettingExemptions(details.chatId)
if(exemptions.muteAllMessages):
return
if(details.notificationType == NotificationType.NewMessageWithPersonalMention and
singletonInstance.localAccountSensitiveSettings.getNotifSettingPersonalMentions() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingPersonalMentions())
self.settingsService.getNotifSettingPersonalMentions() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingPersonalMentions())
return
if(details.notificationType == NotificationType.NewMessageWithGlobalMention and
singletonInstance.localAccountSensitiveSettings.getNotifSettingGlobalMentions() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingGlobalMentions())
self.settingsService.getNotifSettingGlobalMentions() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingGlobalMentions())
return
if(details.notificationType == NotificationType.NewMessage):
if(details.isOneToOne and
singletonInstance.localAccountSensitiveSettings.getNotifSettingOneToOneChats() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingOneToOneChats())
self.settingsService.getNotifSettingOneToOneChats() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingOneToOneChats())
return
if(details.isGroupChat and
singletonInstance.localAccountSensitiveSettings.getNotifSettingGroupChats() != LSS_VALUE_NOTIF_SEND_TURN_OFF):
self.notificationCheck(title, message, details, singletonInstance.localAccountSensitiveSettings.getNotifSettingGroupChats())
self.settingsService.getNotifSettingGroupChats() != VALUE_NOTIF_TURN_OFF):
self.notificationCheck(title, message, details, self.settingsService.getNotifSettingGroupChats())
return
# In all other cases (TestNotification, AcceptedContactRequest, JoinCommunityRequest, MyRequestToJoinCommunityAccepted,

View File

@ -36,12 +36,6 @@ const LSS_KEY_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS* = "hiddenCommuni
const DEFAULT_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS = ""
const LSS_KEY_HIDDEN_COMMUNITY_BACKUP_BANNERS* = "hiddenCommunityBackUpBanners"
const DEFAULT_HIDDEN_COMMUNITY_BACKUP_BANNERS = ""
const LSS_KEY_VOLUME* = "volume"
const DEFAULT_VOLUME = 50
const LSS_KEY_NOTIFICATION_SOUNDS_ENABLED* = "notificationSoundsEnabled"
const DEFAULT_NOTIFICATION_SOUNDS_ENABLED = true
const LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING* = "notificationMessagePreviewSetting"
const DEFAULT_NOTIFICATION_MESSAGE_PREVIEW_SETTING = 2 #notificationPreviewNameAndMessage from qml
const LSS_KEY_WITHLISTED_UNFURLING_SITES* = "whitelistedUnfurlingSites"
const DEFAULT_WITHLISTED_UNFURLING_SITES = ""
const LSS_KEY_NEVER_ASK_ABOUT_UNFURLING_AGAIN* = "neverAskAboutUnfurlingAgain"
@ -101,36 +95,6 @@ const DEFAULT_IS_DDMMYY_DATE_FORMAT = false
const LSS_KEY_IS_24H_TIME_FORMAT* = "is_24h_time_format"
const DEFAULT_IS_24H_TIME_FORMAT = false
# Exemption Keys
const EXEMPTION_KEY_MUTE_ALL_MESSAGES* = "muteAllMessages"
const EXEMPTION_KEY_PERSONAL_MENTIONS* = "personalMentions"
const EXEMPTION_KEY_GLOBAL_MENTIONS* = "globalMentions"
const EXEMPTION_KEY_OTHER_MESSAGES* = "otherMessages"
# Exemption Values
const LSS_VALUE_NOTIF_SEND_ALERTS* = "sendAlerts"
const LSS_VALUE_NOTIF_SEND_DELIVER_QUIETLY* = "deliverQuietly"
const LSS_VALUE_NOTIF_SEND_TURN_OFF* = "turnOff"
# Notifications
const LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS* = "allowNotifications"
const DEFAULT_NOTIF_SETTING_ALLOW_NOTIFICATIONS = true
const LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS* = "notifSettingOneToOneChats"
const DEFAULT_NOTIF_SETTING_ONE_TO_ONE_CHATS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_GROUP_CHATS* = "notifSettingGroupChats"
const DEFAULT_NOTIF_SETTING_GROUP_CHATS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS* = "notifSettingPersonalMentions"
const DEFAULT_NOTIF_SETTING_PERSONAL_MENTIONS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS* = "notifSettingGlobalMentions"
const DEFAULT_NOTIF_SETTING_GLOBAL_MENTIONS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_ALL_MESSAGES* = "notifSettingAllMessages"
const DEFAULT_NOTIF_SETTING_ALL_MESSAGES = LSS_VALUE_NOTIF_SEND_TURN_OFF
const LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS* = "notifSettingContactRequests"
const DEFAULT_NOTIF_SETTING_CONTACT_REQUESTS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS* = "notifSettingIdentityVerificationRequests"
const DEFAULT_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS = LSS_VALUE_NOTIF_SEND_ALERTS
const LSS_KEY_NOTIF_SETTING_EXEMPTIONS* = "notificationsExemptions"
const DEFAULT_NOTIF_SETTING_EXEMPTIONS = ""
logScope:
topics = "la-sensitive-settings"
@ -422,44 +386,6 @@ QtObject:
notify = hiddenCommunityBackUpBannersChanged
proc volumeChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getVolume*(self: LocalAccountSensitiveSettings): int {.slot.} =
getSettingsProp[int](self, LSS_KEY_VOLUME, newQVariant(DEFAULT_VOLUME))
proc setVolume*(self: LocalAccountSensitiveSettings, value: int) {.slot.} =
setSettingsProp(self, LSS_KEY_VOLUME, newQVariant(value)):
self.volumeChanged()
QtProperty[int] volume:
read = getVolume
write = setVolume
notify = volumeChanged
proc notificationSoundsEnabledChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotificationSoundsEnabled*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_NOTIFICATION_SOUNDS_ENABLED, newQVariant(DEFAULT_NOTIFICATION_SOUNDS_ENABLED))
proc setNotificationSoundsEnabled*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIFICATION_SOUNDS_ENABLED, newQVariant(value)):
self.notificationSoundsEnabledChanged()
QtProperty[bool] notificationSoundsEnabled:
read = getNotificationSoundsEnabled
write = setNotificationSoundsEnabled
notify = notificationSoundsEnabledChanged
proc notificationMessagePreviewSettingChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotificationMessagePreviewSetting*(self: LocalAccountSensitiveSettings): int {.slot.} =
getSettingsProp[int](self, LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING, newQVariant(DEFAULT_NOTIFICATION_MESSAGE_PREVIEW_SETTING))
proc setNotificationMessagePreviewSetting*(self: LocalAccountSensitiveSettings, value: int) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING, newQVariant(value)):
self.notificationMessagePreviewSettingChanged()
QtProperty[int] notificationMessagePreviewSetting:
read = getNotificationMessagePreviewSetting
write = setNotificationMessagePreviewSetting
notify = notificationMessagePreviewSettingChanged
proc whitelistedUnfurlingSitesChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getWhitelistedUnfurlingSites*(self: LocalAccountSensitiveSettings): QVariant {.slot.} =
getSettingsPropQVariant(self, LSS_KEY_WITHLISTED_UNFURLING_SITES, newQVariant(DEFAULT_WITHLISTED_UNFURLING_SITES))
@ -835,117 +761,6 @@ QtObject:
write = setIs24hTimeFormat
notify = is24hTimeFormatChanged
proc notifSettingAllowNotificationsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingAllowNotifications*(self: LocalAccountSensitiveSettings): bool {.slot.} =
getSettingsProp[bool](self, LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS, newQVariant(DEFAULT_NOTIF_SETTING_ALLOW_NOTIFICATIONS))
proc setNotifSettingAllowNotifications*(self: LocalAccountSensitiveSettings, value: bool) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS, newQVariant(value)):
self.notifSettingAllowNotificationsChanged()
QtProperty[bool] notifSettingAllowNotifications:
read = getNotifSettingAllowNotifications
write = setNotifSettingAllowNotifications
notify = notifSettingAllowNotificationsChanged
proc notifSettingOneToOneChatsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingOneToOneChats*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS, newQVariant(DEFAULT_NOTIF_SETTING_ONE_TO_ONE_CHATS))
proc setNotifSettingOneToOneChats*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS, newQVariant(value)):
self.notifSettingOneToOneChatsChanged()
QtProperty[string] notifSettingOneToOneChats:
read = getNotifSettingOneToOneChats
write = setNotifSettingOneToOneChats
notify = notifSettingOneToOneChatsChanged
proc notifSettingGroupChatsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingGroupChats*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_GROUP_CHATS, newQVariant(DEFAULT_NOTIF_SETTING_GROUP_CHATS))
proc setNotifSettingGroupChats*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_GROUP_CHATS, newQVariant(value)):
self.notifSettingGroupChatsChanged()
QtProperty[string] notifSettingGroupChats:
read = getNotifSettingGroupChats
write = setNotifSettingGroupChats
notify = notifSettingGroupChatsChanged
proc notifSettingPersonalMentionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingPersonalMentions*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS, newQVariant(DEFAULT_NOTIF_SETTING_PERSONAL_MENTIONS))
proc setNotifSettingPersonalMentions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS, newQVariant(value)):
self.notifSettingPersonalMentionsChanged()
QtProperty[string] notifSettingPersonalMentions:
read = getNotifSettingPersonalMentions
write = setNotifSettingPersonalMentions
notify = notifSettingPersonalMentionsChanged
proc notifSettingGlobalMentionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingGlobalMentions*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS, newQVariant(DEFAULT_NOTIF_SETTING_GLOBAL_MENTIONS))
proc setNotifSettingGlobalMentions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS, newQVariant(value)):
self.notifSettingGlobalMentionsChanged()
QtProperty[string] notifSettingGlobalMentions:
read = getNotifSettingGlobalMentions
write = setNotifSettingGlobalMentions
notify = notifSettingGlobalMentionsChanged
proc notifSettingAllMessagesChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingAllMessages*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_ALL_MESSAGES, newQVariant(DEFAULT_NOTIF_SETTING_ALL_MESSAGES))
proc setNotifSettingAllMessages*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_ALL_MESSAGES, newQVariant(value)):
self.notifSettingAllMessagesChanged()
QtProperty[string] notifSettingAllMessages:
read = getNotifSettingAllMessages
write = setNotifSettingAllMessages
notify = notifSettingAllMessagesChanged
proc notifSettingContactRequestsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingContactRequests*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS, newQVariant(DEFAULT_NOTIF_SETTING_CONTACT_REQUESTS))
proc setNotifSettingContactRequests*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS, newQVariant(value)):
self.notifSettingContactRequestsChanged()
QtProperty[string] notifSettingContactRequests:
read = getNotifSettingContactRequests
write = setNotifSettingContactRequests
notify = notifSettingContactRequestsChanged
proc notifSettingIdentityVerificationRequestsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingIdentityVerificationRequests*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS, newQVariant(DEFAULT_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS))
proc setNotifSettingIdentityVerificationRequests*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS, newQVariant(value)):
self.notifSettingIdentityVerificationRequestsChanged()
QtProperty[string] notifSettingIdentityVerificationRequests:
read = getNotifSettingIdentityVerificationRequests
write = setNotifSettingIdentityVerificationRequests
notify = notifSettingIdentityVerificationRequestsChanged
proc notifSettingExemptionsChanged*(self: LocalAccountSensitiveSettings) {.signal.}
proc getNotifSettingExemptions*(self: LocalAccountSensitiveSettings): string {.slot.} =
getSettingsProp[string](self, LSS_KEY_NOTIF_SETTING_EXEMPTIONS, newQVariant(DEFAULT_NOTIF_SETTING_EXEMPTIONS))
proc setNotifSettingExemptions*(self: LocalAccountSensitiveSettings, value: string) {.slot.} =
setSettingsProp(self, LSS_KEY_NOTIF_SETTING_EXEMPTIONS, newQVariant(value)):
self.notifSettingExemptionsChanged()
QtProperty[string] notifSettingExemptions:
read = getNotifSettingExemptions
write = setNotifSettingExemptions
notify = notifSettingExemptionsChanged
proc getNotifSettingExemptionsAsJson*(self: LocalAccountSensitiveSettings): JsonNode =
var allExemptions = newJObject()
let exemptions = self.getNotifSettingExemptions()
if(exemptions.len == 0):
return allExemptions
try:
let exemptionsObj = exemptions.parseJson
allExemptions = exemptionsObj
except Exception as e:
error "stored exemptions are corrupted, will be overwritten", msg=e.msg
return allExemptions
proc removeKey*(self: LocalAccountSensitiveSettings, key: string) =
if(self.settings.isNil):
return
@ -971,9 +786,6 @@ QtObject:
of LSS_KEY_HIDDEN_COMMUNITY_WELCOME_BANNERS: self.hiddenCommunityWelcomeBannersChanged()
of LSS_KEY_HIDDEN_COMMUNITY_CHANNELS_AND_CATEGORIES_BANNERS: self.hiddenCommunityChannelAndCategoriesBannersChanged()
of LSS_KEY_HIDDEN_COMMUNITY_BACKUP_BANNERS: self.hiddenCommunityBackUpBannersChanged()
of LSS_KEY_VOLUME: self.volumeChanged()
of LSS_KEY_NOTIFICATION_SOUNDS_ENABLED: self.notificationSoundsEnabledChanged()
of LSS_KEY_NOTIFICATION_MESSAGE_PREVIEW_SETTING: self.notificationMessagePreviewSettingChanged()
of LSS_KEY_WITHLISTED_UNFURLING_SITES: self.whitelistedUnfurlingSitesChanged()
of LSS_KEY_NEVER_ASK_ABOUT_UNFURLING_AGAIN: self.neverAskAboutUnfurlingAgainChanged()
of LSS_KEY_HIDE_CHANNEL_SUGGESTIONS: self.hideChannelSuggestionsChanged()
@ -1003,12 +815,3 @@ QtObject:
of LSS_KEY_STICKERS_ENS_ROPSTEN: self.stickersEnsRopstenChanged()
of LSS_KEY_IS_DDMMYY_DATE_FORMAT: self.isDDMMYYDateFormatChanged()
of LSS_KEY_IS_24H_TIME_FORMAT: self.is24hTimeFormatChanged()
of LSS_KEY_NOTIF_SETTING_ALLOW_NOTIFICATIONS: self.notifSettingAllowNotificationsChanged()
of LSS_KEY_NOTIF_SETTING_ONE_TO_ONE_CHATS: self.notifSettingOneToOneChatsChanged()
of LSS_KEY_NOTIF_SETTING_GROUP_CHATS: self.notifSettingGroupChatsChanged()
of LSS_KEY_NOTIF_SETTING_PERSONAL_MENTIONS: self.notifSettingPersonalMentionsChanged()
of LSS_KEY_NOTIF_SETTING_GLOBAL_MENTIONS: self.notifSettingGlobalMentionsChanged()
of LSS_KEY_NOTIF_SETTING_ALL_MESSAGES: self.notifSettingAllMessagesChanged()
of LSS_KEY_NOTIF_SETTING_CONTACT_REQUESTS: self.notifSettingContactRequestsChanged()
of LSS_KEY_NOTIF_SETTING_IDENTITY_VERIF_REQUESTS: self.notifSettingIdentityVerificationRequestsChanged()
of LSS_KEY_NOTIF_SETTING_EXEMPTIONS: self.notifSettingExemptionsChanged()

View File

@ -84,7 +84,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface,
result.advancedModule = advanced_module.newModule(result, events, settingsService, stickersService, nodeConfigurationService)
result.devicesModule = devices_module.newModule(result, events, settingsService, devicesService)
result.syncModule = sync_module.newModule(result, events, settingsService, mailserversService)
result.notificationsModule = notifications_module.newModule(result, events, chatService, contactsService)
result.notificationsModule = notifications_module.newModule(result, events, settingsService, chatService, contactsService)
result.ensUsernamesModule = ens_usernames_module.newModule(
result, events, settingsService, ensService, walletAccountService
)

View File

@ -1,8 +1,9 @@
import Tables, chronicles
import Tables, chronicles, json
import io_interface
import ../../../../global/app_signals
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service as settings_service
import ../../../../../app_service/service/chat/service as chat_service
import ../../../../../app_service/service/contacts/service as contact_service
import ../../../../../app_service/service/community/service as community_service
@ -14,16 +15,19 @@ type
Controller* = ref object of RootObj
delegate: io_interface.AccessInterface
events: EventEmitter
settingsService: settings_service.Service
chatService: chat_service.Service
contactService: contact_service.Service
proc newController*(delegate: io_interface.AccessInterface,
events: EventEmitter,
settingsService: settings_service.Service,
chatService: chat_service.Service,
contactService: contact_service.Service): Controller =
result = Controller()
result.delegate = delegate
result.events = events
result.settingsService = settingsService
result.chatService = chatService
result.contactService = contactService
@ -88,6 +92,15 @@ proc init*(self: Controller) =
let args = ChatExtArgs(e)
self.delegate.addChat(args.chatId)
proc getNotifSettingExemptions*(self: Controller, id: string): NotificationsExemptions =
return self.settingsService.getNotifSettingExemptions(id)
proc setNotifSettingExemptions*(self: Controller, id: string, exemptions: NotificationsExemptions): bool =
return self.settingsService.setNotifSettingExemptions(id, exemptions)
proc removeNotifSettingExemptions*(self: Controller, id: string): bool =
return self.settingsService.removeNotifSettingExemptions(id)
proc getChannelGroups*(self: Controller): seq[ChannelGroupDto] =
return self.chatService.getChannelGroups()

View File

@ -1,4 +1,4 @@
import ../../../../global/local_account_sensitive_settings
import ../../../../../app_service/service/settings/dto/settings
type
Type* {.pure.} = enum
@ -20,8 +20,8 @@ type
otherMessages: string
proc initItem*(id, name, image, color: string, joinedTimestamp: int64, itemType: Type, muteAllMessages = false,
personalMentions = LSS_VALUE_NOTIF_SEND_ALERTS, globalMentions = LSS_VALUE_NOTIF_SEND_ALERTS,
otherMessages = LSS_VALUE_NOTIF_SEND_TURN_OFF): Item =
personalMentions = VALUE_NOTIF_SEND_ALERTS, globalMentions = VALUE_NOTIF_SEND_ALERTS,
otherMessages = VALUE_NOTIF_TURN_OFF): Item =
result = Item()
result.id = id
result.name = name
@ -57,9 +57,9 @@ proc itemType*(self: Item): Type =
proc customized*(self: Item): bool =
return self.muteAllMessages or
self.personalMentions != LSS_VALUE_NOTIF_SEND_ALERTS or
self.globalMentions != LSS_VALUE_NOTIF_SEND_ALERTS or
self.otherMessages != LSS_VALUE_NOTIF_SEND_TURN_OFF
self.personalMentions != VALUE_NOTIF_SEND_ALERTS or
self.globalMentions != VALUE_NOTIF_SEND_ALERTS or
self.otherMessages != VALUE_NOTIF_TURN_OFF
proc muteAllMessages*(self: Item): bool =
return self.muteAllMessages

View File

@ -1,7 +1,7 @@
import NimQml, Tables
import item
import ../../../../global/local_account_sensitive_settings
import ../../../../../app_service/service/settings/dto/settings
type
ModelRole {.pure.} = enum
@ -145,8 +145,8 @@ QtObject:
for i in 0 ..< self.items.len:
yield self.items[i]
proc updateExemptions*(self: Model, id: string, muteAllMessages = false, personalMentions = LSS_VALUE_NOTIF_SEND_ALERTS,
globalMentions = LSS_VALUE_NOTIF_SEND_ALERTS, otherMessages = LSS_VALUE_NOTIF_SEND_TURN_OFF) =
proc updateExemptions*(self: Model, id: string, muteAllMessages = false, personalMentions = VALUE_NOTIF_SEND_ALERTS,
globalMentions = VALUE_NOTIF_SEND_ALERTS, otherMessages = VALUE_NOTIF_TURN_OFF) =
let ind = self.findIndexForItemId(id)
if(ind == -1):
return

View File

@ -6,6 +6,7 @@ import view, controller, model, item
import ../../../../global/app_signals
import ../../../../global/global_singleton
import ../../../../core/eventemitter
import ../../../../../app_service/service/settings/service as settings_service
import ../../../../../app_service/service/chat/service as chat_service
import ../../../../../app_service/service/contacts/service as contact_service
from ../../../../../app_service/service/community/dto/community import CommunityDto
@ -25,13 +26,14 @@ type
proc newModule*(delegate: delegate_interface.AccessInterface,
events: EventEmitter,
settingsService: settings_service.Service,
chatService: chat_service.Service,
contactService: contact_service.Service): Module =
result = Module()
result.delegate = delegate
result.view = view.newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, events, chatService, contactService)
result.controller = controller.newController(result, events, settingsService, chatService, contactService)
result.moduleLoaded = false
method delete*(self: Module) =
@ -52,18 +54,9 @@ method isLoaded*(self: Module): bool =
return self.moduleLoaded
proc createItem(self: Module, id, name, image, color: string, joinedTimestamp: int64, itemType: Type): Item =
let allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
var item = initItem(id, name, image, color, joinedTimestamp, itemType)
if(allExemptions.contains(id)):
let obj = allExemptions[id]
if(obj.contains(EXEMPTION_KEY_MUTE_ALL_MESSAGES)):
item.muteAllMessages = obj[EXEMPTION_KEY_MUTE_ALL_MESSAGES].getBool
if(obj.contains(EXEMPTION_KEY_PERSONAL_MENTIONS)):
item.personalMentions = obj[EXEMPTION_KEY_PERSONAL_MENTIONS].getStr
if(obj.contains(EXEMPTION_KEY_GLOBAL_MENTIONS)):
item.globalMentions = obj[EXEMPTION_KEY_GLOBAL_MENTIONS].getStr
if(obj.contains(EXEMPTION_KEY_OTHER_MESSAGES)):
item.otherMessages = obj[EXEMPTION_KEY_OTHER_MESSAGES].getStr
let exemptions = self.controller.getNotifSettingExemptions(id)
var item = initItem(id, name, image, color, joinedTimestamp, itemType, exemptions.muteAllMessages,
exemptions.personalMentions, exemptions.globalMentions, exemptions.otherMessages)
return item
proc createChatItem(self: Module, chatDto: ChatDto): Item =
@ -111,17 +104,12 @@ method sendTestNotification*(self: Module, title: string, message: string) =
method saveExemptions*(self: Module, itemId: string, muteAllMessages: bool, personalMentions: string,
globalMentions: string, otherMessages: string) =
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
allExemptions[itemId] = %* {
EXEMPTION_KEY_MUTE_ALL_MESSAGES: muteAllMessages,
EXEMPTION_KEY_PERSONAL_MENTIONS: personalMentions,
EXEMPTION_KEY_GLOBAL_MENTIONS: globalMentions,
EXEMPTION_KEY_OTHER_MESSAGES: otherMessages
}
self.view.exemptionsModel().updateExemptions(itemId, muteAllMessages, personalMentions, globalMentions, otherMessages)
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
let exemptions = NotificationsExemptions(muteAllMessages: muteAllMessages,
personalMentions: personalMentions,
globalMentions: globalMentions,
otherMessages: otherMessages)
if(self.controller.setNotifSettingExemptions(itemId, exemptions)):
self.view.exemptionsModel().updateExemptions(itemId, muteAllMessages, personalMentions, globalMentions, otherMessages)
method onToggleSection*(self: Module, sectionType: SectionType) =
if(sectionType != SectionType.Community):
@ -137,14 +125,9 @@ method onToggleSection*(self: Module, sectionType: SectionType) =
let item = self.createItem(cg.id, cg.name, cg.images.thumbnail, cg.color, joinedTimestamp = 0, item.Type.Community)
self.view.exemptionsModel().addItem(item)
else:
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
for item in self.view.exemptionsModel().modelIterator():
if(item.itemType != Type.Community):
continue
if(allExemptions.contains(item.id)):
allExemptions.delete(item.id)
self.view.exemptionsModel().removeItemById(item.id)
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
if(item.itemType == Type.Community and self.controller.removeNotifSettingExemptions(item.id)):
self.view.exemptionsModel().removeItemById(item.id)
method addCommunity*(self: Module, communityDto: CommunityDto) =
let ind = self.view.exemptionsModel().findIndexForItemId(communityDto.id)
@ -161,11 +144,8 @@ method editCommunity*(self: Module, communityDto: CommunityDto) =
self.view.exemptionsModel().addItem(item)
method removeItemWithId*(self: Module, itemId: string) =
var allExemptions = singletonInstance.localAccountSensitiveSettings.getNotifSettingExemptionsAsJson()
if(allExemptions.contains(itemId)):
allExemptions.delete(itemId)
singletonInstance.localAccountSensitiveSettings.setNotifSettingExemptions($allExemptions)
self.view.exemptionsModel().removeItemById(itemId)
if(self.controller.removeNotifSettingExemptions(itemId)):
self.view.exemptionsModel().removeItemById(itemId)
method addChat*(self: Module, chatDto: ChatDto) =
if chatDto.chatType != ChatType.OneToOne and chatDto.chatType != ChatType.PrivateGroupChat:

View File

@ -47,10 +47,21 @@ const KEY_GIF_API_KEY* = "gifs/api-key"
const KEY_DISPLAY_NAME* = "display-name"
const KEY_TEST_NETWORKS_ENABLED* = "test-networks-enabled?"
# Notifications Settings Values
const VALUE_NOTIF_SEND_ALERTS* = "SendAlerts"
const VALUE_NOTIF_DELIVER_QUIETLY* = "DeliverQuietly"
const VALUE_NOTIF_TURN_OFF* = "TurnOff"
const PROFILE_PICTURES_VISIBILITY_CONTACTS_ONLY* = 1
const PROFILE_PICTURES_VISIBILITY_EVERYONE* = 2
const PROFILE_PICTURES_VISIBILITY_NO_ONE* = 3
type NotificationsExemptions* = object
muteAllMessages*: bool
personalMentions*: string
globalMentions*: string
otherMessages*: string
type UpstreamConfig* = object
Enabled*: bool
URL*: string

File diff suppressed because it is too large Load Diff

View File

@ -9,3 +9,89 @@ proc getSettings*(): RpcResponse[JsonNode] {.raises: [Exception].} =
proc saveSettings*(key: string, value: string | JsonNode | bool | int): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [key, value]
result = core.callPrivateRPC("settings_saveSetting", payload)
proc getAllowNotifications*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetAllowNotifications")
proc setAllowNotifications*(value: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetAllowNotifications", %* [value])
proc getOneToOneChats*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetOneToOneChats")
proc setOneToOneChats*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetOneToOneChats", %* [value])
proc getGroupChats*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetGroupChats")
proc setGroupChats*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetGroupChats", %* [value])
proc getPersonalMentions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetPersonalMentions")
proc setPersonalMentions*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetPersonalMentions", %* [value])
proc getGlobalMentions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetGlobalMentions")
proc setGlobalMentions*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetGlobalMentions", %* [value])
proc getAllMessages*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetAllMessages")
proc setAllMessages*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetAllMessages", %* [value])
proc getContactRequests*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetContactRequests")
proc setContactRequests*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetContactRequests", %* [value])
proc getIdentityVerificationRequests*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetIdentityVerificationRequests")
proc setIdentityVerificationRequests*(value: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetIdentityVerificationRequests", %* [value])
proc getSoundEnabled*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetSoundEnabled")
proc setSoundEnabled*(value: bool): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetSoundEnabled", %* [value])
proc getVolume*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetVolume")
proc setVolume*(value: int): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetVolume", %* [value])
proc getMessagePreview*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetMessagePreview")
proc setMessagePreview*(value: int): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsSetMessagePreview", %* [value])
proc getExemptionMuteAllMessages*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetExMuteAllMessages", %* [id])
proc getExemptionPersonalMentions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetExPersonalMentions", %* [id])
proc getExemptionGlobalMentions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetExGlobalMentions", %* [id])
proc getExemptionOtherMessages*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_notificationsGetExOtherMessages", %* [id])
proc setExemptions*(id: string, muteAllMessages: bool, personalMentions: string, globalMentions: string,
otherMessages: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [id, muteAllMessages, personalMentions, globalMentions, otherMessages]
return core.callPrivateRPC("settings_notificationsSetExemptions", payload)
proc deleteExemptions*(id: string): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_deleteExemptions", %* [id])

View File

@ -245,9 +245,9 @@ SettingsContentBase {
components: [
StatusSwitch {
id: allowNotifSwitch
checked: localAccountSensitiveSettings.notifSettingAllowNotifications
checked: appSettings.notifSettingAllowNotifications
onClicked: {
localAccountSensitiveSettings.notifSettingAllowNotifications = !localAccountSensitiveSettings.notifSettingAllowNotifications
appSettings.notifSettingAllowNotifications = !appSettings.notifSettingAllowNotifications
}
}
]
@ -269,10 +269,10 @@ SettingsContentBase {
title: qsTr("1:1 Chats")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingOneToOneChats
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingOneToOneChats
onSendAlertsClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingOneToOneChats = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -282,10 +282,10 @@ SettingsContentBase {
title: qsTr("Group Chats")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingGroupChats
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingGroupChats
onSendAlertsClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingGroupChats = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -296,10 +296,10 @@ SettingsContentBase {
tertiaryTitle: qsTr("Messages containing @%1").arg(userProfile.name)
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingPersonalMentions
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingPersonalMentions
onSendAlertsClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingPersonalMentions = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -310,10 +310,10 @@ SettingsContentBase {
tertiaryTitle: qsTr("Messages containing @here and @channel")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingGlobalMentions
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingGlobalMentions
onSendAlertsClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingGlobalMentions = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -323,10 +323,10 @@ SettingsContentBase {
title: qsTr("All Messages")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingAllMessages
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingAllMessages
onSendAlertsClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingAllMessages = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -344,10 +344,10 @@ SettingsContentBase {
title: qsTr("Contact Requests")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingContactRequests
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingContactRequests
onSendAlertsClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingContactRequests = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -357,10 +357,10 @@ SettingsContentBase {
title: qsTr("Identity Verification Requests")
components: [
NotificationSelect {
selected: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests
onSendAlertsClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: localAccountSensitiveSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.turnOffValue
selected: appSettings.notifSettingIdentityVerificationRequests
onSendAlertsClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.sendAlertsValue
onDeliverQuietlyClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.deliverQuietlyValue
onTurnOffClicked: appSettings.notifSettingIdentityVerificationRequests = Constants.settingsSection.notifications.turnOffValue
}
]
}
@ -386,10 +386,10 @@ SettingsContentBase {
notificationTitle: "Vitalik Buterin"
notificationMessage: qsTr("Hi there! So EIP-1559 will defini...")
buttonGroup: messageSetting
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewNameAndMessage
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameAndMessage
onRadioCheckedChanged: {
if (checked) {
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewNameAndMessage
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameAndMessage
}
}
}
@ -401,10 +401,10 @@ SettingsContentBase {
notificationTitle: "Vitalik Buterin"
notificationMessage: qsTr("You have a new message")
buttonGroup: messageSetting
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewNameOnly
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewNameOnly
onRadioCheckedChanged: {
if (checked) {
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewNameOnly
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewNameOnly
}
}
}
@ -416,10 +416,10 @@ SettingsContentBase {
notificationTitle: "Status"
notificationMessage: qsTr("You have a new message")
buttonGroup: messageSetting
checked: localAccountSensitiveSettings.notificationMessagePreviewSetting === Constants.settingsSection.notificationsBubble.previewAnonymous
checked: appSettings.notificationMessagePreview === Constants.settingsSection.notificationsBubble.previewAnonymous
onRadioCheckedChanged: {
if (checked) {
localAccountSensitiveSettings.notificationMessagePreviewSetting = Constants.settingsSection.notificationsBubble.previewAnonymous
appSettings.notificationMessagePreview = Constants.settingsSection.notificationsBubble.previewAnonymous
}
}
}
@ -430,9 +430,9 @@ SettingsContentBase {
components: [
StatusSwitch {
id: soundSwitch
checked: localAccountSensitiveSettings.notificationSoundsEnabled
checked: appSettings.notificationSoundsEnabled
onClicked: {
localAccountSensitiveSettings.notificationSoundsEnabled = !localAccountSensitiveSettings.notificationSoundsEnabled
appSettings.notificationSoundsEnabled = !appSettings.notificationSoundsEnabled
}
}
]
@ -466,11 +466,11 @@ SettingsContentBase {
stepSize: 1
onValueChanged: {
localAccountSensitiveSettings.volume = value
appSettings.volume = value
}
Component.onCompleted: {
value = localAccountSensitiveSettings.volume
value = appSettings.volume
}
}

View File

@ -168,9 +168,9 @@ QtObject {
}
readonly property QtObject notifications: QtObject {
readonly property string sendAlertsValue: "sendAlerts"
readonly property string deliverQuietlyValue: "deliverQuietly"
readonly property string turnOffValue: "turnOff"
readonly property string sendAlertsValue: "SendAlerts"
readonly property string deliverQuietlyValue: "DeliverQuietly"
readonly property string turnOffValue: "TurnOff"
}
readonly property QtObject exemptions: QtObject {

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 7227ae1c8ef1f74e180f324185d01f564730af70
Subproject commit 78cba969cc90f463184509c6bde9bcb44d7bb3f9