Mercurial > prosody-hg
comparison plugins/muc/util.lib.lua @ 6609:d2faaaca695d
Merge 0.10->trunk
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Fri, 27 Mar 2015 22:24:57 +0000 |
| parents | 006b0e0f0de2 |
| children | 5a2135964ed3 |
comparison
equal
deleted
inserted
replaced
| 6608:b6e558febb7a | 6609:d2faaaca695d |
|---|---|
| 1 -- Prosody IM | |
| 2 -- Copyright (C) 2008-2010 Matthew Wild | |
| 3 -- Copyright (C) 2008-2010 Waqas Hussain | |
| 4 -- Copyright (C) 2014 Daurnimator | |
| 5 -- | |
| 6 -- This project is MIT/X11 licensed. Please see the | |
| 7 -- COPYING file in the source package for more information. | |
| 8 -- | |
| 9 | |
| 10 local _M = {}; | |
| 11 | |
| 12 _M.valid_affiliations = { | |
| 13 outcast = -1; | |
| 14 none = 0; | |
| 15 member = 1; | |
| 16 admin = 2; | |
| 17 owner = 3; | |
| 18 }; | |
| 19 | |
| 20 _M.valid_roles = { | |
| 21 none = 0; | |
| 22 visitor = 1; | |
| 23 participant = 2; | |
| 24 moderator = 3; | |
| 25 }; | |
| 26 | |
| 27 local kickable_error_conditions = { | |
| 28 ["gone"] = true; | |
| 29 ["internal-server-error"] = true; | |
| 30 ["item-not-found"] = true; | |
| 31 ["jid-malformed"] = true; | |
| 32 ["recipient-unavailable"] = true; | |
| 33 ["redirect"] = true; | |
| 34 ["remote-server-not-found"] = true; | |
| 35 ["remote-server-timeout"] = true; | |
| 36 ["service-unavailable"] = true; | |
| 37 ["malformed error"] = true; | |
| 38 }; | |
| 39 function _M.is_kickable_error(stanza) | |
| 40 local cond = select(2, stanza:get_error()) or "malformed error"; | |
| 41 return kickable_error_conditions[cond]; | |
| 42 end | |
| 43 | |
| 44 local muc_x_filters = { | |
| 45 ["http://jabber.org/protocol/muc"] = true; | |
| 46 ["http://jabber.org/protocol/muc#user"] = true; | |
| 47 } | |
| 48 local function muc_x_filter(tag) | |
| 49 if muc_x_filters[tag.attr.xmlns] then | |
| 50 return nil; | |
| 51 end | |
| 52 return tag; | |
| 53 end | |
| 54 function _M.filter_muc_x(stanza) | |
| 55 return stanza:maptags(muc_x_filter); | |
| 56 end | |
| 57 | |
| 58 return _M; |
