# HG changeset patch # User Emmanuel Gil Peyrot # Date 1545438063 -3600 # Node ID db033e5eabcb22a7298775aad096bdf81b79a80c # Parent d6df73b466f6ae10364e9d5f61292d8da39d0f5e Add pubsub#access_model configuration for avatars. diff --git a/avatar.js b/avatar.js --- a/avatar.js +++ b/avatar.js @@ -9,6 +9,7 @@ function initAvatar(connection) { const avatar_file = document.getElementById('avatar-file'); const avatar_upload = document.getElementById('avatar-upload'); const avatar_change = document.getElementById('avatar-change'); + const avatar_access = document.getElementById('avatar-access'); avatar_img.src = DEFAULT_AVATAR; const iq = $iq({type: 'get'}) @@ -168,4 +169,32 @@ function initAvatar(connection) { } return [bytes, unit]; } + + avatar_access.addEventListener('change', function (evt) { + const iq = $iq({type: 'set'}) + .c('pubsub', {xmlns: 'http://jabber.org/protocol/pubsub#owner'}) + .c('configure', {node: 'urn:xmpp:avatar:metadata'}) + .c('x', {xmlns: 'jabber:x:data', type: 'submit'}) + .c('field', {'var': 'FORM_TYPE', type: 'hidden'}) + .c('value') + .t('http://jabber.org/protocol/pubsub#node_config') + .up() + .up() + .c('field', {'var': 'pubsub#access_model'}) + .c('value') + .t(evt.target.value) + .up() + .up() + connection.sendIQ(iq, onAvatarConfigured, onAvatarConfigureError.bind(null, 'PubSub configuration failed.')); + }); + + function onAvatarConfigured(result_iq) + { + console.log('Successfully set avatar access model.') + } + + function onAvatarConfigureError(string) + { + console.log('Failed to configure avatar node: ' + string); + } } diff --git a/index.xhtml b/index.xhtml --- a/index.xhtml +++ b/index.xhtml @@ -36,7 +36,7 @@ -
+

@@ -56,7 +56,11 @@

- +
+

Dangerous zone