aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-15 20:08:52 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-15 20:08:52 +0000
commit47212b1162abf9d1ca498e4f241b6134c135ac43 (patch)
treece1b406e7c14f85ce28700557ebf0b27976b4532 /apps
parenta4bec415a39991d9e352016d4d340f449661b659 (diff)
Ensure mailbox is not filled to capacity before doing message forwarding.
Specifically, before prompting to record a prepended message the capacity is checked first. If the mailbox is full the extension will be reprompted. ABE-2517 git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@286941 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index ead08664e..ebbedb1fb 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -5288,7 +5288,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
AST_LIST_HEAD_NOLOCK_STATIC(extensions, ast_vm_user);
char *stringp;
const char *s;
- int saved_messages = 0, found = 0;
+ int saved_messages = 0;
int valid_extensions = 0;
char *dir;
int curmsg;
@@ -5391,10 +5391,33 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
while (s) {
/* Don't forward to ourselves but allow leaving a message for ourselves (flag == 1). find_user is going to malloc since we have a NULL as first argument */
if ((flag == 1 || strcmp(s,sender->mailbox)) && (receiver = find_user(NULL, context, s))) {
+ int oldmsgs;
+ int newmsgs;
+ int capacity;
+ if (inboxcount(s, &newmsgs, &oldmsgs)) {
+ ast_log(LOG_ERROR, "Problem in calculating number of voicemail messages available for extension %s\n", s);
+ /* Shouldn't happen, but allow trying another extension if it does */
+ res = ast_play_and_wait(chan, "pbx-invalid");
+ valid_extensions = 0;
+ break;
+ }
+ capacity = receiver->maxmsg - inprocess_count(receiver->mailbox, receiver->context, +1);
+ if ((newmsgs + oldmsgs) >= capacity) {
+ ast_log(LOG_NOTICE, "Mailbox '%s' is full with capacity of %d, prompting for another extension.\n", s, capacity);
+ res = ast_play_and_wait(chan, "vm-mailboxfull");
+ valid_extensions = 0;
+ while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) {
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
+ free_user(vmtmp);
+ }
+ inprocess_count(receiver->mailbox, receiver->context, -1);
+ break;
+ }
AST_LIST_INSERT_HEAD(&extensions, receiver, list);
- found++;
} else {
ast_log(LOG_NOTICE, "'%s' is not a valid mailbox\n", s);
+ /* "I am sorry, that's not a valid extension. Please try again." */
+ res = ast_play_and_wait(chan, "pbx-invalid");
valid_extensions = 0;
break;
}
@@ -5403,8 +5426,6 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
/* break from the loop of reading the extensions */
if (valid_extensions)
break;
- /* "I am sorry, that's not a valid extension. Please try again." */
- res = ast_play_and_wait(chan, "pbx-invalid");
}
/* check if we're clear to proceed */
if (AST_LIST_EMPTY(&extensions) || !valid_extensions)
@@ -5467,6 +5488,7 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
copy_msg_result = copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt, dir);
#endif
saved_messages++;
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
AST_LIST_REMOVE_CURRENT(&extensions, list);
free_user(vmtmp);
if (res)
@@ -5507,8 +5529,10 @@ static int forward_message(struct ast_channel *chan, char *context, struct vm_st
}
/* If anything failed above, we still have this list to free */
- while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list)))
+ while ((vmtmp = AST_LIST_REMOVE_HEAD(&extensions, list))) {
+ inprocess_count(vmtmp->mailbox, vmtmp->context, -1);
free_user(vmtmp);
+ }
return res ? res : cmd;
}