From 43fc966f9af4c5c1e8bc1f166e6472ccf4c3aa9f Mon Sep 17 00:00:00 2001 From: Hoang Date: Fri, 10 Dec 2021 11:46:25 +0700 Subject: [PATCH] update CreateOptions --- action_create.go | 9 +++++++++ action_update.go | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/action_create.go b/action_create.go index 832ae1e..2df1d4b 100644 --- a/action_create.go +++ b/action_create.go @@ -21,6 +21,9 @@ type CreateOptions struct { Language string Model string Manufacturer string + OsName string + OsVersion string + IsMobile bool } // Create ... @@ -63,6 +66,12 @@ func (payload CreateOptions) newDevice() Device { // Get userAgent data osName, osVersion, isMobile := getUserAgentData(payload.UserAgent) + if osName == "" || osVersion == "" { + osName = payload.OsName + osVersion = payload.OsVersion + isMobile = payload.IsMobile + } + userID, _ := mongodb.NewIDFromString(payload.UserID) return Device{ ID: mongodb.NewObjectID(), diff --git a/action_update.go b/action_update.go index 5d2c229..81f9044 100644 --- a/action_update.go +++ b/action_update.go @@ -21,6 +21,9 @@ type UpdateOptions struct { Language string Model string Manufacturer string + OsName string + OsVersion string + IsMobile bool } // UpdateByDeviceID ... @@ -46,6 +49,11 @@ func (s Service) UpdateByDeviceID(deviceID string, payload UpdateOptions) error // Get userAgent data osName, osVersion, isMobile := getUserAgentData(payload.UserAgent) + if osName == "" || osVersion == "" { + osName = payload.OsName + osVersion = payload.OsVersion + isMobile = payload.IsMobile + } // Setup update data userID, _ := mongodb.NewIDFromString(payload.UserID)