update CreateOptions
This commit is contained in:
parent
348a8ddb13
commit
43fc966f9a
|
@ -21,6 +21,9 @@ type CreateOptions struct {
|
||||||
Language string
|
Language string
|
||||||
Model string
|
Model string
|
||||||
Manufacturer string
|
Manufacturer string
|
||||||
|
OsName string
|
||||||
|
OsVersion string
|
||||||
|
IsMobile bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ...
|
// Create ...
|
||||||
|
@ -63,6 +66,12 @@ func (payload CreateOptions) newDevice() Device {
|
||||||
// Get userAgent data
|
// Get userAgent data
|
||||||
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
|
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
|
||||||
|
|
||||||
|
if osName == "" || osVersion == "" {
|
||||||
|
osName = payload.OsName
|
||||||
|
osVersion = payload.OsVersion
|
||||||
|
isMobile = payload.IsMobile
|
||||||
|
}
|
||||||
|
|
||||||
userID, _ := mongodb.NewIDFromString(payload.UserID)
|
userID, _ := mongodb.NewIDFromString(payload.UserID)
|
||||||
return Device{
|
return Device{
|
||||||
ID: mongodb.NewObjectID(),
|
ID: mongodb.NewObjectID(),
|
||||||
|
|
|
@ -21,6 +21,9 @@ type UpdateOptions struct {
|
||||||
Language string
|
Language string
|
||||||
Model string
|
Model string
|
||||||
Manufacturer string
|
Manufacturer string
|
||||||
|
OsName string
|
||||||
|
OsVersion string
|
||||||
|
IsMobile bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateByDeviceID ...
|
// UpdateByDeviceID ...
|
||||||
|
@ -46,6 +49,11 @@ func (s Service) UpdateByDeviceID(deviceID string, payload UpdateOptions) error
|
||||||
|
|
||||||
// Get userAgent data
|
// Get userAgent data
|
||||||
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
|
osName, osVersion, isMobile := getUserAgentData(payload.UserAgent)
|
||||||
|
if osName == "" || osVersion == "" {
|
||||||
|
osName = payload.OsName
|
||||||
|
osVersion = payload.OsVersion
|
||||||
|
isMobile = payload.IsMobile
|
||||||
|
}
|
||||||
|
|
||||||
// Setup update data
|
// Setup update data
|
||||||
userID, _ := mongodb.NewIDFromString(payload.UserID)
|
userID, _ := mongodb.NewIDFromString(payload.UserID)
|
||||||
|
|
Loading…
Reference in New Issue