From b5eb5e19c37c0e41f52e356af10f5a256768ccf3 Mon Sep 17 00:00:00 2001 From: Naveen Albert Date: Mon, 30 Oct 2023 09:27:20 -0400 Subject: [PATCH] app_voicemail: Add AMI event for mailbox PIN changes. This adds an AMI event that is emitted whenever a mailbox password is successfully changed, allowing AMI consumers to process these. UserNote: The VoicemailPasswordChange event is now emitted whenever a mailbox password is updated, containing the mailbox information and the new password. Resolves: #398 (cherry picked from commit cf9d7fa9f6c696e56a208ff1fad0b6ba7fa32158) --- apps/app_voicemail.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 0e69973146..30982229bc 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -546,6 +546,22 @@ as the same as the from. + + + Raised in response to a mailbox password change. + + + Mailbox context. + + + Mailbox name. + + + New password for mailbox. + + + + ***/ #ifdef IMAP_STORAGE @@ -1849,6 +1865,16 @@ static int reset_user_pw(const char *context, const char *mailbox, const char *n res = 0; } AST_LIST_UNLOCK(&users); + if (!res) { + struct ast_json *json_object; + + json_object = ast_json_pack("{s: s, s: s, s: s}", + "Context", S_OR(context, "default"), + "Mailbox", mailbox, + "NewPassword", newpass); + ast_manager_publish_event("VoicemailPasswordChange", EVENT_FLAG_SYSTEM | EVENT_FLAG_USER, json_object); + ast_json_unref(json_object); + } return res; } @@ -1892,7 +1918,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); break; } else { - ast_verb(4, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn); + ast_log(LOG_WARNING, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn); } /* Fall-through */ case OPT_PWLOC_VOICEMAILCONF: