我想在聊天网络应用程序中添加阻止,解锁和检索阻止用户列表的功能。
为此,我通过添加新函数来修改quickblox.js以获取_enableCarbons()
函数下面的阻止列表:
getBlockList: function() {
iq = $iq({
//from: connection.jid, //Also tried to sent this but same response was received
type: 'get',
id: connection.getUniqueId('sendIQ')
}).c('blocklist', {
xmlns: "urn:xmpp:blocking"
});
connection.sendIQ(iq, function(stanza) {
console.log("response of getBlockList",stanza);
callback();
});
}
在调用上面的函数下面,xml被发送到服务器:
<iq type="get" id="3:sendIQ" xmlns="jabber:client">
<blocklist xmlns="urn:xmpp:blocking"></blocklist>
</iq>
在响应中发送以下xml:
<iq id="3:sendIQ" to="3056272-18345@chat.quickblox.com/1220770403-quickblox-228541" type="error" xmlns="jabber:client">
<blocklist xmlns="urn:xmpp:blocking"></blocklist>
<error type="cancel" code="501">
<feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></feature-not-implemented>
<text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Feature not supported yet.</text>
</error>
</iq>
如果我需要发送其他东西或者我做错了,请告诉我。 我按照http://xmpp.org/extensions/xep-0191.html链接检索阻止列表
我也遵循XEP-0016并通过代码更改用户将用户添加到隐私列表中:
block : function(userId,callback) {
iq = $iq({
from: connection.jid,
type: 'set',
id: connection.getUniqueId('sendIQ')
}).c('query', {
xmlns: "jabber:iq:privacy"
}).c('list',{
name : 'public'
}).c('item',{
type : 'jid',
value : this.helpers.getUserJid(userId, this.service.getSession().application_id),
action : 'deny',
order : new Date().getTime()
});
connection.sendIQ(iq, function(stanza) {
console.log("response of getBlockList",stanza);
callback(stanza);
});
}
以下发送XML:
<iq from="userid-appId@chat.quickblox.com/1220770403-quickblox-233195" type="set" id="3:sendIQ" xmlns="jabber:client">
<query xmlns="jabber:iq:privacy">
<list name="public">
<item type="jid" value="idOfUserToBlock-appId@chat.quickblox.com" action="deny" order="1444815897276"></item>
</list>
</query>
</iq>
我从服务器获得的响应是:
<iq id="3:sendIQ" to="chatID-appID@chat.quickblox.com/1220770403-quickblox-233195" type="error" xmlns="jabber:client">
<query xmlns="jabber:iq:privacy">
<list name="public">
<item value="blockChatID-appID@chat.quickblox.com" action="deny" order="1444815897276" type="jid"></item>
</list>
</query>
<error type="modify" code="400">
<bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></bad-request>
</error>
在这里输入代码
答案 0 :(得分:1)
答案 1 :(得分:0)
隐私列表API从1.17.1版QuickBlox Javascript SDK
开始提供这也是API文档
http://quickblox.com/developers/Web_XMPP_Chat_Sample#Privacy_lists