Merge pull request #742 from resin-io/740-spurious-state-reporting

fix: Don't send internal state tracking information to the API
This commit is contained in:
CameronDiver 2018-09-05 12:25:58 -07:00 committed by GitHub
commit 4df981697e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,6 +18,12 @@ ExchangeKeyError = class ExchangeKeyError extends TypedError
REPORT_SUCCESS_DELAY = 1000
MAX_REPORT_RETRY_DELAY = 60000
INTERNAL_STATE_KEYS = [
'update_pending',
'update_downloaded',
'update_failed',
]
createAPIBinderRouter = (apiBinder) ->
router = express.Router()
router.use(bodyParser.urlencoded(extended: true))
@ -392,10 +398,14 @@ module.exports = class APIBinder
_getStateDiff: =>
diff = {
local: _.omitBy @stateForReport.local, (val, key) =>
_.isEqual(@lastReportedState.local[key], val)
dependent: _.omitBy @stateForReport.dependent, (val, key) =>
_.isEqual(@lastReportedState.dependent[key], val)
local: _(@stateForReport.local)
.omitBy((val, key) => _.isEqual(@lastReportedState.local[key], val))
.omit(INTERNAL_STATE_KEYS)
.value()
dependent: _(@stateForReport.dependent)
.omitBy((val, key) => _.isEqual(@lastReportedState.dependent[key], val))
.omit(INTERNAL_STATE_KEYS)
.value()
}
return _.pickBy(diff, _.negate(_.isEmpty))