Mercurial > libervia-pubsub
view db/sat_pubsub_update_0_1.sql @ 338:6d059f07c2d3
privilege: added presence and +notify initial support:
presence privilege is now used and capabilities are cached. When an entity is connected, last items are sent according to +notify nodes in disco.
This is initial support, XEP-0356 doesn't allow yet to get roster updated, or synchronises contacts on startup.
Only "open" access model is supported for now. "presence" should be added soon as it is trivial to support now.
Only last items sending is handled for now, notifications support for new items/deletions should follow.
Capabilities hash is not checked yet, with the security concerns that this imply. Check should be added in the future.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 12 Aug 2017 18:29:32 +0200 |
parents | 3c2705199108 |
children | 4d4575911060 |
line wrap: on
line source
ALTER TABLE nodes ADD COLUMN pep text; ALTER TABLE nodes DROP CONSTRAINT nodes_node_key; /* we need 2 partial indexes to manage NULL value for PEP */ CREATE UNIQUE INDEX nodes_node_pep_key_not_null ON nodes(node, pep) WHERE pep IS NOT NULL; CREATE UNIQUE INDEX nodes_node_pep_key_null ON nodes(node) WHERE pep IS NULL; CREATE TABLE metadata ( key text PRIMARY KEY, value text ); INSERT INTO metadata VALUES ('version', '1'); CREATE TABLE item_categories ( item_categories_id serial PRIMARY KEY, item_id integer NOT NULL references items ON DELETE CASCADE, category text NOT NULL, UNIQUE (item_id,category) ); UPDATE nodes SET node='urn:xmpp:microblog:0', pep=substring(node from 20) WHERE node LIKE 'urn:xmpp:groupblog:_%'; /* This is to update namespaces, SàT was bugguy before 0.6 and didn't set the atom namespace in <entry/> */ /* But yeah, this is a crazy query */ UPDATE items SET data = xmlelement(name item, xmlattributes((xpath('/item/@id', data::xml))[1] as id), XMLPARSE(CONTENT NULLIF(array_to_string(xpath('/item/entry/preceding-sibling::*', data::xml)::text[],''),'')), xmlelement(name entry, xmlattributes('http://www.w3.org/2005/Atom' as xmlns), array_to_string(xpath('/item/entry/*', data::xml)::text[], '')::xml), XMLPARSE(CONTENT NULLIF(array_to_string(xpath('/item/entry/following-sibling::*', data::xml)::text[],''),''))) FROM nodes WHERE nodes.node_id = items.node_id AND (node = 'urn:xmpp:microblog:0' or node LIKE 'urn:xmpp:comments:%') AND XMLEXISTS('/item/entry' PASSING (data::xml));