[FIX] Subscription after logging in
This commit is contained in:
parent
6d282eb2f6
commit
82aa27558b
|
@ -109,6 +109,8 @@ class TelegramClient
|
|||
@telegram.get_me.then{|me| @me = me}.wait
|
||||
@telegram.get_chats(limit=999).wait
|
||||
@xmpp.send_presence(@jid, nil, nil, nil, "Logged in %s" % @session[:login])
|
||||
@xmpp.send_presence(@jid, nil, :subscribe, nil, nil)
|
||||
@xmpp.send_presence(@jid, nil, :subscribed, nil, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class XMPPComponent
|
|||
@component.add_iq_callback do |stanza| self.handle_vcard_iq(stanza) if stanza.type == :get and stanza.vcard end # vcards handler
|
||||
@logger.warn 'Connected to XMPP server'
|
||||
@db.transaction do @db[:sessions].each do |jid, session| @sessions[jid] = TelegramClient.new(self, jid, session) end end # probe all known sessions
|
||||
@sessions.each_key do |jid| self.send_presence(jid,nil,:probe) end
|
||||
@sessions.each_key do |jid| self.send_presence(jid, nil, :probe) end
|
||||
Thread.new { while @component.is_connected? do sleep 60; @queue.delete_if {|_, presence| @component.send(presence) || true } end } # status updater thread
|
||||
Thread.stop() # stop main thread loop
|
||||
rescue Exception => error
|
||||
|
@ -53,7 +53,7 @@ class XMPPComponent
|
|||
@sessions[presence.from.bare.to_s] = TelegramClient.new(self, presence.from.bare.to_s) unless @sessions.key? presence.from.bare.to_s # create session
|
||||
@sessions[presence.from.bare.to_s] = nil if presence.type == :unsubscribed # destroy session
|
||||
@sessions[presence.from.bare.to_s].disconnect() if presence.type == :unavailable or presence.type == :error # go offline
|
||||
@sessions[presence.from.bare.to_s].connect() if not presence.type # go online
|
||||
@sessions[presence.from.bare.to_s].connect() if presence.type == :subscribe or not presence.type # go online
|
||||
end
|
||||
|
||||
def handle_message(message)
|
||||
|
|
Reference in a new issue