Now also sending resource to prevent some clients unwanted behaviour
This commit is contained in:
parent
2c3ab0aceb
commit
474e59b4d8
|
@ -70,6 +70,7 @@ class TelegramClient
|
||||||
def initialize(xmpp, jid, **session)
|
def initialize(xmpp, jid, **session)
|
||||||
return unless @@config
|
return unless @@config
|
||||||
@logger = Logger.new(STDOUT, level: @@config[:loglevel], progname: 'TelegramClient: %s | %s' % [jid, session[:login]] )
|
@logger = Logger.new(STDOUT, level: @@config[:loglevel], progname: 'TelegramClient: %s | %s' % [jid, session[:login]] )
|
||||||
|
@resource = @@config[:tdlib][:client][:device_model] || 'zhabogram'
|
||||||
@xmpp = xmpp
|
@xmpp = xmpp
|
||||||
@jid = jid
|
@jid = jid
|
||||||
@session = session
|
@session = session
|
||||||
|
@ -270,7 +271,7 @@ class TelegramClient
|
||||||
when TD::Types::UserStatus::Offline then show, status = (Time.now.getutc.to_i-status.was_online.to_i<3600) ? :away : :xa,
|
when TD::Types::UserStatus::Offline then show, status = (Time.now.getutc.to_i-status.was_online.to_i<3600) ? :away : :xa,
|
||||||
DateTime.strptime((status.was_online+Time.now.getlocal(@session[:timezone]).utc_offset).to_s,'%s').strftime("Last seen at %H:%M %d/%m/%Y")
|
DateTime.strptime((status.was_online+Time.now.getlocal(@session[:timezone]).utc_offset).to_s,'%s').strftime("Last seen at %H:%M %d/%m/%Y")
|
||||||
end
|
end
|
||||||
return @xmpp.send_presence(@jid, id, type, show, status, nil, photo, immed)
|
return @xmpp.send_presence(@jid, id, type, show, status, nil, photo, @resource, immed)
|
||||||
end
|
end
|
||||||
|
|
||||||
## send outgoing message to telegram user
|
## send outgoing message to telegram user
|
||||||
|
|
|
@ -94,10 +94,10 @@ class XMPPComponent
|
||||||
@component.send(message)
|
@component.send(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_presence(to, from=nil, type=nil, show=nil, status=nil, nickname=nil, photo=nil, immed=true)
|
def send_presence(to, from=nil, type=nil, show=nil, status=nil, nickname=nil, photo=nil, resource=nil, immed=true)
|
||||||
@logger.info "Got presence :%s from %s to %s" % [type, from||@component.jid, to]
|
@logger.info "Got presence :%s from %s to %s" % [type, from||@component.jid, to]
|
||||||
presence = Jabber::Presence.new()
|
presence = Jabber::Presence.new()
|
||||||
presence.from = from.nil? ? @component.jid : "%s@%s" % [from.to_s, @component.jid.to_s] # presence <from>
|
presence.from = from.nil? ? @component.jid : "%s@%s%s" % [from.to_s, @component.jid.to_s, (resource ? "/"+resource : "")] # presence <from>
|
||||||
presence.to = to # presence <to>
|
presence.to = to # presence <to>
|
||||||
presence.type = type unless type.nil? # pres. type
|
presence.type = type unless type.nil? # pres. type
|
||||||
presence.show = show unless show.nil? # presence <show>
|
presence.show = show unless show.nil? # presence <show>
|
||||||
|
|
Reference in a new issue