Improved API privacy

This commit is contained in:
Eduard Urbach 2019-09-07 20:09:55 +09:00
parent 4e6aa5eef6
commit cc1c394002
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
6 changed files with 25 additions and 1 deletions

View File

@ -38,6 +38,11 @@ type ConnectionAnalytics struct {
EffectiveType string `json:"effectiveType"` EffectiveType string `json:"effectiveType"`
} }
// GetID returns the ID.
func (analytics *Analytics) GetID() string {
return analytics.UserID
}
// GetAnalytics returns the analytics for the given user ID. // GetAnalytics returns the analytics for the given user ID.
func GetAnalytics(userID UserID) (*Analytics, error) { func GetAnalytics(userID UserID) (*Analytics, error) {
obj, err := DB.Get("Analytics", userID) obj, err := DB.Get("Analytics", userID)

View File

@ -8,7 +8,8 @@ import (
// Force interface implementations // Force interface implementations
var ( var (
_ api.Newable = (*Analytics)(nil) _ Identifiable = (*Analytics)(nil)
_ api.Newable = (*Analytics)(nil)
) )
// Authorize returns an error if the given API POST request is not authorized. // Authorize returns an error if the given API POST request is not authorized.

View File

@ -5,3 +5,8 @@ type GoogleToUser struct {
ID string `json:"id" primary:"true"` ID string `json:"id" primary:"true"`
UserID UserID `json:"userId"` UserID UserID `json:"userId"`
} }
// GetID returns the ID.
func (mapping *GoogleToUser) GetID() string {
return mapping.ID
}

View File

@ -55,6 +55,11 @@ func (list *PushSubscriptions) Find(id string) *PushSubscription {
return nil return nil
} }
// GetID returns the ID.
func (list *PushSubscriptions) GetID() string {
return list.UserID
}
// GetPushSubscriptions ... // GetPushSubscriptions ...
func GetPushSubscriptions(id string) (*PushSubscriptions, error) { func GetPushSubscriptions(id string) (*PushSubscriptions, error) {
obj, err := DB.Get("PushSubscriptions", id) obj, err := DB.Get("PushSubscriptions", id)

View File

@ -10,6 +10,7 @@ import (
// Force interface implementations // Force interface implementations
var ( var (
_ Identifiable = (*PushSubscriptions)(nil)
_ api.Editable = (*PushSubscriptions)(nil) _ api.Editable = (*PushSubscriptions)(nil)
_ api.Filter = (*PushSubscriptions)(nil) _ api.Filter = (*PushSubscriptions)(nil)
) )
@ -91,6 +92,10 @@ func (list *PushSubscriptions) Filter() {
item.P256DH = "" item.P256DH = ""
item.Auth = "" item.Auth = ""
item.Endpoint = "" item.Endpoint = ""
item.Platform = ""
item.UserAgent = ""
item.Screen.Width = 0
item.Screen.Height = 0
} }
} }

View File

@ -15,11 +15,14 @@ import (
// privateTypes are types that are not available for download. // privateTypes are types that are not available for download.
var privateTypes = []string{ var privateTypes = []string{
"Analytics",
"EditLogEntry", "EditLogEntry",
"EmailToUser", "EmailToUser",
"FacebookToUser",
"PayPalPayment", "PayPalPayment",
"Purchase", "Purchase",
"Session", "Session",
"TwitterToUser",
} }
// Download downloads a snapshot of a database collection. // Download downloads a snapshot of a database collection.