[SVN] bump to version 0.2.1

[UPD] roster exchange (XEP-0144) now is not mandatory since not all clients supports it; it is optional and configurable
This commit is contained in:
annelin
2018-06-19 19:29:49 +00:00
parent 55f85db5d1
commit c16faf8e4e
3 changed files with 19 additions and 6 deletions

View File

@@ -433,7 +433,18 @@ class XMPPTelegram(ComponentXMPP):
rawxml = rawxml + "</x>"
message.appendxml(ET.fromstring(rawxml))
return message
self.send(message)
def roster_fill(self, tojid, contacts):
for jid, nick in contacts.items():
presence = sleekxmpp.Presence()
presence['from'] = jid
presence['to'] = tojid
presence['type'] = 'subscribe'
presence.appendxml(ET.fromstring("<nick xmlns='http://jabber.org/protocol/nick'>%s</nick>" % nick))
self.send(presence)
def tg_process_dialogs(self, jid):
@@ -549,8 +560,10 @@ class XMPPTelegram(ComponentXMPP):
self.send_presence(pto=jid, pfrom=c_jid)
if len(dlgs.dialogs) == 0: # Если все диалоги получены - прерываем цикл
rosterxchange = self.roster_exchange(jid, self.contact_list[jid])
self.send(rosterxchange)
if self.config['xmpp_use_roster_exchange']:
self.roster_exchange(jid, self.contact_list[jid])
else:
self.roster_fill(jid, self.contact_list[jid])
break
else: # Иначе строим оффсеты
last_msg_id = dlgs.dialogs[-1].top_message # Нужен последний id сообщения. Наркоманы.