changeset 3921:9eabd68b8e48

mod_reminders: add id to sent reminder Update the acknowledgement of reminder's creation with ProtoXEP comments.
author marc0s <marcos@tenak.net>
date Fri, 28 Feb 2020 16:22:37 +0100
parents cf92e3b30c18
children ea59c9455f93
files mod_reminders/mod_reminders.lua
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mod_reminders/mod_reminders.lua	Thu Feb 27 23:17:31 2020 +0100
+++ b/mod_reminders/mod_reminders.lua	Fri Feb 28 16:22:37 2020 +0100
@@ -64,7 +64,7 @@
 	local bare = jid.bare(reminder.jid);
 	module:log("debug", "Sending reminder %s to %s", reminder.id, bare);
 	local message = st.message({ from = "localhost"; to = bare; id = id.short() })
-		:tag("reminder", {xmlns = xmlns_reminders})
+		:tag("reminder", {id = reminder.id; xmlns = xmlns_reminders})
 		:add_child(reminder.text)
 		:tag("date"):text(datetime.datetime(reminder.date)):up();
 	module:send(message);
@@ -110,7 +110,6 @@
 end
 
 local function create_reminder (jid, reminder)
-	local rem = st.clone(reminder);
 	local date = reminder:get_child("date");
 	local text = reminder:get_child("text");
 	if date == nil or text == nil then
@@ -123,10 +122,11 @@
 	end
 	if parsed_date < now then
 		return nil, reminder_error("past_date"), nil
-	end	
-	rem.attr.id = id.medium();
+	end
+	local reminder_id = id.medium();
+	local rem = st.stanza("reminder", {xmlns = xmlns_reminders; id = reminder_id});
 	local data = {
-		id = rem.attr.id;
+		id = reminder_id;
 		jid = jid;
 		text = text;
 		date = parsed_date;