Skip to content

Commit

Permalink
Merge pull request #378 from safing/feature/ui-profile-upgrade
Browse files Browse the repository at this point in the history
Upgrade ui profile for support page
  • Loading branch information
ppacher authored Aug 19, 2021
2 parents 85cb66d + cc20d81 commit d5c6231
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion profile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type Profile struct { //nolint:maligned // not worth the effort
// when this Profile was approximately last used.
// For performance reasons not every single usage is saved.
ApproxLastUsed int64
// LastEdited hols the UTC timestamp in seconds when the profile was last
// LastEdited holds the UTC timestamp in seconds when the profile was last
// edited by the user. This is not set automatically, but has to be manually
// set by the user interface.
LastEdited int64
Expand Down
28 changes: 4 additions & 24 deletions profile/special.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package profile

import (
"fmt"
"time"

"github.com/safing/portbase/notifications"

"github.com/safing/portbase/log"
)

Expand Down Expand Up @@ -139,6 +136,7 @@ In order to respect the app settings of the actual application, DNS requests fro
CfgOptionDefaultActionKey: "block",
CfgOptionEndpointsKey: []string{
"+ Localhost",
"+ .safing.io",
},
},
)
Expand Down Expand Up @@ -182,6 +180,8 @@ func specialProfileNeedsReset(profile *Profile) bool {
switch profile.ID {
case SystemResolverProfileID:
return canBeUpgraded(profile, "1.6.2021")
case PortmasterAppProfileID:
return canBeUpgraded(profile, "1.9.2021")
default:
// Not a special profile or no upgrade available yet.
return false
Expand All @@ -197,28 +197,8 @@ func canBeUpgraded(profile *Profile, upgradeDate string) bool {
}

// Check if the upgrade is applicable.
if profile.Meta().Created < upgradeTime.Unix() {
if profile.Created < upgradeTime.Unix() {
log.Infof("profile: upgrading special profile %s", profile.ScopedID())

notifications.NotifyInfo(
"profiles:upgraded-special-profile:"+profile.ID,
profile.Name+" Settings Upgraded",
// TODO: Remove disclaimer.
fmt.Sprintf(
"The %s settings were automatically upgraded. The current app settings have been replaced, as the Portmaster did not detect any changes made by you. Please note that settings upgrades before June 2021 might not detect previous changes correctly and you might want to review the new settings.",
profile.Name,
),
notifications.Action{
ID: "ack",
Text: "OK",
},
notifications.Action{
Text: "Open Settings",
Type: notifications.ActionTypeOpenProfile,
Payload: profile.ScopedID(),
},
)

return true
}

Expand Down

0 comments on commit d5c6231

Please sign in to comment.