You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.2 KiB
79 lines
3.2 KiB
From: Sipwise Development Team <support@sipwise.com>
|
|
Date: Mon, 4 Nov 2024 15:37:29 +0100
|
|
Subject: sipwise_vm_ast_load_realtime_use_uuid
|
|
|
|
---
|
|
apps/app_voicemail.c | 23 ++++++++++++++++++-----
|
|
1 file changed, 18 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
|
|
index d2ed8d6..fffbad9 100644
|
|
--- a/apps/app_voicemail.c
|
|
+++ b/apps/app_voicemail.c
|
|
@@ -1858,7 +1858,7 @@ static int is_valid_dtmf(const char *key)
|
|
*
|
|
* \return The ast_vm_user structure for the user that was found.
|
|
*/
|
|
-static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *mailbox)
|
|
+static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *mailbox, int by_uuid)
|
|
{
|
|
struct ast_variable *var;
|
|
struct ast_vm_user *retval;
|
|
@@ -1875,9 +1875,15 @@ static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const cha
|
|
ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
|
|
}
|
|
if (!context && ast_test_flag((&globalflags), VM_SEARCH)) {
|
|
- var = ast_load_realtime("voicemail", "mailbox", mailbox, SENTINEL);
|
|
+ if (by_uuid)
|
|
+ var = ast_load_realtime("voicemail", "customer_id", mailbox, SENTINEL);
|
|
+ else
|
|
+ var = ast_load_realtime("voicemail", "mailbox", mailbox, SENTINEL);
|
|
} else {
|
|
- var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, SENTINEL);
|
|
+ if (by_uuid)
|
|
+ var = ast_load_realtime("voicemail", "customer_id", mailbox, "context", context, SENTINEL);
|
|
+ else
|
|
+ var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, SENTINEL);
|
|
}
|
|
if (var) {
|
|
// ast_log (LOG_DEBUG,"call apply_options_full\n");
|
|
@@ -1941,7 +1947,7 @@ static struct ast_vm_user *find_user(struct ast_vm_user *ivm, const char *contex
|
|
#ifdef ODBC_STORAGE
|
|
vmu = find_user_realtime_by_alias(ivm, context, mailbox);
|
|
#else
|
|
- vmu = find_user_realtime(ivm, context, mailbox);
|
|
+ vmu = find_user_realtime(ivm, context, mailbox, 0);
|
|
#endif
|
|
}
|
|
if (!vmu && !ast_strlen_zero(aliasescontext)) {
|
|
@@ -4237,6 +4243,7 @@ static struct ast_vm_user *find_user_realtime_by_alias(struct ast_vm_user *ivm,
|
|
"where customer_id = ?";
|
|
struct generic_prepare_struct gps_uuid = { .sql = sql_uuid, .argc = 1, .argv = argv };
|
|
struct odbc_obj *obj = NULL;
|
|
+ int by_uuid = 1;
|
|
SQLHSTMT stmt = NULL;
|
|
|
|
obj = ast_odbc_request_obj(odbc_database, 0);
|
|
@@ -4251,6 +4258,8 @@ static struct ast_vm_user *find_user_realtime_by_alias(struct ast_vm_user *ivm,
|
|
ast_log(LOG_NOTICE, "Failed to fetch mailbox for uuid '%s', falling back to alias search\n", alias);
|
|
SQLFreeHandle (SQL_HANDLE_STMT, stmt);
|
|
|
|
+ by_uuid = 0;
|
|
+
|
|
stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, &gps);
|
|
if (!stmt) {
|
|
ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
|
|
@@ -4277,7 +4286,11 @@ static struct ast_vm_user *find_user_realtime_by_alias(struct ast_vm_user *ivm,
|
|
ast_odbc_release_obj(obj);
|
|
|
|
ast_log(LOG_NOTICE, "Found mailbox '%s' for alias '%s'\n", mailbox, alias);
|
|
- return find_user_realtime(ivm, context, mailbox);
|
|
+
|
|
+ if (by_uuid)
|
|
+ return find_user_realtime(ivm, context, alias, by_uuid);
|
|
+
|
|
+ return find_user_realtime(ivm, context, mailbox, by_uuid);
|
|
}
|
|
#endif
|
|
|