diff options
author | Remko Tronçon <git@el-tramo.be> | 2013-10-30 19:51:56 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2013-10-30 19:53:32 (GMT) |
commit | d7b73e460adab34f5bf0cc0038ffa21bd6b6c53a (patch) | |
tree | 0740d6d445c3e611fe5ca3c6e95709b9c3b8b04c | |
parent | aeae699f47c3f9a148903525943b6876c39a598d (diff) | |
download | swift-d7b73e460adab34f5bf0cc0038ffa21bd6b6c53a.zip swift-d7b73e460adab34f5bf0cc0038ffa21bd6b6c53a.tar.bz2 |
Implement missing PubSub owner queries.
Implemented get_owner_subscriptions, get_owner_affiliations, and
set_owner_affiliations.
Change-Id: Ib3ccf2f7e7fe228ccdddf83bde324341e69362d6
-rw-r--r-- | Sluift/boot.lua | 11 | ||||
-rw-r--r-- | Swiften/QA/ScriptedTests/PubSub.lua | 20 |
2 files changed, 30 insertions, 1 deletions
diff --git a/Sluift/boot.lua b/Sluift/boot.lua index b642bfa..e019fe6 100644 --- a/Sluift/boot.lua +++ b/Sluift/boot.lua @@ -275,6 +275,8 @@ local simple_pubsub_node_queries = { get_configuration = 'pubsub_owner_configure', get_subscriptions = 'pubsub_subscriptions', get_affiliations = 'pubsub_affiliations', + get_owner_subscriptions = 'pubsub_owner_subscriptions', + get_owner_affiliations = 'pubsub_owner_affiliations', get_default_subscription_options = 'pubsub_default', } for method, query_type in pairs(simple_pubsub_node_queries) do @@ -335,6 +337,15 @@ function PubSubNode.set_configuration(node, options) }, options)) end +function PubSubNode.set_owner_affiliations(node, ...) + local options = parse_options({}, ...) + return node.client:query_pubsub(merge_tables({ + type = 'set', to = node.jid, query = merge_tables({ + _type = 'pubsub_owner_affiliations', node = node.node, + }, options.affiliations)}, options)) +end + + function PubSubNode.subscribe(node, ...) local options = parse_options(...) local jid = options.jid or sluift.jid.to_bare(node.client:jid()) diff --git a/Swiften/QA/ScriptedTests/PubSub.lua b/Swiften/QA/ScriptedTests/PubSub.lua index 5ea701c..43cce14 100644 --- a/Swiften/QA/ScriptedTests/PubSub.lua +++ b/Swiften/QA/ScriptedTests/PubSub.lua @@ -286,7 +286,25 @@ function test_owner_use_cases() -- 8.7 Process pending subscription requests -- TODO - -- ... + -- 8.8 Manage Subscriptions + assert(node:create()) + assert(subscriber_node:subscribe({ jid = subscriber_jid })) + local items = assert(node:get_owner_subscriptions()) + assert(#items == 1) + assert(items[1].jid == subscriber_jid) + assert(items[1].subscription == "subscribed") + assert(node:delete()) + + -- 8.9 Manage Affiliations + assert(node:create()) + assert(node:set_owner_affiliations{affiliations = {{jid = subscriber_jid, type = 'publisher'}}}) + local items = assert(node:get_owner_affiliations()) + assert(#items == 2) + assert(items[1].jid == publisher_jid) + assert(items[1].type == "owner") + assert(items[2].jid == subscriber_jid) + assert(items[2].type == "publisher") + assert(node:delete()) end function run_tests() |