robotAPI struct instead of robot struct

main
alex 2023-10-17 17:22:09 +02:00
parent 2a637f3426
commit 6cb66ad400
1 changed files with 16 additions and 2 deletions

View File

@ -120,14 +120,28 @@ func FirstRequest(c *fiber.Ctx) error {
func addRobotSSEMessage(newRobot *structs.Robot) {
totalPages := cache.GetAllRobots(rspagination.PageQuery{Page: 1}).TotalPages
apiRobot := structs.APIRobot{
Id: newRobot.Id,
Type: newRobot.Type,
Name: newRobot.Name,
Status: newRobot.Status,
Address: newRobot.Address,
CurrentJobName: newRobot.CurrentJobName,
JobsWaitingCount: newRobot.JobsWaitingCount,
JobsWaitingNameList: []string{},
FirmwareVersion: newRobot.FirmwareVersion,
ConnectedAt: newRobot.ConnectedAt,
CreatedAt: newRobot.CreatedAt,
}
robot.BroadcastSSEMessage(structs.SSEMessage{
Cmd: utils.SSESentCmdAddRobot,
Body: struct {
Robot *structs.Robot
Robot *structs.APIRobot
TotalPages int
UnauthorizedRobotsTotalPages int
}{
Robot: newRobot,
Robot: &apiRobot,
TotalPages: totalPages,
UnauthorizedRobotsTotalPages: cache.GetAllUnauthorizedRobots(rspagination.PageQuery{Page: 1}).TotalPages,
},