]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
push-notification: lua: Expose UTF8 from/to/subject
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Sun, 10 Nov 2019 12:16:49 +0000 (14:16 +0200)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 22 Nov 2019 10:35:55 +0000 (12:35 +0200)
Replace the existing "subject" field with UTF8 subject. Add new
from_address, from_display_name, to_address and to_display_name where
the *_display_names are UTF8.

src/plugins/push-notification/push-notification-driver-lua.c

index 68d2b1e4de0f9516b8e89b890a3c31512447c925..2946a86c496e8facc8c0b78b9979f7b714d99851 100644 (file)
@@ -339,6 +339,24 @@ push_notification_lua_push_mailboxrename(const struct push_notification_txn_even
        lua_setfield(script->L, -2, "mailbox_old");
 }
 
+static void
+push_notification_lua_push_message_ext(const struct push_notification_message_ext *ext,
+                                      struct dlua_script *script)
+{
+       lua_pushstring(script->L, ext->from_address);
+       lua_setfield(script->L, -2, "from_address");
+       lua_pushstring(script->L, ext->from_display_name_utf8);
+       lua_setfield(script->L, -2, "from_display_name");
+
+       lua_pushstring(script->L, ext->to_address);
+       lua_setfield(script->L, -2, "to_address");
+       lua_pushstring(script->L, ext->to_display_name_utf8);
+       lua_setfield(script->L, -2, "to_display_name");
+
+       lua_pushstring(script->L, ext->subject_utf8);
+       lua_setfield(script->L, -2, "subject");
+}
+
 static void
 push_notification_lua_push_messageappend(const struct push_notification_txn_event *event,
                                         struct dlua_script *script)
@@ -357,9 +375,6 @@ push_notification_lua_push_messageappend(const struct push_notification_txn_even
        lua_pushstring(script->L, data->to);
        lua_setfield(script->L, -2, "to");
 
-       lua_pushstring(script->L, data->subject);
-       lua_setfield(script->L, -2, "subject");
-
        lua_pushstring(script->L, data->snippet);
        lua_setfield(script->L, -2, "snippet");
 
@@ -371,6 +386,8 @@ push_notification_lua_push_messageappend(const struct push_notification_txn_even
 
        lua_pushstring(script->L, data->message_id);
        lua_setfield(script->L, -2, "message_id");
+
+       push_notification_lua_push_message_ext(&data->ext, script);
 }
 
 static void
@@ -391,9 +408,6 @@ push_notification_lua_push_messagenew(const struct push_notification_txn_event *
        lua_pushstring(script->L, data->to);
        lua_setfield(script->L, -2, "to");
 
-       lua_pushstring(script->L, data->subject);
-       lua_setfield(script->L, -2, "subject");
-
        lua_pushstring(script->L, data->snippet);
        lua_setfield(script->L, -2, "snippet");
 
@@ -405,6 +419,8 @@ push_notification_lua_push_messagenew(const struct push_notification_txn_event *
 
        lua_pushstring(script->L, data->message_id);
        lua_setfield(script->L, -2, "message_id");
+
+       push_notification_lua_push_message_ext(&data->ext, script);
 }
 
 /* events that need special treatment */