Skip to content

Commit f58e6e0

Browse files
committed
add the MutualBlock flag
1 parent fd384fd commit f58e6e0

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

spec/QB-ChatSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ describe('Chat API', function() {
245245
//
246246
it("can create new list with items", function(done) {
247247
var usersObj = [
248-
{user_id: 1111111, action: "deny"},
248+
{user_id: 1111111, action: "deny", mutualBlock: true},
249249
{user_id: 1010101, action: "allow"}
250250
];
251251

src/modules/qbChat.js

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ PrivacyListProxy.prototype = {
10571057
var iq, self = this,
10581058
userId, userJid,
10591059
userAction, userMuc,
1060+
mutualBlock,
10601061
listObj = {},
10611062
listKeys = [];
10621063

@@ -1071,7 +1072,10 @@ PrivacyListProxy.prototype = {
10711072
});
10721073

10731074
$(list.items).each(function(e, i){
1074-
listObj[i.user_id] = i.action;
1075+
listObj[i.user_id] = {
1076+
action: i.action,
1077+
mutualBlock: i.mutualBlock === true ? true : false
1078+
};
10751079
});
10761080

10771081
listKeys = Object.keys(listObj);
@@ -1081,28 +1085,45 @@ PrivacyListProxy.prototype = {
10811085
userAction = listObj[userId];
10821086
userJid = self.helpers.jidOrUserId(parseInt(userId, 10));
10831087
userMuc = self.helpers.getUserNickWithMucDomain(userId);
1084-
1085-
iq.c('item', {
1086-
type: 'jid',
1087-
value: userJid,
1088-
action: userAction,
1089-
order: i+1
1090-
}).c('message', {
1091-
}).up().c('presence-in', {
1092-
}).up().c('presence-out', {
1093-
}).up().c('iq', {
1094-
}).up().up();
1095-
1096-
iq.c('item', {
1097-
type: 'jid',
1098-
value: userMuc,
1099-
action: userAction,
1100-
order: i+2
1101-
}).c('message', {
1102-
}).up().c('presence-in', {
1103-
}).up().c('presence-out', {
1104-
}).up().c('iq', {
1105-
}).up().up();
1088+
mutualBlock = listObj[userId].mutualBlock;
1089+
1090+
if(!mutualBlock && userAction !== 'deny'){
1091+
iq.c('item', {
1092+
type: 'jid',
1093+
value: userJid,
1094+
action: userAction,
1095+
order: i+1
1096+
}).c('message', {
1097+
}).up().c('presence-in', {
1098+
}).up().c('presence-out', {
1099+
}).up().c('iq', {
1100+
}).up().up();
1101+
1102+
iq.c('item', {
1103+
type: 'jid',
1104+
value: userMuc,
1105+
action: userAction,
1106+
order: i+2
1107+
}).c('message', {
1108+
}).up().c('presence-in', {
1109+
}).up().c('presence-out', {
1110+
}).up().c('iq', {
1111+
}).up().up();
1112+
} else {
1113+
iq.c('item', {
1114+
type: 'jid',
1115+
value: userJid,
1116+
action: userAction,
1117+
order: i+1
1118+
}).up();
1119+
1120+
iq.c('item', {
1121+
type: 'jid',
1122+
value: userMuc,
1123+
action: userAction,
1124+
order: i+2
1125+
}).up();
1126+
}
11061127
}
11071128

11081129
connection.sendIQ(iq, function(stanzaResult) {

0 commit comments

Comments
 (0)