Commit 5377fc82 authored by Philipp Hörist's avatar Philipp Hörist

Dont block contacts only partially

This is needed for better interop with XEP-0191.
The Server doesnt deliver a partial blocked contact as blocked
to a XEP-0191 Client.
parent 4966b4bf
...@@ -1764,9 +1764,10 @@ class Connection(CommonConnection, ConnectionHandlers): ...@@ -1764,9 +1764,10 @@ class Connection(CommonConnection, ConnectionHandlers):
for contact in contact_list: for contact in contact_list:
self.send_custom_status('offline', message, contact.jid) self.send_custom_status('offline', message, contact.jid)
max_order = self.get_max_blocked_list_order() max_order = self.get_max_blocked_list_order()
new_rule = {'order': str(max_order + 1), 'type': 'jid', 'action': 'deny', new_rule = {'order': str(max_order + 1),
'value' : contact.jid, 'child': ['message', 'iq', 'type': 'jid',
'presence-out']} 'action': 'deny',
'value': contact.jid}
self.blocked_list.append(new_rule) self.blocked_list.append(new_rule)
self.blocked_contacts.append(contact.jid) self.blocked_contacts.append(contact.jid)
self.set_privacy_list('block', self.blocked_list) self.set_privacy_list('block', self.blocked_list)
...@@ -1820,8 +1821,10 @@ class Connection(CommonConnection, ConnectionHandlers): ...@@ -1820,8 +1821,10 @@ class Connection(CommonConnection, ConnectionHandlers):
for contact in contact_list: for contact in contact_list:
self.send_custom_status('offline', message, contact.jid) self.send_custom_status('offline', message, contact.jid)
max_order = self.get_max_blocked_list_order() max_order = self.get_max_blocked_list_order()
new_rule = {'order': str(max_order + 1), 'type': 'group', 'action': 'deny', new_rule = {'order': str(max_order + 1),
'value' : group, 'child': ['message', 'iq', 'presence-out']} 'type': 'group',
'action': 'deny',
'value': group}
self.blocked_list.append(new_rule) self.blocked_list.append(new_rule)
self.set_privacy_list('block', self.blocked_list) self.set_privacy_list('block', self.blocked_list)
if len(self.blocked_list) == 1: if len(self.blocked_list) == 1:
...@@ -2446,6 +2449,7 @@ class Connection(CommonConnection, ConnectionHandlers): ...@@ -2446,6 +2449,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.connection.send(iq) self.connection.send(iq)
def _nec_privacy_list_received(self, obj): def _nec_privacy_list_received(self, obj):
roster = gajim.interface.roster
if obj.conn.name != self.name: if obj.conn.name != self.name:
return return
if obj.list_name != 'block': if obj.list_name != 'block':
...@@ -2475,6 +2479,11 @@ class Connection(CommonConnection, ConnectionHandlers): ...@@ -2475,6 +2479,11 @@ class Connection(CommonConnection, ConnectionHandlers):
self.blocked_groups.append(rule['value']) self.blocked_groups.append(rule['value'])
self.blocked_list.append(rule) self.blocked_list.append(rule)
if rule['type'] == 'jid':
roster.draw_contact(rule['value'], self.name)
if rule['type'] == 'group':
roster.draw_group(rule['value'], self.name)
def _request_bookmarks_xml(self): def _request_bookmarks_xml(self):
if not gajim.account_is_connected(self.name): if not gajim.account_is_connected(self.name):
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment