Software /
code /
verse
Annotate
libs/xstanza.lua @ 482:4c4f3dd62c54
squishy: Comment legacy protocol plugins by default
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 17 Mar 2023 12:31:28 +0000 |
parent | 15:be4154ed4e3a |
rev | line source |
---|---|
6
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local stanza_mt = getmetatable(require "util.stanza".stanza()); |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 |
15
be4154ed4e3a
util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents:
6
diff
changeset
|
3 local xmlns_stanzas = "urn:ietf:params:xml:ns:xmpp-stanzas"; |
be4154ed4e3a
util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents:
6
diff
changeset
|
4 |
be4154ed4e3a
util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents:
6
diff
changeset
|
5 function stanza_mt:get_error() |
6
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 local type, condition, text; |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
15
be4154ed4e3a
util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents:
6
diff
changeset
|
8 local error_tag = self:get_child("error"); |
6
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 if not error_tag then |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 return nil, nil; |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 end |
15
be4154ed4e3a
util.xstanza: Fix and rename error_from_stanza() -> get_error()
Matthew Wild <mwild1@gmail.com>
parents:
6
diff
changeset
|
12 type = error_tag.attr.type; |
6
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 for child in error_tag:children() do |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 if child.attr.xmlns == xmlns_stanzas then |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 if child.name == "text" then |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 text = child:get_text(); |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 else |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 condition = child.name; |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 end |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 if condition and text then |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 break; |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 end |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 end |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 end |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 return type, condition, text; |
f8e0ab90d84e
util.xstanza: New library to extend util.stanza with XMPP-specific helpers
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 end |