diff --git a/prod_rmq_agents/user_state.py b/prod_rmq_agents/user_state.py index 53445c284c92ae035ebadcb14c837d540ca9c3a2..f9b74a1071675f4da70cb17d7d34d01ad4176776 100644 --- a/prod_rmq_agents/user_state.py +++ b/prod_rmq_agents/user_state.py @@ -22,6 +22,7 @@ rc_rmq = RCRMQ({"exchange": rcfg.Exchange, "exchange_type": "topic"}) def user_state(ch, method, properties, body): msg = json.loads(body) username = msg["username"] + updated_by = msg.get("updated_by") op = msg["op"] msg["success"] = False errmsg = "" @@ -47,7 +48,12 @@ def user_state(ch, method, properties, body): state = msg["state"] errmsg = "Updating state of {username} to {state}" table.insert( - {"username": username, "state": state, "date": datetime.now()} + { + "username": username, + "state": state, + "date": datetime.now(), + "updated_by": updated_by, + } ) logger.debug(f"User {username} state updates to {state}") diff --git a/rc_util.py b/rc_util.py index fbb7c39ec8ee73fa6ef6ceb9d144bf170e4221e1..271debb37029632bfda9f6e1f786b6b865679697 100644 --- a/rc_util.py +++ b/rc_util.py @@ -214,7 +214,7 @@ def check_state(username, debug=False): @timeout(rcfg.Function_timeout) -def update_state(username, state, debug=False): +def update_state(username, state, updated_by=None, debug=False): if state not in rcfg.Valid_state: print(f"Invalid state '{state}'") @@ -249,7 +249,12 @@ def update_state(username, state, debug=False): "props": pika.BasicProperties( reply_to=callback_queue, correlation_id=corr_id ), - "msg": {"op": "post", "username": username, "state": state}, + "msg": { + "op": "post", + "username": username, + "state": state, + "updated_by": updated_by, + }, } )