]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
voicemail: Fixed wrong voicemail message count
authorSungtae Kim <pchero21@gmail.com>
Wed, 7 Mar 2018 01:08:00 +0000 (02:08 +0100)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 7 Mar 2018 17:37:17 +0000 (11:37 -0600)
Fixed wrong voicemail mailbox reference for Action: VoicemailUsersList.

ASTERISK-27703

Change-Id: I99bfec14bd4ae475b0fa1fac5a7992f3e2e8d64a

apps/app_voicemail.c

index db6b75741b9ce9cca8cbbe65103aed59aacb7db1..485d03f27e4f0544acbfbf4ac61bffc5726f7c19 100644 (file)
@@ -13346,11 +13346,30 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
        astman_send_listack(s, m, "Voicemail user list will follow", "start");
 
        AST_LIST_TRAVERSE(&users, vmu, list) {
-               char dirname[256];
                int new, old;
-               inboxcount(vmu->mailbox, &new, &old);
+               int ret;
+               char *mailbox;
+
+               /* create mailbox string */
+               if (!ast_strlen_zero(vmu->context)) {
+                       ret = ast_asprintf(&mailbox, "%s@%s", vmu->mailbox, vmu->context);
+               } else {
+                       ret = ast_asprintf(&mailbox, "%s", vmu->mailbox);
+               }
+               if (ret == -1) {
+                       ast_log(LOG_ERROR, "Could not create mailbox string. err[%s]\n", strerror(errno));
+                       continue;
+               }
+
+               /* get mailbox count */
+               ret = inboxcount(mailbox, &new, &old);
+               ast_free(mailbox);
+               if (ret == -1) {
+                       ast_log(LOG_ERROR, "Could not get mailbox count. username[%s], context[%s]\n",
+                               vmu->mailbox ?: "", vmu->context ?: "");
+                       continue;
+               }
 
-               make_dir(dirname, sizeof(dirname), vmu->context, vmu->mailbox, "INBOX");
                astman_append(s,
                        "Event: VoicemailUserEntry\r\n"
                        "%s"