scanner
parent
e81bdc2ba9
commit
8cc63fc0ef
|
@ -31,18 +31,22 @@ func InvexApiRequestClient(requestMethod string, url string) (statusCode int, bo
|
||||||
if code == 401 {
|
if code == 401 {
|
||||||
log.Error().Msgf("invex not authorized, code: %d", code)
|
log.Error().Msgf("invex not authorized, code: %d", code)
|
||||||
|
|
||||||
logger.AddSystemLog(rslogger.LogTypeInfo, "InvexApiRequestClient err: %s statusCode: %s",
|
logger.AddSystemLog(rslogger.LogTypeError, "InvexApiRequestClient err: %s statusCode: %s",
|
||||||
"invex not authorized", strconv.Itoa(code))
|
"invex not authorized", strconv.Itoa(code))
|
||||||
|
|
||||||
return code, nil, err
|
return code, nil, err
|
||||||
}
|
} else if code == 404 {
|
||||||
|
|
||||||
if code == 404 {
|
|
||||||
log.Error().Msgf("Invex stock item not found, code: %d", code)
|
log.Error().Msgf("Invex stock item not found, code: %d", code)
|
||||||
|
|
||||||
logger.AddSystemLog(rslogger.LogTypeInfo, "InvexApiRequestClient err: %s statusCode: %s",
|
logger.AddSystemLog(rslogger.LogTypeWarning, "InvexApiRequestClient err: %s statusCode: %s",
|
||||||
"invex stock item not found", strconv.Itoa(code))
|
"invex stock item not found", strconv.Itoa(code))
|
||||||
|
|
||||||
|
return code, nil, err
|
||||||
|
} else if code != 200 {
|
||||||
|
log.Error().Msgf("InvexApiRequestClient request failed, statusCode: %s", strconv.Itoa(code))
|
||||||
|
|
||||||
|
logger.AddSystemLog(rslogger.LogTypeError, "InvexApiRequestClient request failed, statusCode: %s", strconv.Itoa(code))
|
||||||
|
|
||||||
return code, nil, err
|
return code, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ const (
|
||||||
SentCmdGroupTasksReloaded = 8
|
SentCmdGroupTasksReloaded = 8
|
||||||
SentCmdUpdateUserSessions = 9
|
SentCmdUpdateUserSessions = 9
|
||||||
SentCmdUpdateAllUsersUserAvatar = 10
|
SentCmdUpdateAllUsersUserAvatar = 10
|
||||||
|
SentCmdScannerNewScan = 11
|
||||||
|
|
||||||
SentCmdTaskLocked = 16
|
SentCmdTaskLocked = 16
|
||||||
SentCmdTaskUnlocked = 17
|
SentCmdTaskUnlocked = 17
|
||||||
|
@ -111,6 +112,7 @@ const (
|
||||||
ReceivedCmdAllUsersDeleteUser = 13
|
ReceivedCmdAllUsersDeleteUser = 13
|
||||||
ReceivedCmdAllUsersUserDeactivation = 14
|
ReceivedCmdAllUsersUserDeactivation = 14
|
||||||
ReceivedCmdScannerNewScan = 15
|
ReceivedCmdScannerNewScan = 15
|
||||||
|
|
||||||
ReceivedCmdHandleUserActionTaskStep = 18
|
ReceivedCmdHandleUserActionTaskStep = 18
|
||||||
ReceivedCmdCreateNewUserApiKey = 19
|
ReceivedCmdCreateNewUserApiKey = 19
|
||||||
ReceivedCmdDeleteUserApiKey = 20
|
ReceivedCmdDeleteUserApiKey = 20
|
||||||
|
|
|
@ -167,6 +167,14 @@ func SendMessageToUsersByRoleId(roleId string, sendSocketMessage structs.SendSoc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SendMessageToUserExceptBrowserTabSession(userId string, ignoreBrowserTabSession string, sendSocketMessage structs.SendSocketMessage) {
|
||||||
|
for _, client := range cache.GetSocketClients() {
|
||||||
|
if client.UserId == userId && client.BrowserTabSession != ignoreBrowserTabSession {
|
||||||
|
client.SendMessage(sendSocketMessage)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This close all connections that are connected with one session id.
|
// This close all connections that are connected with one session id.
|
||||||
// For example when a user has two browser tabs opened
|
// For example when a user has two browser tabs opened
|
||||||
func CloseAllUserSessionConnections(sessionId string) {
|
func CloseAllUserSessionConnections(sessionId string) {
|
||||||
|
|
|
@ -271,6 +271,11 @@ func RunHub() {
|
||||||
break
|
break
|
||||||
case utils.ReceivedCmdScannerNewScan:
|
case utils.ReceivedCmdScannerNewScan:
|
||||||
log.Info().Msgf("Received new scan: %v", receivedMessage.Body)
|
log.Info().Msgf("Received new scan: %v", receivedMessage.Body)
|
||||||
|
|
||||||
|
socketclients.SendMessageToUserExceptBrowserTabSession(data.Conn.Locals("userId").(string), data.Conn.Locals("browserTabSession").(string), structs.SendSocketMessage{
|
||||||
|
Cmd: utils.SentCmdScannerNewScan,
|
||||||
|
Body: receivedMessage.Body["Scan"],
|
||||||
|
})
|
||||||
break
|
break
|
||||||
case utils.ReceivedCmdHandleUserActionTaskStep:
|
case utils.ReceivedCmdHandleUserActionTaskStep:
|
||||||
if !socketclients.HasXYPermission(data.Conn.Locals("userId").(string), utils.PermissionGroupTasksOverviewXYReloadGroupConfig, receivedMessage.Body["category"].(string)) {
|
if !socketclients.HasXYPermission(data.Conn.Locals("userId").(string), utils.PermissionGroupTasksOverviewXYReloadGroupConfig, receivedMessage.Body["category"].(string)) {
|
||||||
|
|
Loading…
Reference in New Issue