@@ -938,7 +938,21 @@ PrivacyListProxy.prototype = {
938938 } ) ;
939939
940940 connection . sendIQ ( iq , function ( stanzaResult ) {
941- callback ( null , stanzaResult ) ;
941+ var allNames = [ ] , namesList = { } ,
942+ defaultList = stanzaResult . getElementsByTagName ( 'default' ) ,
943+ activeList = stanzaResult . getElementsByTagName ( 'active' ) ,
944+ allLists = stanzaResult . getElementsByTagName ( 'list' ) ,
945+ defaultName = defaultList [ 0 ] . getAttribute ( 'name' ) ,
946+ activeName = activeList [ 0 ] . getAttribute ( 'name' ) ;
947+ for ( var i = 0 , len = allLists . length ; i < len ; i ++ ) {
948+ allNames . push ( allLists [ i ] . getAttribute ( 'name' ) ) ;
949+ }
950+ namesList = {
951+ 'default' : defaultName ,
952+ 'active' : activeName ,
953+ 'names' : allNames
954+ } ;
955+ callback ( null , namesList ) ;
942956 } , function ( stanzaError ) {
943957 if ( stanzaError ) {
944958 var errorObject = getErrorFromXMLNode ( stanzaError ) ;
@@ -1012,7 +1026,7 @@ PrivacyListProxy.prototype = {
10121026
10131027 listKeys = Object . keys ( listObj ) ;
10141028
1015- for ( var index = 0 , i = 1 , j = 2 , len = listKeys . length ; index < len ; index ++ , i = i + 2 , j = j + 2 ) {
1029+ for ( var index = 0 , i = 0 , len = listKeys . length ; index < len ; index ++ , i = i + 2 ) {
10161030 userId = listKeys [ index ] ;
10171031 userAction = listObj [ userId ] ;
10181032 userJid = self . helpers . jidOrUserId ( parseInt ( userId , 10 ) ) ;
@@ -1022,19 +1036,19 @@ PrivacyListProxy.prototype = {
10221036 type : 'jid' ,
10231037 value : userJid ,
10241038 action : userAction ,
1025- order : i
1039+ order : i + 1
10261040 } ) . up ( ) ;
10271041
10281042 iq . c ( 'item' , {
10291043 type : 'jid' ,
10301044 value : userMuc ,
10311045 action : userAction ,
1032- order : j
1046+ order : i + 2
10331047 } ) . up ( ) ;
10341048 }
10351049
10361050 connection . sendIQ ( iq , function ( stanzaResult ) {
1037- callback ( null , stanzaResult ) ;
1051+ callback ( null , null ) ;
10381052 } , function ( stanzaError ) {
10391053 if ( stanzaError ) {
10401054 var errorObject = getErrorFromXMLNode ( stanzaError ) ;
@@ -1059,15 +1073,13 @@ PrivacyListProxy.prototype = {
10591073 list . items = updatedArray ;
10601074 createList = list ;
10611075
1062- self . create ( createList , null ) ;
1063- } ) ;
1064-
1065- self . getList ( list . name , function ( error , response ) {
1066- if ( error ) {
1067- callback ( error , null ) ;
1068- } else {
1069- callback ( null , response ) ;
1070- }
1076+ self . create ( createList , function ( error , response ) {
1077+ if ( error ) {
1078+ callback ( error , null ) ;
1079+ } else {
1080+ callback ( null , createList ) ;
1081+ }
1082+ } ) ;
10711083 } ) ;
10721084 } ,
10731085
@@ -1083,7 +1095,7 @@ PrivacyListProxy.prototype = {
10831095 } ) ;
10841096
10851097 connection . sendIQ ( iq , function ( stanzaResult ) {
1086- callback ( null , stanzaResult ) ;
1098+ callback ( null , null ) ;
10871099 } , function ( stanzaError ) {
10881100 if ( stanzaError ) {
10891101 var errorObject = getErrorFromXMLNode ( stanzaError ) ;
@@ -1106,7 +1118,7 @@ PrivacyListProxy.prototype = {
11061118 } ) ;
11071119
11081120 connection . sendIQ ( iq , function ( stanzaResult ) {
1109- callback ( null , stanzaResult ) ;
1121+ callback ( null , null ) ;
11101122 } , function ( stanzaError ) {
11111123 if ( stanzaError ) {
11121124 var errorObject = getErrorFromXMLNode ( stanzaError ) ;
@@ -1125,11 +1137,11 @@ PrivacyListProxy.prototype = {
11251137 } ) . c ( 'query' , {
11261138 xmlns : Strophe . NS . PRIVACY_LIST
11271139 } ) . c ( 'active' , {
1128- name : name
1140+ name : name ? name : ''
11291141 } ) ;
11301142
11311143 connection . sendIQ ( iq , function ( stanzaResult ) {
1132- callback ( null , stanzaResult ) ;
1144+ callback ( null , null ) ;
11331145 } , function ( stanzaError ) {
11341146 if ( stanzaError ) {
11351147 var errorObject = getErrorFromXMLNode ( stanzaError ) ;
0 commit comments