mirror of
https://github.com/micromdm/micromdm/
synced 2026-06-03 15:56:29 +08:00
Add more logic to the way code is organized. /pkg -- library code not directly connected to micromdm /mdm -- packages meant for the services devices interract with. The MDM protocol. /dep -- DEP API and related packages. /platform -- Core APIs the server provides. Commands API, Devices API, queue, pubsub etc. /workflow -- Packages/API that build on top of platform. Today that's the webhook package. Depending on what ends up here, the workflow folder might become its own repository.
35 lines
863 B
Go
35 lines
863 B
Go
package queue
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/micromdm/micromdm/platform/queue/internal/commandqueuedproto"
|
|
)
|
|
|
|
type QueueCommandQueued struct {
|
|
DeviceUDID string
|
|
CommandUUID string
|
|
}
|
|
|
|
func MarshalQueuedCommand(cq *QueueCommandQueued) ([]byte, error) {
|
|
if cq == nil {
|
|
return nil, errors.New("marshalling nil QueueCommandQueued")
|
|
}
|
|
return proto.Marshal(&commandqueued.CommandQueued{
|
|
DeviceUdid: cq.DeviceUDID,
|
|
CommandUuid: cq.DeviceUDID,
|
|
})
|
|
}
|
|
|
|
func UnmarshalQueuedCommand(data []byte) (*QueueCommandQueued, error) {
|
|
cmdQueued := commandqueued.CommandQueued{}
|
|
if err := proto.Unmarshal(data, &cmdQueued); err != nil {
|
|
return nil, err
|
|
}
|
|
queueCmdQueued := new(QueueCommandQueued)
|
|
queueCmdQueued.DeviceUDID = cmdQueued.DeviceUdid
|
|
queueCmdQueued.CommandUUID = cmdQueued.CommandUuid
|
|
return queueCmdQueued, nil
|
|
}
|