I promise to get better at Lua and Prosody - currently I am a noob and ask 
a lot of stupid questions. Here's my question:

I am trying to add vCard support to mod_offline_email. Zash kindly 
suggested:

local vcards = module:open_store("vcard");
>  -- in a hook 
> local vcard = vcards:get(username); 

 

> local email = vcards:get_child_text("EMAIL"); 


Here is the modified 
code: https://gist.github.com/metalaureate/5971162ff3017e8fd3f2

My vCards look like this:

[{"name":"EMAIL","attr":{"xmlns":"vcard-temp"},"__array":[{"attr":{"xmlns":"vcard-temp"},"name":"USERID","__array":["si...@domain.net"]},{"name":"PREF","attr":{"xmlns":"vcard-temp"}}]}]

I get the error:


[xmpp-1] 2015-03-20T00:53:13.198613705Z mod_bosh                            
      *error* Traceback[bosh]: 
...sody-modules/mod_offline_email/mod_offline_email.lua:24: attempt to call 
method 'get_child_text' (a nil value)
[xmpp-1] 2015-03-20T00:53:13.198613705Z stack traceback:
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
...sody-modules/mod_offline_email/mod_offline_email.lua:24: 
in function '?'
[xmpp-1] 2015-03-20T00:53:13.198613705Z /usr/lib/prosody/util/events.lua:67: 
in function </usr/lib/prosody/util/events.lua:63>
[xmpp-1] 2015-03-20T00:53:13.198613705Z (tail call): ?
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/modules/mod_message.lua:53: 
in function </usr/lib/prosody/modules/mod_message.lua:18>
[xmpp-1] 2015-03-20T00:53:13.198613705Z (tail call): ?
[xmpp-1] 2015-03-20T00:53:13.198613705Z /usr/lib/prosody/util/events.lua:67: 
in function 'fire_event'
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/core/stanza_router.lua:187: 
in function 'core_post_stanza'
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/core/stanza_router.lua:135: 
in function </usr/lib/prosody/core/stanza_router.lua:56>
[xmpp-1] 2015-03-20T00:53:13.198613705Z (tail call): ?
[xmpp-1] 2015-03-20T00:53:13.198613705Z [C]: in function 'xpcall'
[xmpp-1] 2015-03-20T00:53:13.198613705Z ...
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/net/http/server.lua:108: 
in function 'process_next'
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/net/http/server.lua:124: 
in function 'success_cb'
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/net/http/parser.lua:154: 
in function 'feed'
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/net/http/server.lua:150: 
in function </usr/lib/prosody/net/http/server.lua:149>
[xmpp-1] 2015-03-20T00:53:13.198613705Z (tail call): ?
[xmpp-1] 2015-03-20T00:53:13.198613705Z 
/usr/lib/prosody/net/server_select.lua:861: 
in function </usr/lib/prosody/net/server_select.lua:843>
[xmpp-1] 2015-03-20T00:53:13.198613705Z [C]: in function 'xpcall'
[xmpp-1] 2015-03-20T00:53:13.198613705Z /usr/lib/prosody/../../bin/prosody:373: 
in function 'loop'
[xmpp-1] 2015-03-20T00:53:13.198613705Z /usr/lib/prosody/../../bin/prosody:404: 
in main chunk


What am I doing wrong? I don't fully understand the syntax accessing the 
vcard object, so it is hard to troubleshoot. Javascript and node.js is more 
my area hitherto.

Thanks!

Simon

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To post to this group, send email to prosody-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to