Files
status-go/internal/protocol/messenger_settings.go
Igor Sirotin f3e4363808 refactor: move protocol to internal/protocol
Part of the Go project layout migration, item 27.

Pure move plus import-path rewrite across 502 files. No API or behaviour
change. `internal/` keeps the messaging application logic unimportable
from outside the module, which is what the issue asks for -- status-go is
consumed through the C-bindings in mobile/, not as a Go library.

Things that had to follow the move, beyond the Go imports:

- tools/generate-handlers/template.txt. messenger_handlers.go is
  generated, and the template hard-codes the imports it emits, so the
  generated file kept importing protocol/common and failed typecheck.
- .gitignore. The ignore rule for that generated file was pinned to the
  old path; without moving it, a 1486-line generated file starts being
  tracked.
- Makefile: the logosstorage and torrent test targets (both the archive
  packages and ./protocol itself), the archive README, migration-protocol.
- scripts/run_unit_tests.sh, which names the protocol package explicitly
  to shard its tests.
- scripts/cleanup_generated_files.sh and .golangci.yml.

scripts/migration_check.sh also needed a fix that is not specific to this
move: it validated every file the branch touched under a migration dir
against the timestamp naming rule, and a directory rename makes every
migration in it look newly added. It now excludes renames, so moving a
migration is not mistaken for adding one.

refs #7067
2026-08-21 10:11:05 +02:00

100 lines
2.5 KiB
Go

package protocol
import (
"context"
"github.com/status-im/status-go/internal/nodecfg"
"github.com/status-im/status-go/internal/protocol/requests"
"github.com/status-im/status-go/internal/timesource"
)
func (m *Messenger) SetLightClient(request *requests.SetLightClient) error {
return nodecfg.SetLightClient(m.database, request.Enabled)
}
func (m *Messenger) SetSyncingOnMobileNetwork(request *requests.SetSyncingOnMobileNetwork) error {
if err := request.Validate(); err != nil {
return err
}
err := m.settings.SetSyncingOnMobileNetwork(request.Enabled)
if err != nil {
return err
}
if request.Enabled {
m.notifyHistoricSyncWorker()
}
return nil
}
// Deprecated: Use SetLogLevel from status.go instead.
func (m *Messenger) SetLogLevel(request *requests.SetLogLevel) error {
if err := request.Validate(); err != nil {
return err
}
return nodecfg.SetLogLevel(m.database, request.LogLevel)
}
// Deprecated: Use SetLogNamespaces from status.go instead.
func (m *Messenger) SetLogNamespaces(request *requests.SetLogNamespaces) error {
if err := request.Validate(); err != nil {
return err
}
return nodecfg.SetLogNamespaces(m.database, request.LogNamespaces)
}
// Deprecated: Use SetLogEnabled from status.go instead.
func (m *Messenger) SetLogEnabled(enabled bool) error {
return nodecfg.SetLogEnabled(m.database, enabled)
}
func (m *Messenger) SetMaxLogBackups(request *requests.SetMaxLogBackups) error {
return nodecfg.SetMaxLogBackups(m.database, request.MaxLogBackups)
}
func (m *Messenger) SetCustomizationColor(ctx context.Context, request *requests.SetCustomizationColor) error {
if err := request.Validate(); err != nil {
return err
}
acc, err := m.multiAccounts.GetAccount(request.KeyUID)
if err != nil {
return err
}
acc.CustomizationColor = request.CustomizationColor
if m.account != nil {
m.account.CustomizationColor = request.CustomizationColor
}
//Use a combination of wall clock + lamport timestamp, just like Chat#NextClockAndTimestamp
tNow := timesource.GetCurrentTimeInMillis()
if acc.CustomizationColorClock >= tNow {
acc.CustomizationColorClock++
} else {
acc.CustomizationColorClock = tNow
}
affected, err := m.multiAccounts.UpdateAccountCustomizationColor(request.KeyUID, string(acc.CustomizationColor), acc.CustomizationColorClock)
if err != nil {
return err
}
if affected > 0 {
err = m.syncAccountCustomizationColor(ctx, acc)
if err != nil {
return err
}
err = m.resetLastPublishedTimeForChatIdentity()
if err != nil {
return err
}
return m.publishContactCode()
}
return nil
}