mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-12 13:25:38 +08:00
Change function signature of connect service Acknowledge/NextCommand to thread the Context and mdmConnectRequest through.
This commit is contained in:
@@ -32,7 +32,7 @@ func makeConnectEndpoint(svc Service) endpoint.Endpoint {
|
||||
var err error
|
||||
switch req.Status {
|
||||
case "Acknowledged":
|
||||
total, err := svc.Acknowledge(req.UDID, req.CommandUUID)
|
||||
total, err := svc.Acknowledge(ctx, req)
|
||||
if err != nil {
|
||||
return mdmConnectResponse{Err: err}, nil
|
||||
}
|
||||
@@ -40,14 +40,14 @@ func makeConnectEndpoint(svc Service) endpoint.Endpoint {
|
||||
return mdmConnectResponse{}, nil
|
||||
}
|
||||
if total != 0 {
|
||||
next, _, err := svc.NextCommand(req.UDID)
|
||||
next, _, err := svc.NextCommand(ctx, req)
|
||||
if err != nil {
|
||||
return mdmConnectResponse{Err: err}, nil
|
||||
}
|
||||
return mdmConnectResponse{payload: next}, nil
|
||||
}
|
||||
case "Idle":
|
||||
next, total, err := svc.NextCommand(req.UDID)
|
||||
next, total, err := svc.NextCommand(ctx, req)
|
||||
if err != nil {
|
||||
return mdmConnectResponse{Err: err}, nil
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@ import (
|
||||
"github.com/micromdm/micromdm/command"
|
||||
"github.com/micromdm/micromdm/device"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// Service defines methods for an MDM service
|
||||
type Service interface {
|
||||
Acknowledge(deviceUDID, commandUUID string) (int, error)
|
||||
NextCommand(deviceUDID string) ([]byte, int, error)
|
||||
Acknowledge(ctx context.Context, req mdmConnectRequest) (int, error)
|
||||
NextCommand(ctx context.Context, req mdmConnectRequest) ([]byte, int, error)
|
||||
}
|
||||
|
||||
// NewService creates a mdm service
|
||||
@@ -26,13 +27,13 @@ type service struct {
|
||||
commands command.Service
|
||||
}
|
||||
|
||||
func (svc service) Acknowledge(deviceUDID, commandUUID string) (int, error) {
|
||||
total, err := svc.commands.DeleteCommand(deviceUDID, commandUUID)
|
||||
func (svc service) Acknowledge(ctx context.Context, req mdmConnectRequest) (int, error) {
|
||||
total, err := svc.commands.DeleteCommand(req.UDID, req.CommandUUID)
|
||||
if err != nil {
|
||||
return total, err
|
||||
}
|
||||
if total == 0 {
|
||||
total, err = svc.checkRequeue(deviceUDID)
|
||||
total, err = svc.checkRequeue(req.UDID)
|
||||
if err != nil {
|
||||
return total, err
|
||||
}
|
||||
@@ -41,8 +42,8 @@ func (svc service) Acknowledge(deviceUDID, commandUUID string) (int, error) {
|
||||
return total, nil
|
||||
}
|
||||
|
||||
func (svc service) NextCommand(deviceUDID string) ([]byte, int, error) {
|
||||
return svc.commands.NextCommand(deviceUDID)
|
||||
func (svc service) NextCommand(ctx context.Context, req mdmConnectRequest) ([]byte, int, error) {
|
||||
return svc.commands.NextCommand(req.UDID)
|
||||
}
|
||||
|
||||
func (svc service) checkRequeue(deviceUDID string) (int, error) {
|
||||
@@ -63,3 +64,8 @@ func (svc service) checkRequeue(deviceUDID string) (int, error) {
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// Acknowledge Queries sent with DeviceInformation command
|
||||
func (svc service) ackQueryResponses() (error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user