Software /
code /
prosody
Comparison
core/offlinemanager.lua @ 249:1fc47cf5d144
Added basic offline message support
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Thu, 13 Nov 2008 12:13:13 +0500 |
child | 267:6303b7454ad0 |
comparison
equal
deleted
inserted
replaced
248:8ce9559d501a | 249:1fc47cf5d144 |
---|---|
1 | |
2 local datamanager = require "util.datamanager"; | |
3 local st = require "util.stanza"; | |
4 local datetime = require "util.datetime"; | |
5 local ipairs = ipairs; | |
6 | |
7 module "offlinemanager" | |
8 | |
9 function store(node, host, stanza) | |
10 stanza.attr.stamp = datetime.datetime(); | |
11 stanza.attr.stamp_legacy = datetime.legacy(); | |
12 return datamanager.list_append(node, host, "offline", st.preserialize(stanza)); | |
13 end | |
14 | |
15 function load(node, host) | |
16 local data = datamanager.list_load(node, host, "offline"); | |
17 if not data then return; end | |
18 for k, v in ipairs(data) do | |
19 stanza = st.deserialize(v); | |
20 stanza:tag("delay", {xmlns = "urn:xmpp:delay", from = host, stamp = stanza.attr.stamp}):up(); -- XEP-0203 | |
21 stanza:tag("x", {xmlns = "jabber:x:delay", from = host, stamp = stanza.attr.stamp_legacy}):up(); -- XEP-0091 (deprecated) | |
22 stanza.attr.stamp, stanza.attr.stamp_legacy = nil, nil; | |
23 data[k] = stanza; | |
24 end | |
25 return data; | |
26 end | |
27 | |
28 function deleteAll(node, host) | |
29 return datamanager.list_store(node, host, "offline", nil); | |
30 end | |
31 | |
32 return _M; |