Skip to content

Commit

Permalink
fix: do not update account secret if not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Jan 10, 2025
1 parent 11b3054 commit eb543ae
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions mail/mail/doctype/mail_agent_job/mail_agent_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,25 +224,31 @@ def patch_account_on_agents(
if not primary_agents:
return

request_data = json.dumps(
[
{
"action": "set",
"field": "description",
"value": display_name,
},
{
"action": "addItem",
"field": "secrets",
"value": new_secret,
},
{
"action": "removeItem",
"field": "secrets",
"value": old_secret,
},
]
)
request_data = [
{
"action": "set",
"field": "description",
"value": display_name,
}
]

if old_secret != new_secret:
request_data.extend(
[
{
"action": "addItem",
"field": "secrets",
"value": new_secret,
},
{
"action": "removeItem",
"field": "secrets",
"value": old_secret,
},
]
)

request_data = json.dumps(request_data)
for agent in primary_agents:
create_mail_agent_job(
agent=agent, method="PATCH", endpoint=f"/api/principal/{email}", request_data=request_data
Expand Down

0 comments on commit eb543ae

Please sign in to comment.