follow RFC 3921 section 8 for subscription. This also fixes #1400
This commit is contained in:
parent
eb055c5bf2
commit
59e6377546
|
@ -2151,10 +2151,21 @@ class Connection:
|
|||
p = common.xmpp.Presence(jid, 'unsubscribe')
|
||||
self.connection.send(p)
|
||||
|
||||
def request_subscription(self, jid, msg):
|
||||
def request_subscription(self, jid, msg, name = '', groups = []):
|
||||
if not self.connection:
|
||||
return
|
||||
gajim.log.debug('subscription request for %s' % jid)
|
||||
# RFC 3921 section 8.2
|
||||
infos = {'jid': jid}
|
||||
if name:
|
||||
infos['name'] = name
|
||||
iq = common.xmpp.Iq('set', common.xmpp.NS_ROSTER)
|
||||
q = iq.getTag('query')
|
||||
item = q.addChild('item', attrs = infos)
|
||||
for g in groups:
|
||||
item.addChild('group').setData(g)
|
||||
self.connection.send(iq)
|
||||
|
||||
p = common.xmpp.Presence(jid, 'subscribe')
|
||||
p = self.add_sha(p)
|
||||
if not msg:
|
||||
|
|
|
@ -601,7 +601,6 @@ class Interface:
|
|||
if _('Not in Roster') in c.groups:
|
||||
c.groups.remove(_('Not in Roster'))
|
||||
self.roster.add_contact_to_roster(c.jid, account)
|
||||
gajim.connections[account].update_contact(c.jid, c.name, c.groups)
|
||||
else:
|
||||
keyID = ''
|
||||
attached_keys = gajim.config.get_per('accounts', account,
|
||||
|
|
|
@ -1345,11 +1345,11 @@ class RosterWindow:
|
|||
|
||||
def req_sub(self, widget, jid, txt, account, group=None, pseudo=None):
|
||||
'''Request subscription to a contact'''
|
||||
gajim.connections[account].request_subscription(jid, txt)
|
||||
if group:
|
||||
group = [group]
|
||||
else:
|
||||
group = []
|
||||
gajim.connections[account].request_subscription(jid, txt, pseudo, group)
|
||||
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
|
||||
if not contact:
|
||||
keyID = ''
|
||||
|
|
Loading…
Reference in New Issue