Quickblox: WEB 聊天中的阻止解锁和阻止列表
Quickblox: Blocking Unblocking and BlockList in WEB Chat
我想在我的聊天 Web 应用程序中添加阻止、取消阻止和检索阻止用户列表的功能。
为此,我修改了 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 link 检索阻止列表
我也遵循了 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>
在此处输入代码
QuickBlox 使用 XEP-0016 隐私列表来实现阻止功能
http://xmpp.org/extensions/xep-0016.html
请跟随它而不是0191
隐私列表 API 从 1.17.1 版本开始可用 QuickBlox Javascript SDK
这里还有 API 文档
http://quickblox.com/developers/Web_XMPP_Chat_Sample#Privacy_lists
我想在我的聊天 Web 应用程序中添加阻止、取消阻止和检索阻止用户列表的功能。
为此,我修改了 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 link 检索阻止列表
我也遵循了 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>
在此处输入代码
QuickBlox 使用 XEP-0016 隐私列表来实现阻止功能
http://xmpp.org/extensions/xep-0016.html
请跟随它而不是0191
隐私列表 API 从 1.17.1 版本开始可用 QuickBlox Javascript SDK
这里还有 API 文档
http://quickblox.com/developers/Web_XMPP_Chat_Sample#Privacy_lists