Browse Source

[FIX] Subscription after logging in

tags/v2.1
annelin 8 months ago
parent
commit
82aa27558b
2 changed files with 4 additions and 2 deletions
  1. 2
    0
      inc/telegramclient.rb
  2. 2
    2
      inc/xmppcomponent.rb

+ 2
- 0
inc/telegramclient.rb View File

@@ -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


+ 2
- 2
inc/xmppcomponent.rb View File

@@ -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)

Loading…
Cancel
Save