Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Improve features
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Aug 9, 2023
1 parent 1fa9a93 commit dd98157
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
12 changes: 6 additions & 6 deletions access/account/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (u *User) MayUseSPN() bool {

// MayUsePrioritySupport returns whether the user may currently use the priority support.
func (u *User) MayUsePrioritySupport() bool {
return u.MayUse(FeaturePrioritySupport)
return u.MayUse(FeatureSafingSupport)
}

// MayUse returns whether the user may currently use the feature identified by
Expand Down Expand Up @@ -120,11 +120,11 @@ type FeatureID string

// A list of all supported features.
const (
FeatureSPN = FeatureID("spn")
FeaturePrioritySupport = FeatureID("support")
FeatureHistory = FeatureID("history")
FeatureBWVis = FeatureID("bw-vis")
FeatureVPNCompat = FeatureID("vpn-compat")
FeatureSPN = FeatureID("spn")
FeatureSafingSupport = FeatureID("support")
FeatureHistory = FeatureID("history")
FeatureBWVis = FeatureID("bw-vis")
FeatureVPNCompat = FeatureID("vpn-compat")
)

// Plan describes an SPN subscription plan.
Expand Down
6 changes: 3 additions & 3 deletions access/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,19 @@ func registerAPIEndpoints() error {
}

if err := api.RegisterEndpoint(api.Endpoint{
Path: `account/features/{id:[A-Za-z0-9_]+}/icon`,
Path: `account/features/{id:[A-Za-z0-9_-]+}/icon`,
Read: api.PermitUser,
ReadMethod: http.MethodGet,
Name: "Returns the image of the featuare",
MimeType: "image/svg+xml",
DataFunc: func(ar *api.Request) (data []byte, err error) {
featureId, ok := ar.URLVars["id"]
featureID, ok := ar.URLVars["id"]
if !ok {
return nil, fmt.Errorf("invalid feature id")
}

for _, feature := range features {
if feature.ID == featureId {
if feature.ID == featureID {
return []byte(feature.icon), nil
}
}
Expand Down
28 changes: 14 additions & 14 deletions access/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import "github.com/safing/spn/access/account"

// Feature describes a notable part of the program.
type Feature struct {
ID string
Name string
ID string
RequiredFeatureID account.FeatureID
ConfigKey string
ConfigScope string
RequiredFeatureID account.FeatureID // FIXME: can more than one be required?
InPackage *Package
Comment string
Beta bool
CommingSoon bool
ComingSoon bool
icon string
}

Expand Down Expand Up @@ -42,8 +42,8 @@ var (
}
features = []Feature{
{
ID: "secure_dns",
Name: "Secure DNS",
ID: "dns",
ConfigScope: "dns/",
InPackage: packageFree,
icon: `
Expand All @@ -54,8 +54,8 @@ var (
`,
},
{
ID: "privacy_filter",
Name: "Privacy Filter",
ID: "filter",
ConfigScope: "filter/",
InPackage: packageFree,
icon: `
Expand All @@ -65,12 +65,12 @@ var (
`,
},
{
ID: "network_history",
Name: "Network History",
ID: string(account.FeatureHistory),
RequiredFeatureID: account.FeatureHistory,
ConfigKey: "history/enable",
ConfigScope: "history/",
InPackage: packagePlus,
RequiredFeatureID: account.FeatureHistory,
Beta: true,
icon: `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
Expand All @@ -80,11 +80,11 @@ var (
`,
},
{
ID: "bandwith_vis",
Name: "Bandwidth Visibility",
InPackage: packagePlus,
ID: string(account.FeatureBWVis),
RequiredFeatureID: account.FeatureBWVis,
CommingSoon: true,
InPackage: packagePlus,
Beta: true,
icon: `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -93,10 +93,10 @@ var (
`,
},
{
ID: "priority_support",
Name: "Priority Support",
Name: "Safing Support",
ID: string(account.FeatureSafingSupport),
RequiredFeatureID: account.FeatureSafingSupport,
InPackage: packagePlus,
RequiredFeatureID: account.FeaturePrioritySupport,
icon: `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
Expand All @@ -105,8 +105,8 @@ var (
`,
},
{
ID: "spn",
Name: "Safing Privacy Network",
ID: string(account.FeatureSPN),
RequiredFeatureID: account.FeatureSPN,
ConfigKey: "spn/enable",
ConfigScope: "spn/",
Expand Down

0 comments on commit dd98157

Please sign in to comment.