diff mod_reminders/mod_reminders.lua @ 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 3e19c25ff93e
children
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;