Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] snooze rpc #23305

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions go/install/install_darwinwindows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os/exec"
"strconv"
"strings"

"github.com/keybase/client/go/libkb"
)

// GetNeedUpdate returns true if updater says we have a new update available.
Expand All @@ -29,3 +31,15 @@ func GetNeedUpdate() (bool, error) {
}
return needUpdate, nil
}

// SnoozeUpdate will snooze the new update (if there is one) for 24 hrs.
func SnoozeUpdate(mctx libkb.MetaContext) error {
updaterPath, err := UpdaterBinPath()
if err != nil {
return err
}
exec.Command(updaterPath, "snooze")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if err != nil {
return err
}
}
6 changes: 6 additions & 0 deletions go/install/install_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,9 @@ func WatchdogLogPath(string) (string, error) {
func SystemLogPath() string {
return ""
}

// SnoozeUpdate will snooze all updates indefinitely
func SnoozeUpdate(mctx libkb.MetaContext) error {
mctx.G().Env.GetConfigWriter().SetSnoozeUpdates(true)
return nil
}
6 changes: 6 additions & 0 deletions go/libkb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ func (f *JSONConfigFile) GetRememberPassphrase(username NormalizedUsername) (boo
}
return f.GetTopLevelBool(legacyRememberPassphraseKey)
}
func (f *JSONConfigFile) GetSnoozeUpdates() (bool, bool) {
return f.GetBoolAtPath("snooze_updates")
}
func (f *JSONConfigFile) SetSnoozeUpdates(snoozeUpdates bool) error {
return f.SetBoolAtPath("snooze_updates", snoozeUpdates)
}
func (f *JSONConfigFile) GetStayLoggedOut() (bool, bool) {
return f.GetBoolAtPath("stay_logged_out")
}
Expand Down
2 changes: 2 additions & 0 deletions go/libkb/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ func (m MetaContext) switchUserNewConfig(u keybase1.UID, n NormalizedUsername, s
return err
}
}
// TODO: do i need to do anything particular for snooze_updates when user
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do i need to do anything particular for snooze_updates when user switching?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that updater settings is per-install and not per-user but @thebearjew should confirm

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually don't know the answer to this off the top of my head. I'll look into it.

// switching?
return g.ActiveDevice.SetOrClear(m, ad)
}

Expand Down
7 changes: 7 additions & 0 deletions go/libkb/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (n NullConfiguration) GetUsernameForUID(u keybase1.UID) NormalizedUsername
func (n NullConfiguration) GetUIDForUsername(u NormalizedUsername) keybase1.UID {
return keybase1.UID("")
}
func (n NullConfiguration) GetSnoozeUpdates() (bool, bool) { return false, false }
func (n NullConfiguration) GetStayLoggedOut() (bool, bool) { return false, false }
func (n NullConfiguration) GetAutoFork() (bool, bool) { return false, false }
func (n NullConfiguration) GetRunMode() (RunMode, error) { return NoRunMode, nil }
Expand Down Expand Up @@ -1136,6 +1137,12 @@ func (e *Env) GetEmail() string {
)
}

func (e *Env) GetSnoozeUpdates() bool {
return e.GetBool(false,
func() (bool, bool) { return e.GetConfig().GetSnoozeUpdates() },
)
}

func (e *Env) GetStayLoggedOut() bool {
return e.GetBool(false,
func() (bool, bool) { return e.GetConfig().GetStayLoggedOut() },
Expand Down
2 changes: 2 additions & 0 deletions go/libkb/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ type ConfigReader interface {
GetProxyCACerts() ([]string, error)
GetSecurityAccessGroupOverride() (bool, bool)
GetBug3964RepairTime(NormalizedUsername) (time.Time, error)
GetSnoozeUpdates() (bool, bool)
GetStayLoggedOut() (bool, bool)

GetUpdatePreferenceAuto() (bool, bool)
Expand Down Expand Up @@ -252,6 +253,7 @@ type ConfigWriter interface {
SetBug3964RepairTime(NormalizedUsername, time.Time) error
SetRememberPassphrase(NormalizedUsername, bool) error
SetPassphraseState(keybase1.PassphraseState) error
SetSnoozeUpdates(bool) error
SetStayLoggedOut(bool) error
Reset()
BeginTransaction() (ConfigWriterTransacter, error)
Expand Down
19 changes: 19 additions & 0 deletions go/protocol/keybase1/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions go/service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func (h ConfigHandler) StartUpdateIfNeeded(ctx context.Context) error {
return install.StartUpdateIfNeeded(ctx, h.G().Log)
}

func (h ConfigHandler) SnoozeUpdate(ctx context.Context) error {
m := libkb.NewMetaContext(ctx, h.G())
return install.SnoozeUpdate(m)
}

func (h ConfigHandler) WaitForClient(_ context.Context, arg keybase1.WaitForClientArg) (bool, error) {
return h.G().ConnectionManager.WaitForClientType(arg.ClientType, arg.Timeout.Duration()), nil
}
Expand Down
1 change: 1 addition & 0 deletions protocol/avdl/keybase1/config.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ protocol config {
// Same as running `keybase update check` in CLI.
void startUpdateIfNeeded();

void snoozeUpdate();

/**
Wait for client type to connect to service.
Expand Down
4 changes: 4 additions & 0 deletions protocol/json/keybase1/config.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions shared/constants/types/rpc-gen.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.