follow RFC 3921 section 8 for subscription. This also fixes #1400
This commit is contained in:
		
							parent
							
								
									eb055c5bf2
								
							
						
					
					
						commit
						59e6377546
					
				
					 3 changed files with 13 additions and 3 deletions
				
			
		|  | @ -2151,10 +2151,21 @@ class Connection: | ||||||
| 		p = common.xmpp.Presence(jid, 'unsubscribe') | 		p = common.xmpp.Presence(jid, 'unsubscribe') | ||||||
| 		self.connection.send(p) | 		self.connection.send(p) | ||||||
| 
 | 
 | ||||||
| 	def request_subscription(self, jid, msg): | 	def request_subscription(self, jid, msg, name = '', groups = []): | ||||||
| 		if not self.connection: | 		if not self.connection: | ||||||
| 			return | 			return | ||||||
| 		gajim.log.debug('subscription request for %s' % jid) | 		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 = common.xmpp.Presence(jid, 'subscribe') | ||||||
| 		p = self.add_sha(p) | 		p = self.add_sha(p) | ||||||
| 		if not msg: | 		if not msg: | ||||||
|  |  | ||||||
|  | @ -601,7 +601,6 @@ class Interface: | ||||||
| 			if _('Not in Roster') in c.groups: | 			if _('Not in Roster') in c.groups: | ||||||
| 				c.groups.remove(_('Not in Roster')) | 				c.groups.remove(_('Not in Roster')) | ||||||
| 			self.roster.add_contact_to_roster(c.jid, account) | 			self.roster.add_contact_to_roster(c.jid, account) | ||||||
| 			gajim.connections[account].update_contact(c.jid, c.name, c.groups) |  | ||||||
| 		else: | 		else: | ||||||
| 			keyID = '' | 			keyID = '' | ||||||
| 			attached_keys = gajim.config.get_per('accounts', account, | 			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): | 	def req_sub(self, widget, jid, txt, account, group=None, pseudo=None): | ||||||
| 		'''Request subscription to a contact''' | 		'''Request subscription to a contact''' | ||||||
| 		gajim.connections[account].request_subscription(jid, txt) |  | ||||||
| 		if group: | 		if group: | ||||||
| 			group = [group] | 			group = [group] | ||||||
| 		else: | 		else: | ||||||
| 			group = [] | 			group = [] | ||||||
|  | 		gajim.connections[account].request_subscription(jid, txt, pseudo, group) | ||||||
| 		contact = gajim.contacts.get_contact_with_highest_priority(account, jid) | 		contact = gajim.contacts.get_contact_with_highest_priority(account, jid) | ||||||
| 		if not contact: | 		if not contact: | ||||||
| 			keyID = '' | 			keyID = '' | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue