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.
// 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

View File

@@ -1,11 +1,8 @@
package profile
import (
"fmt"
"time"
"github.com/safing/portbase/notifications"
"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",
CfgOptionEndpointsKey: []string{
"+ Localhost",
"+ .safing.io",
},
},
)
@@ -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
@@ -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
}