Software / code / prosody
Comparison
plugins/mod_privacy.lua @ 2499:145d62abdbfc
mod_privacy: Reduced a function.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Tue, 26 Jan 2010 01:49:45 +0500 |
| parent | 2498:3d08a6cf57ea |
| child | 2500:bffdaeb7ab5e |
comparison
equal
deleted
inserted
replaced
| 2498:3d08a6cf57ea | 2499:145d62abdbfc |
|---|---|
| 180 table.remove(privacy_lists.lists, idx); | 180 table.remove(privacy_lists.lists, idx); |
| 181 origin.send(st.reply(stanza)); | 181 origin.send(st.reply(stanza)); |
| 182 return true; | 182 return true; |
| 183 end | 183 end |
| 184 return {"modify", "bad-request", "Not existing list specifed to be deleted."}; | 184 return {"modify", "bad-request", "Not existing list specifed to be deleted."}; |
| 185 end | |
| 186 | |
| 187 local function sortByOrder(a, b) | |
| 188 if a.order < b.order then | |
| 189 return true; | |
| 190 end | |
| 191 return false; | |
| 192 end | 185 end |
| 193 | 186 |
| 194 function createOrReplaceList (privacy_lists, origin, stanza, name, entries, roster) | 187 function createOrReplaceList (privacy_lists, origin, stanza, name, entries, roster) |
| 195 local idx = findNamedList(privacy_lists, name); | 188 local idx = findNamedList(privacy_lists, name); |
| 196 local bare_jid = origin.username.."@"..origin.host; | 189 local bare_jid = origin.username.."@"..origin.host; |
| 275 end | 268 end |
| 276 ]]-- | 269 ]]-- |
| 277 list.items[#list.items + 1] = tmp; | 270 list.items[#list.items + 1] = tmp; |
| 278 end | 271 end |
| 279 | 272 |
| 280 table.sort(list, sortByOrder); | 273 table.sort(list, function(a, b) return a.order < b.order; end); |
| 281 | 274 |
| 282 privacy_lists.lists[idx] = list; | 275 privacy_lists.lists[idx] = list; |
| 283 origin.send(st.reply(stanza)); | 276 origin.send(st.reply(stanza)); |
| 284 if bare_sessions[bare_jid] ~= nil then | 277 if bare_sessions[bare_jid] ~= nil then |
| 285 local iq = st.iq ( { type = "set", id="push1" } ); | 278 local iq = st.iq ( { type = "set", id="push1" } ); |