Mercurial > prosody-modules
comparison mod_group_bookmarks/mod_group_bookmarks.lua @ 3266:ebd78514bbec
mod_group_bookmarks: Remove unused requires.
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Fri, 24 Aug 2018 19:51:31 +0200 |
| parents | 0ccdd3f31435 |
| children |
comparison
equal
deleted
inserted
replaced
| 3265:d4207ab8ccc1 | 3266:ebd78514bbec |
|---|---|
| 5 -- | 5 -- |
| 6 -- This project is MIT/X11 licensed. Please see the | 6 -- This project is MIT/X11 licensed. Please see the |
| 7 -- COPYING file in the source package for more information. | 7 -- COPYING file in the source package for more information. |
| 8 -- | 8 -- |
| 9 | 9 |
| 10 | |
| 11 local st = require "util.stanza" | 10 local st = require "util.stanza" |
| 12 local dm_load = require "util.datamanager".load | 11 local dm_load = require "util.datamanager".load |
| 13 | 12 local jid_prep = require "util.jid".prep; |
| 14 local jid = require "util.jid"; | |
| 15 local jid_bare, jid_prep, jid_split = jid.bare, jid.prep, jid.split; | |
| 16 | |
| 17 local module_host = module:get_host(); | |
| 18 | 13 |
| 19 local rooms; | 14 local rooms; |
| 20 local members; | 15 local members; |
| 21 | 16 |
| 22 local bookmarks_file; | 17 local bookmarks_file; |
| 23 | 18 |
| 24 module:add_feature("jabber:iq:private"); | 19 module:add_feature("jabber:iq:private"); |
| 25 | 20 |
| 26 function inject_bookmarks(username, host, data) | 21 local function inject_bookmarks(username, host, data) |
| 27 local jid = username.."@"..host; | 22 local jid = username.."@"..host; |
| 28 data:reset(); | 23 data:reset(); |
| 29 if members[jid] then | 24 if members[jid] then |
| 30 for _, room in ipairs(members[jid]) do | 25 for _, room in ipairs(members[jid]) do |
| 31 data:tag("conference", { | 26 data:tag("conference", { |
| 95 rooms[curr_room] = rooms[curr_room] or {}; | 90 rooms[curr_room] = rooms[curr_room] or {}; |
| 96 elseif curr_room then | 91 elseif curr_room then |
| 97 -- Add JID | 92 -- Add JID |
| 98 local entryjid, name = line:match("([^=]*)=?(.*)"); | 93 local entryjid, name = line:match("([^=]*)=?(.*)"); |
| 99 module:log("debug", "entryjid = '%s', name = '%s'", entryjid, name); | 94 module:log("debug", "entryjid = '%s', name = '%s'", entryjid, name); |
| 100 local jid; | 95 local jid = jid_prep(entryjid:match("%S+")); |
| 101 jid = jid_prep(entryjid:match("%S+")); | |
| 102 if jid then | 96 if jid then |
| 103 module:log("debug", "New member of %s: %s", tostring(curr_room), tostring(jid)); | 97 module:log("debug", "New member of %s: %s", tostring(curr_room), tostring(jid)); |
| 104 rooms[curr_room][jid] = name or false; | 98 rooms[curr_room][jid] = name or false; |
| 105 members[jid] = members[jid] or {}; | 99 members[jid] = members[jid] or {}; |
| 106 members[jid][#members[jid]+1] = curr_room; | 100 members[jid][#members[jid]+1] = curr_room; |
| 107 end | 101 end |
| 108 end | 102 end |
| 109 end | 103 end |
| 110 module:log("info", "Group bookmarks loaded successfully"); | 104 module:log("info", "Group bookmarks loaded successfully"); |
| 111 end | 105 end |
| 112 |
