mirror of
https://github.com/micromdm/micromdm/
synced 2026-08-13 14:05:42 +08:00
* Send APNS push to UDID after Commands being queued. In support of #100. Create a new protobuf & message type for post-queued commands. The push service listens for these and pushes to the devices as appropriate. * Break out subscriber as method on Push * Refactor event passing to use a struct * Error on nil argument
35 lines
854 B
Go
35 lines
854 B
Go
package queue
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
"github.com/micromdm/micromdm/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
|
|
}
|