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.
asterisk-voicemail/debian/patches/sipwise_vm_zonemessages.patch

81 lines
3.3 KiB

From: Sipwise Development Team <support@sipwise.com>
Date: Mon, 21 Feb 2022 14:17:23 +0100
Subject: sipwise_vm_zonemessages
---
apps/app_voicemail.c | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index e3182eb..0d63f1e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -8646,7 +8646,7 @@ static int play_message_category(struct ast_channel *chan, const char *category)
static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *vmu, const char *origtime, const char *filename)
{
int res = 0;
- struct vm_zone *the_zone = NULL;
+ struct vm_zone the_zone = { NULL, "", "", "" };
time_t t;
if (ast_get_time_t(origtime, &t, 0, NULL)) {
@@ -8661,13 +8661,20 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
AST_LIST_LOCK(&zones);
AST_LIST_TRAVERSE(&zones, z, list) {
if (!strcmp(z->name, vmu->zonetag)) {
- the_zone = z;
+ the_zone = *z;
break;
}
}
AST_LIST_UNLOCK(&zones);
}
+ /* if no timezone is defined in voicemail.conf
+ try to use vmu->zonetag ("tz") as a valid timezone
+ NOTE: it uses GMT as fallback
+ */
+ if (ast_strlen_zero(the_zone.timezone))
+ ast_copy_string(the_zone.timezone, vmu->zonetag, sizeof(the_zone.timezone));
+
/* No internal variable parsing for now, so we'll comment it out for the time being */
#if 0
/* Set the DIFF_* variables */
@@ -8684,8 +8691,8 @@ static int play_message_datetime(struct ast_channel *chan, struct ast_vm_user *v
/* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */
#endif
- if (the_zone) {
- res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, ast_channel_language(chan), the_zone->msg_format, the_zone->timezone);
+ if (!ast_strlen_zero(the_zone.timezone)) {
+ res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, ast_channel_language(chan), the_zone.msg_format, the_zone.timezone);
} else if (!strncasecmp(ast_channel_language(chan), "de", 2)) { /* GERMAN syntax */
res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, ast_channel_language(chan), "'vm-received' Q 'digits/at' HM", NULL);
} else if (!strncasecmp(ast_channel_language(chan), "gr", 2)) { /* GREEK syntax */
@@ -14385,17 +14392,14 @@ static void load_zonemessages(struct ast_config *cfg)
strcpy(storage, var->value); /* safe */
msg_format = storage;
tzone = strsep(&msg_format, "|,");
- if (msg_format) {
- ast_copy_string(z->name, var->name, sizeof(z->name));
- ast_copy_string(z->timezone, tzone, sizeof(z->timezone));
- ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
- AST_LIST_LOCK(&zones);
- AST_LIST_INSERT_HEAD(&zones, z, list);
- AST_LIST_UNLOCK(&zones);
- } else {
- ast_log(AST_LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
- ast_free(z);
- }
+ if (msg_format == NULL)
+ msg_format = "";
+ ast_copy_string(z->name, var->name, sizeof(z->name));
+ ast_copy_string(z->timezone, tzone, sizeof(z->timezone));
+ ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
+ AST_LIST_LOCK(&zones);
+ AST_LIST_INSERT_HEAD(&zones, z, list);
+ AST_LIST_UNLOCK(&zones);
}
var = var->next;
}