[FIX] Subscription after logging in

This commit is contained in:
annelin 2020-01-05 07:22:52 +02:00
parent 6d282eb2f6
commit 82aa27558b
2 changed files with 4 additions and 2 deletions

View file

@ -109,6 +109,8 @@ class TelegramClient
@telegram.get_me.then{|me| @me = me}.wait @telegram.get_me.then{|me| @me = me}.wait
@telegram.get_chats(limit=999).wait @telegram.get_chats(limit=999).wait
@xmpp.send_presence(@jid, nil, nil, nil, "Logged in %s" % @session[:login]) @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
end end

View file

@ -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] = 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] = 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].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 end
def handle_message(message) def handle_message(message)