plugins/mod_bookmarks.lua
changeset 12182 0aa99a6dfb3e
parent 12181 024cc878f472
child 12263 57792ed670e7
equal deleted inserted replaced
12181:024cc878f472 12182:0aa99a6dfb3e
    39 local function generate_legacy_storage(items)
    39 local function generate_legacy_storage(items)
    40 	local storage = st.stanza("storage", { xmlns = namespace_legacy });
    40 	local storage = st.stanza("storage", { xmlns = namespace_legacy });
    41 	for _, item_id in ipairs(items) do
    41 	for _, item_id in ipairs(items) do
    42 		local item = items[item_id];
    42 		local item = items[item_id];
    43 		local bookmark = item:get_child("conference", namespace);
    43 		local bookmark = item:get_child("conference", namespace);
       
    44 		if not bookmark then
       
    45 			module:log("warn", "Invalid bookmark published: expected {%s}conference, got {%s}%s", namespace,
       
    46 
       
    47 				item.tags[1] and item.tags[1].attr.xmlns, item.tags[1] and item.tags[1].name);
       
    48 		end
    44 		local conference = st.stanza("conference", {
    49 		local conference = st.stanza("conference", {
    45 			jid = item.attr.id,
    50 			jid = item.attr.id,
    46 			name = bookmark.attr.name,
    51 			name = bookmark and bookmark.attr.name,
    47 			autojoin = bookmark.attr.autojoin,
    52 			autojoin = bookmark and bookmark.attr.autojoin,
    48 		});
    53 		});
    49 		local nick = bookmark:get_child_text("nick");
    54 		local nick = bookmark and bookmark:get_child_text("nick");
    50 		if nick ~= nil then
    55 		if nick ~= nil then
    51 			conference:text_tag("nick", nick):up();
    56 			conference:text_tag("nick", nick):up();
    52 		end
    57 		end
    53 		local password = bookmark:get_child_text("password");
    58 		local password = bookmark and bookmark:get_child_text("password");
    54 		if password ~= nil then
    59 		if password ~= nil then
    55 			conference:text_tag("password", password):up();
    60 			conference:text_tag("password", password):up();
    56 		end
    61 		end
    57 		storage:add_child(conference);
    62 		storage:add_child(conference);
    58 	end
    63 	end