Set LastQueryResponse to byte slice.

Marshal LastQueryResponse to JSON in connect.Service
This commit is contained in:
Mosen
2016-06-24 16:26:20 +10:00
parent 0c7a80b720
commit 00c8c9247f
2 changed files with 28 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
package connect
import (
"encoding/json"
"github.com/micromdm/mdm"
"github.com/micromdm/micromdm/command"
"github.com/micromdm/micromdm/device"
@@ -89,7 +90,11 @@ func (svc service) ackQueryResponses(req mdm.Response) error {
now := time.Now()
existing.LastCheckin = &now
existing.LastQueryResponse = req.QueryResponses
existing.LastQueryResponse, err = json.Marshal(req.QueryResponses)
if err != nil {
return err
}
existing.ProductName = req.QueryResponses.ProductName
existing.BuildVersion = req.QueryResponses.BuildVersion

View File

@@ -6,7 +6,7 @@ import (
"time"
"github.com/micromdm/dep"
"github.com/micromdm/mdm"
//"github.com/micromdm/mdm"
)
// Device represents an iOS or OS X Computer
@@ -21,27 +21,27 @@ type Device struct {
IMEI string `json:"imei,omitempty" db:"imei,omitempty"`
MEID string `json:"meid,omitempty" db:"meid,omitempty"`
//Apple MDM Protocol Topic
MDMTopic string `json:"mdm_topic,omitempty" db:"apple_mdm_topic,omitempty"`
PushMagic string `json:"push_magic,omitempty" db:"apple_push_magic,omitempty"`
AwaitingConfiguration bool `json:"awaiting_configuration,omitempty" db:"awaiting_configuration,omitempty"`
Token string `json:"token,omitempty" db:"apple_mdm_token,omitempty"`
UnlockToken string `json:"unlock_token,omitempty" db:"unlock_token,omitempty"`
Enrolled bool `json:"enrolled,omitempty" db:"mdm_enrolled,omitempty"`
Workflow string `json:"workflow_uuid,omitempty" db:"workflow_uuid,omitempty"`
DEPDevice bool `json:"dep_device,omitempty" db:"dep_device,omitempty"`
Description string `json:"description,omitempty" db:"description"`
Model string `json:"model,omitempty" db:"model"`
Color string `json:"color,omitempty" db:"color"`
AssetTag string `json:"asset_tag,omitempty" db:"asset_tag"`
DEPProfileStatus DEPProfileStatus `json:"dep_profile_status,omitempty" db:"dep_profile_status"`
DEPProfileUUID string `json:"dep_profile_uuid,omitempty" db:"dep_profile_uuid"`
DEPProfileAssignTime *time.Time `json:"dep_profile_assign_time,omitempty" db:"dep_profile_assign_time"`
DEPProfilePushTime *time.Time `json:"dep_profile_push_time,omitempty" db:"dep_profile_push_time"`
DEPProfileAssignedDate *time.Time `json:"dep_profile_assigned_date,omitempty" db:"dep_profile_assigned_date"`
DEPProfileAssignedBy string `json:"dep_profile_assigned_by,omitempty" db:"dep_profile_assigned_by"`
LastCheckin *time.Time `json:"last_checkin" db:"last_checkin"`
DeviceName string `json:"device_name" db:"device_name"`
LastQueryResponse mdm.QueryResponses `json:"last_query_response" db:"last_query_response"`
MDMTopic string `json:"mdm_topic,omitempty" db:"apple_mdm_topic,omitempty"`
PushMagic string `json:"push_magic,omitempty" db:"apple_push_magic,omitempty"`
AwaitingConfiguration bool `json:"awaiting_configuration,omitempty" db:"awaiting_configuration,omitempty"`
Token string `json:"token,omitempty" db:"apple_mdm_token,omitempty"`
UnlockToken string `json:"unlock_token,omitempty" db:"unlock_token,omitempty"`
Enrolled bool `json:"enrolled,omitempty" db:"mdm_enrolled,omitempty"`
Workflow string `json:"workflow_uuid,omitempty" db:"workflow_uuid,omitempty"`
DEPDevice bool `json:"dep_device,omitempty" db:"dep_device,omitempty"`
Description string `json:"description,omitempty" db:"description"`
Model string `json:"model,omitempty" db:"model"`
Color string `json:"color,omitempty" db:"color"`
AssetTag string `json:"asset_tag,omitempty" db:"asset_tag"`
DEPProfileStatus DEPProfileStatus `json:"dep_profile_status,omitempty" db:"dep_profile_status"`
DEPProfileUUID string `json:"dep_profile_uuid,omitempty" db:"dep_profile_uuid"`
DEPProfileAssignTime *time.Time `json:"dep_profile_assign_time,omitempty" db:"dep_profile_assign_time"`
DEPProfilePushTime *time.Time `json:"dep_profile_push_time,omitempty" db:"dep_profile_push_time"`
DEPProfileAssignedDate *time.Time `json:"dep_profile_assigned_date,omitempty" db:"dep_profile_assigned_date"`
DEPProfileAssignedBy string `json:"dep_profile_assigned_by,omitempty" db:"dep_profile_assigned_by"`
LastCheckin *time.Time `json:"last_checkin" db:"last_checkin"`
DeviceName string `json:"device_name" db:"device_name"`
LastQueryResponse []byte `json:"last_query_response" db:"last_query_response"`
}
// DEPProfileStatus is the status of the DEP Profile