Skip to content

Commit

Permalink
ASK-928 tuning Zendesk.UserRoleChanged (#1421)
Browse files Browse the repository at this point in the history
Co-authored-by: ben-githubs <[email protected]>
  • Loading branch information
akozlovets098 and ben-githubs authored Nov 12, 2024
1 parent 6224265 commit 4a79a46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rules/zendesk_rules/zendesk_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
def rule(event):
if event.get("source_type") == "user" and event.get("action") == "update":
# admin roles have their own handling
if event.udm("event_type") != event_type.ADMIN_ROLE_ASSIGNED:
if (
event.udm("event_type") != event_type.ADMIN_ROLE_ASSIGNED
and "role changed" in event.get("change_description", "").lower()
):
_, new_role = zendesk_get_roles(event)
return bool(new_role)
return False
Expand Down
18 changes: 18 additions & 0 deletions rules/zendesk_rules/zendesk_user_role.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,21 @@ Tests:
"created_at": "2021-05-28T18:39:50Z",
"p_log_type": "Zendesk.Audit",
}
- Name: Zendesk - No changing roles
ExpectedResult: false
Log:
{
"url": "https://myzendek.zendesk.com/api/v2/audit_logs/111222333444.json",
"id": 123456789123,
"action_label": "Updated",
"actor_id": 123,
"actor_name": "John Doe",
"source_id": 123,
"source_type": "user",
"source_label": "Bob Cat",
"action": "update",
"change_description": "Organization: AAAA is asigned",
"ip_address": "127.0.0.1",
"created_at": "2021-05-28T18:39:50Z",
"p_log_type": "Zendesk.Audit",
}

0 comments on commit 4a79a46

Please sign in to comment.