@@ -70,7 +70,15 @@ def compare_dictionaries(original, updates):
7070 return modified
7171
7272
73- async def send_to (doc , update = None , desk_id = None , stage_id = None , user_id = None , default_stage = "incoming_stage" ):
73+ async def send_to (
74+ doc ,
75+ update = None ,
76+ desk_id = None ,
77+ stage_id = None ,
78+ user_id = None ,
79+ default_stage = "incoming_stage" ,
80+ macro_kwargs = None ,
81+ ) -> None :
7482 """Send item to given desk and stage.
7583
7684 Applies the outgoing and incoming macros of current and destination stages
@@ -91,7 +99,7 @@ async def send_to(doc, update=None, desk_id=None, stage_id=None, user_id=None, d
9199 task = {"desk" : desk_id , "stage" : stage_id , "user" : original_task .get ("user" ) if user_id is None else user_id }
92100
93101 if current_stage :
94- await apply_stage_rule (doc , update , current_stage , MACRO_OUTGOING )
102+ await apply_stage_rule (doc , update , current_stage , MACRO_OUTGOING , macro_kwargs = macro_kwargs )
95103
96104 if desk_id :
97105 # TODO-ASYNC[desks]: Use DesksResourceModel async service where when upgrading this module
@@ -128,15 +136,17 @@ async def send_to(doc, update=None, desk_id=None, stage_id=None, user_id=None, d
128136 doc ["expiry" ] = get_item_expiry (desk = desk , stage = destination_stage )
129137
130138 if destination_stage :
131- await apply_stage_rule (doc , update , destination_stage , MACRO_INCOMING , desk = desk , task = task )
139+ await apply_stage_rule (
140+ doc , update , destination_stage , MACRO_INCOMING , desk = desk , task = task , macro_kwargs = macro_kwargs
141+ )
132142 if destination_stage .get ("task_status" ):
133143 if update :
134144 update ["task" ]["status" ] = destination_stage ["task_status" ]
135145 else :
136146 doc ["task" ]["status" ] = destination_stage ["task_status" ]
137147
138148
139- async def apply_stage_rule (doc , update , stage , rule_type , desk = None , task = None ):
149+ async def apply_stage_rule (doc , update , stage , rule_type , desk = None , task = None , macro_kwargs = None ):
140150 macro_type = "{}_macro" .format (rule_type )
141151
142152 if stage .get (macro_type ):
@@ -147,7 +157,7 @@ async def apply_stage_rule(doc, update, stage, rule_type, desk=None, task=None):
147157 logger .warning ("macro %s is missing" , stage .get (macro_type ))
148158 return
149159
150- await macro ["callback" ](doc , desk = desk , stage = stage , task = task )
160+ await macro ["callback" ](doc , desk = desk , stage = stage , task = task , ** ( macro_kwargs or {}) )
151161 if update :
152162 modified = compare_dictionaries (original_doc , doc )
153163 for i in modified :
0 commit comments