Merge pull request #378 from safing/feature/ui-profile-upgrade

Upgrade ui profile for support page
This commit is contained in:
Patrick Pacher
2021-08-19 14:38:19 +02:00
committed by GitHub
2 changed files with 5 additions and 25 deletions

View File

@@ -102,7 +102,7 @@ type Profile struct { //nolint:maligned // not worth the effort
// when this Profile was approximately last used. // when this Profile was approximately last used.
// For performance reasons not every single usage is saved. // For performance reasons not every single usage is saved.
ApproxLastUsed int64 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 // edited by the user. This is not set automatically, but has to be manually
// set by the user interface. // set by the user interface.
LastEdited int64 LastEdited int64

View File

@@ -1,11 +1,8 @@
package profile package profile
import ( import (
"fmt"
"time" "time"
"github.com/safing/portbase/notifications"
"github.com/safing/portbase/log" "github.com/safing/portbase/log"
) )
@@ -139,6 +136,7 @@ In order to respect the app settings of the actual application, DNS requests fro
CfgOptionDefaultActionKey: "block", CfgOptionDefaultActionKey: "block",
CfgOptionEndpointsKey: []string{ CfgOptionEndpointsKey: []string{
"+ Localhost", "+ Localhost",
"+ .safing.io",
}, },
}, },
) )
@@ -182,6 +180,8 @@ func specialProfileNeedsReset(profile *Profile) bool {
switch profile.ID { switch profile.ID {
case SystemResolverProfileID: case SystemResolverProfileID:
return canBeUpgraded(profile, "1.6.2021") return canBeUpgraded(profile, "1.6.2021")
case PortmasterAppProfileID:
return canBeUpgraded(profile, "1.9.2021")
default: default:
// Not a special profile or no upgrade available yet. // Not a special profile or no upgrade available yet.
return false return false
@@ -197,28 +197,8 @@ func canBeUpgraded(profile *Profile, upgradeDate string) bool {
} }
// Check if the upgrade is applicable. // 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()) 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 return true
} }