Skip to content

Commit 104b743

Browse files
committed
fix: Clean the old NotificationsEnabled and logs
`NotificationsEnabled` flag was previously used by the mobile legacy client. It's no longer used since status-desktop uses another, more granular config for push notifications. This commit also removes the previously added fmt prints for logging and fixes the anonymous local notifications.
1 parent 9e3b269 commit 104b743

File tree

9 files changed

+27
-58
lines changed

9 files changed

+27
-58
lines changed

internal/db/multiaccounts/settings/columns.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,6 @@ var (
217217
dBColumnName: "node_config",
218218
valueHandler: NodeConfigHandler,
219219
}
220-
// NotificationsEnabled - we should remove this and realated things once mobile team starts usign `settings_notifications` package
221-
NotificationsEnabled = SettingField{
222-
reactFieldName: "notifications-enabled?",
223-
dBColumnName: "notifications_enabled",
224-
valueHandler: BoolHandler,
225-
}
226220
OpenseaEnabled = SettingField{
227221
reactFieldName: "opensea-enabled?",
228222
dBColumnName: "opensea_enabled",
@@ -544,7 +538,6 @@ var (
544538
NetworksNetworks,
545539
MessengerNotificationsEnabled,
546540
NodeConfig,
547-
NotificationsEnabled,
548541
OpenseaEnabled,
549542
PhotoPath,
550543
PinnedMailservers,

internal/db/multiaccounts/settings/database.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ func (db *Database) GetSettings() (Settings, error) {
394394
custom_bootnodes, custom_bootnodes_enabled, dapps_address, display_name, bio, eip1581_address, fleet,
395395
hide_home_tooltip, installation_id, key_uid, keycard_instance_uid, keycard_paired_on, keycard_pairing,
396396
last_updated, latest_derived_path, link_preview_request_enabled, link_previews_enabled_sites, log_level,
397-
mnemonic, mnemonic_removed, name, networks, notifications_enabled,
397+
mnemonic, mnemonic_removed, name, networks,
398398
push_notifications_from_contacts_only, remote_push_notifications_enabled, messenger_notifications_enabled,
399399
send_push_notifications, push_notifications_block_mentions, photo_path, pinned_mailservers, preferred_name, preview_privacy, public_key,
400400
remember_syncing_choice, signing_phrase, stickers_packs_installed, stickers_packs_pending, stickers_recent_stickers,
@@ -437,7 +437,6 @@ func (db *Database) GetSettings() (Settings, error) {
437437
&s.MnemonicRemoved,
438438
&s.Name,
439439
&s.Networks,
440-
&s.NotificationsEnabled,
441440
&s.PushNotificationsFromContactsOnly,
442441
&s.RemotePushNotificationsEnabled,
443442
&s.MessengerNotificationsEnabled,
@@ -501,15 +500,6 @@ func (db *Database) GetSettings() (Settings, error) {
501500
return s, err
502501
}
503502

504-
// We should remove this and realated things once mobile team starts usign `settings_notifications` package
505-
func (db *Database) GetNotificationsEnabled() (result bool, err error) {
506-
err = db.makeSelectRow(NotificationsEnabled).Scan(&result)
507-
if err == sql.ErrNoRows {
508-
return result, nil
509-
}
510-
return result, err
511-
}
512-
513503
func (db *Database) GetProfilePicturesVisibility() (result int, err error) {
514504
err = db.makeSelectRow(ProfilePicturesVisibility).Scan(&result)
515505
if err == sql.ErrNoRows {

internal/db/multiaccounts/settings/database_settings_manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ type DatabaseSettingsManager interface {
1818
GetNotifier() Notifier
1919
GetSettingLastSynced(setting SettingField) (result uint64, err error)
2020
GetSettings() (Settings, error)
21-
GetNotificationsEnabled() (result bool, err error)
2221
GetProfilePicturesVisibility() (result int, err error)
2322
GetPublicKey() (string, error)
2423
GetFleet() (string, error)

internal/db/multiaccounts/settings/structs.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ type Settings struct {
155155
MutualContactEnabled bool `json:"mutual-contact-enabled?"`
156156
Name string `json:"name,omitempty"`
157157
Networks *json.RawMessage `json:"networks/networks"`
158-
// NotificationsEnabled indicates whether local notifications should be enabled (android only)
159-
NotificationsEnabled bool `json:"notifications-enabled?,omitempty"`
160158
PhotoPath string `json:"photo-path"`
161159
PinnedMailserver *json.RawMessage `json:"pinned-mailservers,omitempty"`
162160
// PreferredName represents the user's preferred Ethereum Name Service (ENS) name.

protocol/local_notifications.go

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package protocol
33
import (
44
"crypto/ecdsa"
55
"encoding/json"
6-
"fmt"
76
"strings"
87

98
gethcommon "github.com/ethereum/go-ethereum/common"
@@ -111,6 +110,17 @@ func applyMessagePreview(title, message string, messagePreview int) (displayTitl
111110
}
112111
}
113112

113+
// applyAuthorPrivacy clears identity-revealing fields from a notification when the privacy
114+
// level is anonymous. In anonymous mode the OS notification must not expose who sent
115+
// the message: no sender name, no sender/community/chat icon.
116+
func applyAuthorPrivacy(notif *localnotifications.Notification, messagePreview int) {
117+
if messagePreview == messagePreviewAnonymous {
118+
notif.Author = localnotifications.NotificationAuthor{}
119+
notif.CommunityIcon = ""
120+
notif.ChatIcon = ""
121+
}
122+
}
123+
114124
// NotificationSettingsProvider allows querying notification preferences for local notifications.
115125
// Implemented by *accounts.Database which embeds *NotificationsSettings.
116126
type NotificationSettingsProvider interface {
@@ -142,7 +152,6 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
142152
// For public/community chats, skip inactive (soft-deleted). For 1:1 and group,
143153
// still notify — e.g. contact requests or new messages can arrive when Active=false.
144154
if chat != nil && !chat.Active && !chat.OneToOne() && !chat.PrivateGroupChat() {
145-
fmt.Printf("[local_notifications] showMessageNotification: false (chat !Active, not 1:1/group) msgId=%s\n", message.ID)
146155
return false
147156
}
148157

@@ -168,7 +177,6 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
168177
// 1. Check per-chat/community exemptions first
169178
exMuteAll, err := settings.GetExMuteAllMessages(chatID)
170179
if err == nil && exMuteAll {
171-
fmt.Printf("[local_notifications] showMessageNotification: false (exemption muteAll) msgId=%s\n", message.ID)
172180
return false
173181
}
174182

@@ -179,21 +187,17 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
179187
if chat.OneToOne() {
180188
val, err := settings.GetOneToOneChats()
181189
if err == nil && !isNotificationAllowed(val) {
182-
fmt.Printf("[local_notifications] showMessageNotification: false (1:1 TurnOff) msgId=%s\n", message.ID)
183190
return false
184191
}
185-
fmt.Printf("[local_notifications] showMessageNotification: true (1:1) msgId=%s\n", message.ID)
186192
return true
187193
}
188194

189195
// 3. Private group chats
190196
if chat.PrivateGroupChat() {
191197
val, err := settings.GetGroupChats()
192198
if err == nil && !isNotificationAllowed(val) {
193-
fmt.Printf("[local_notifications] showMessageNotification: false (group TurnOff) msgId=%s\n", message.ID)
194199
return false
195200
}
196-
fmt.Printf("[local_notifications] showMessageNotification: true (private group) msgId=%s\n", message.ID)
197201
return true
198202
}
199203

@@ -210,9 +214,7 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
210214
exG, _ := settings.GetExGlobalMentions(chatID)
211215
effPersonal, effGlobal = exP, exG
212216
}
213-
allowed := isNotificationAllowed(effPersonal) || isNotificationAllowed(effGlobal)
214-
fmt.Printf("[local_notifications] showMessageNotification: %v (mention) msgId=%s\n", allowed, message.ID)
215-
return allowed
217+
return isNotificationAllowed(effPersonal) || isNotificationAllowed(effGlobal)
216218
}
217219

218220
if isReplyToOwn {
@@ -222,9 +224,7 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
222224
exOther, _ := settings.GetExOtherMessages(chatID)
223225
eff = exOther
224226
}
225-
allowed := isNotificationAllowed(eff)
226-
fmt.Printf("[local_notifications] showMessageNotification: %v (reply to own) msgId=%s\n", allowed, message.ID)
227-
return allowed
227+
return isNotificationAllowed(eff)
228228
}
229229

230230
// 5. Other messages in public/community chats
@@ -234,9 +234,7 @@ func showMessageNotification(settings NotificationSettingsProvider, publicKey ec
234234
exOther, _ := settings.GetExOtherMessages(chatID)
235235
eff = exOther
236236
}
237-
allowed := isNotificationAllowed(eff)
238-
fmt.Printf("[local_notifications] showMessageNotification: %v (other) msgId=%s\n", allowed, message.ID)
239-
return allowed
237+
return isNotificationAllowed(eff)
240238
}
241239

242240
func (n NotificationBody) MarshalJSON() ([]byte, error) {
@@ -385,14 +383,15 @@ func (n NotificationBody) toMessageNotification(id string, resolvePrimaryName fu
385383
notif.ChatIcon = chatIconDataURI(n.Chat)
386384
}
387385

386+
applyAuthorPrivacy(notif, messagePreview)
388387
return notif, nil
389388
}
390389

391390
func (n NotificationBody) toContactRequestNotification(id string, profilePicturesVisibility int, messagePreview int) (*localnotifications.Notification, error) {
392391
title := n.Contact.PrimaryName() + " wants to connect"
393392
message := n.Contact.PrimaryName() + " sent you a contact request"
394393
displayTitle, displayMessage := applyMessagePreview(title, message, messagePreview)
395-
return &localnotifications.Notification{
394+
notif := &localnotifications.Notification{
396395
ID: gethcommon.HexToHash(id),
397396
Body: n,
398397
Title: title,
@@ -411,14 +410,16 @@ func (n NotificationBody) toContactRequestNotification(id string, profilePicture
411410
Timestamp: n.Message.WhisperTimestamp,
412411
IsConversation: true,
413412
Image: "",
414-
}, nil
413+
}
414+
applyAuthorPrivacy(notif, messagePreview)
415+
return notif, nil
415416
}
416417

417418
func (n NotificationBody) toPrivateGroupInviteNotification(id string, profilePicturesVisibility int, messagePreview int) *localnotifications.Notification {
418419
title := n.Contact.PrimaryName() + " invited you to " + n.Chat.Name
419420
message := n.Contact.PrimaryName() + " wants you to join group " + n.Chat.Name
420421
displayTitle, displayMessage := applyMessagePreview(title, message, messagePreview)
421-
return &localnotifications.Notification{
422+
notif := &localnotifications.Notification{
422423
ID: gethcommon.HexToHash(id),
423424
Body: n,
424425
Title: title,
@@ -436,13 +437,15 @@ func (n NotificationBody) toPrivateGroupInviteNotification(id string, profilePic
436437
ChatIcon: chatIconDataURI(n.Chat),
437438
Image: "",
438439
}
440+
applyAuthorPrivacy(notif, messagePreview)
441+
return notif
439442
}
440443

441444
func (n NotificationBody) toCommunityRequestToJoinNotification(id string, profilePicturesVisibility int, messagePreview int) *localnotifications.Notification {
442445
title := n.Contact.PrimaryName() + " wants to join " + n.Community.Name()
443-
message := n.Contact.PrimaryName() + " wants to join message " + n.Community.Name()
446+
message := n.Contact.PrimaryName() + " wants to join " + n.Community.Name()
444447
displayTitle, displayMessage := applyMessagePreview(title, message, messagePreview)
445-
return &localnotifications.Notification{
448+
notif := &localnotifications.Notification{
446449
ID: gethcommon.HexToHash(id),
447450
Body: n,
448451
Title: title,
@@ -460,4 +463,6 @@ func (n NotificationBody) toCommunityRequestToJoinNotification(id string, profil
460463
CommunityIcon: communityIconDataURI(n.Community),
461464
Image: "",
462465
}
466+
applyAuthorPrivacy(notif, messagePreview)
467+
return notif
463468
}

protocol/messenger.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2789,7 +2789,6 @@ func (r *ReceivedMessageState) addNewMessageNotification(messenger *Messenger, s
27892789
if !msg.New {
27902790
return nil
27912791
}
2792-
fmt.Printf("[messenger] addNewMessageNotification: considering msgId=%s chatId=%s (m.New=true)\n", msg.ID, msg.LocalChatID)
27932792

27942793
pubKey, err := msg.GetSenderPubKey()
27952794
if err != nil {
@@ -2831,13 +2830,8 @@ func (r *ReceivedMessageState) addNewMessageNotification(messenger *Messenger, s
28312830
if err != nil {
28322831
return err
28332832
}
2834-
fmt.Printf("[messenger] addNewMessageNotification: ADDING notification msgId=%s chatId=%s\n", msg.ID, msg.LocalChatID)
28352833
r.Response.AddNotification(notification)
2836-
} else {
2837-
fmt.Printf("[messenger] addNewMessageNotification: SKIP showMessageNotification=false msgId=%s chatId=%s\n", msg.ID, msg.LocalChatID)
28382834
}
2839-
} else {
2840-
fmt.Printf("[messenger] addNewMessageNotification: SKIP chat muted msgId=%s chatId=%s\n", msg.ID, msg.LocalChatID)
28412835
}
28422836

28432837
return nil

services/local-notifications/core.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package localnotifications
33
import (
44
"database/sql"
55
"encoding/json"
6-
"fmt"
76

87
"github.com/ethereum/go-ethereum/common"
98
"github.com/ethereum/go-ethereum/rpc"
@@ -148,7 +147,6 @@ func PushMessages(ns []*Notification) {
148147
}
149148

150149
func pushMessage(notification *Notification) {
151-
fmt.Printf("[local-notifications] pushMessage: title=%q convId=%s deleted=%v\n", notification.Title, notification.ConversationID, notification.Deleted)
152150
logutils.ZapLogger().Debug("Pushing a new push notification")
153151
signal.SendLocalNotifications(notification)
154152
}

signal/events_pn.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package signal
22

3-
import "fmt"
4-
53
const (
64
notificationEvent = "local-notifications"
75
)
86

97
// SendLocalNotifications sends event with a local notification.
108
func SendLocalNotifications(event interface{}) {
11-
fmt.Printf("[signal] SendLocalNotifications: invoking send(%q, ...)\n", notificationEvent)
129
send(notificationEvent, event)
1310
}

signal/signals.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ extern void SetEventCallback(void *cb);
1010
import "C"
1111
import (
1212
"encoding/json"
13-
"fmt"
1413
"sync"
1514
"time"
1615
"unsafe"
@@ -59,13 +58,9 @@ func send(typ string, event interface{}) {
5958

6059
// If a Go implementation of signal handler is set, let's use it.
6160
if mobileSignalHandler != nil {
62-
fmt.Printf("[signal] send(%q): using mobileSignalHandler\n", typ)
63-
logger.Debug("signal.send using mobileSignalHandler", zap.String("type", typ))
6461
mobileSignalHandler(data)
6562
} else {
6663
// ...and fallback to C implementation otherwise.
67-
fmt.Printf("[signal] send(%q): using C StatusServiceSignalEvent, len=%d\n", typ, len(data))
68-
logger.Debug("signal.send using C StatusServiceSignalEvent", zap.String("type", typ))
6964
str := C.CString(string(data))
7065
C.StatusServiceSignalEvent(str)
7166
C.free(unsafe.Pointer(str))

0 commit comments

Comments
 (0)