Add 'in_accepted_state' to fsm_update messages

This commit is contained in:
Kristóf Tóth 2018-07-20 14:39:23 +02:00
parent e1e0acb3b8
commit 96b4e314a9
2 changed files with 5 additions and 1 deletions

View File

@ -59,8 +59,10 @@ class FSMUpdater:
for trigger in self.fsm.get_triggers(self.fsm.state)
]
last_trigger = self.fsm.trigger_history[-1] if self.fsm.trigger_history else None
in_accepted_state = state in self.fsm.accepted_states
return {
'current_state': state,
'valid_transitions': valid_transitions,
'last_trigger': last_trigger
'last_trigger': last_trigger,
'in_accepted_state': in_accepted_state
}

View File

@ -116,6 +116,7 @@ class FSMAwareEventHandler(EventHandlerBase, ABC):
super().__init__(key)
self.subscribe('fsm_update')
self.fsm_state = None
self.in_accepted_state = False
self._auth_key = KeyManager().auth_key
def dispatch_handling(self, message):
@ -132,6 +133,7 @@ class FSMAwareEventHandler(EventHandlerBase, ABC):
if self.fsm_state != new_state:
self.handle_fsm_step(self.fsm_state, new_state, trigger)
self.fsm_state = new_state
self.in_accepted_state = message['data']['in_accepted_state']
except KeyError:
LOG.error('Invalid fsm_update message received!')