Annotate

plugins/browsing.lua @ 478:cf6626a12e0e

Add dummy util.net
author Matthew Wild <mwild1@gmail.com>
date Fri, 17 Mar 2023 12:28:13 +0000
parent 466:1eaec52ff71a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
403
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
1 local verse = require "verse";
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
2
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
3 local xmlns_browsing = "urn:xmpp:browsing:0";
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
4
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
5 function verse.plugins.browsing(stream)
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
6 stream:add_plugin("pep");
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
7 function stream:browsing(infos, callback)
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
8 if type(infos) == "string" then
466
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
9 infos = {uri = infos};
403
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
10 end
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
11
466
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
12 local link = verse.stanza("page", {xmlns = xmlns_browsing})
403
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
13 for info, value in pairs(infos) do
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
14 link:tag(info):text(value):up();
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
15 end
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
16 return stream:publish_pep(link, callback);
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
17 end
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
18
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
19 stream:hook_pep(xmlns_browsing, function(event)
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
20 local item = event.item;
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
21 return stream:event("browsing", {
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
22 from = event.from;
466
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
23 description = item:get_child_text "description";
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
24 keywords = item:get_child_text "keywords";
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
25 title = item:get_child_text "title";
1eaec52ff71a browsing: whitespace fixes
Matthew Wild <mwild1@gmail.com>
parents: 403
diff changeset
26 uri = item:get_child_text "uri";
403
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
27 });
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
28 end);
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
29 end
6f4f60ebb796 Add plugin for XEP-0195: User Browsing
Kim Alvefur <zash@zash.se>
parents:
diff changeset
30