Skip to content

Commit d678370

Browse files
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
1 parent 6c61370 commit d678370

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

apps/app_voicemail.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,22 @@
546546
as the same as the from.</para>
547547
</description>
548548
</manager>
549+
<managerEvent language="en_US" name="VoicemailPasswordChange">
550+
<managerEventInstance class="EVENT_FLAG_USER">
551+
<synopsis>Raised in response to a mailbox password change.</synopsis>
552+
<syntax>
553+
<parameter name="Context">
554+
<para>Mailbox context.</para>
555+
</parameter>
556+
<parameter name="Mailbox">
557+
<para>Mailbox name.</para>
558+
</parameter>
559+
<parameter name="NewPassword">
560+
<para>New password for mailbox.</para>
561+
</parameter>
562+
</syntax>
563+
</managerEventInstance>
564+
</managerEvent>
549565
***/
550566

551567
#ifdef IMAP_STORAGE
@@ -1849,6 +1865,16 @@ static int reset_user_pw(const char *context, const char *mailbox, const char *n
18491865
res = 0;
18501866
}
18511867
AST_LIST_UNLOCK(&users);
1868+
if (!res) {
1869+
struct ast_json *json_object;
1870+
1871+
json_object = ast_json_pack("{s: s, s: s, s: s}",
1872+
"Context", S_OR(context, "default"),
1873+
"Mailbox", mailbox,
1874+
"NewPassword", newpass);
1875+
ast_manager_publish_event("VoicemailPasswordChange", EVENT_FLAG_SYSTEM | EVENT_FLAG_USER, json_object);
1876+
ast_json_unref(json_object);
1877+
}
18521878
return res;
18531879
}
18541880

@@ -1892,7 +1918,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
18921918
ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
18931919
break;
18941920
} else {
1895-
ast_verb(4, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn);
1921+
ast_log(LOG_WARNING, "Writing voicemail password to file %s failed, falling back to config file\n", secretfn);
18961922
}
18971923
/* Fall-through */
18981924
case OPT_PWLOC_VOICEMAILCONF:

0 commit comments

Comments
 (0)