detect incoming MUC error presences from the ID. Fixes #5309
This commit is contained in:
parent
6c2b658a9a
commit
f18ede1c88
2 changed files with 21 additions and 2 deletions
|
@ -39,6 +39,7 @@ import operator
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import locale
|
import locale
|
||||||
|
import hmac
|
||||||
|
|
||||||
try:
|
try:
|
||||||
randomsource = random.SystemRandom()
|
randomsource = random.SystemRandom()
|
||||||
|
@ -190,6 +191,7 @@ class Connection(ConnectionHandlers):
|
||||||
self.vcard_supported = False
|
self.vcard_supported = False
|
||||||
self.private_storage_supported = True
|
self.private_storage_supported = True
|
||||||
self.streamError = ''
|
self.streamError = ''
|
||||||
|
self.secret_hmac = str(random.random())[2:]
|
||||||
# END __init__
|
# END __init__
|
||||||
|
|
||||||
def put_event(self, ev):
|
def put_event(self, ev):
|
||||||
|
@ -1775,8 +1777,12 @@ class Connection(ConnectionHandlers):
|
||||||
last_log = 0
|
last_log = 0
|
||||||
self.last_history_time[room_jid] = last_log
|
self.last_history_time[room_jid] = last_log
|
||||||
|
|
||||||
p = common.xmpp.Presence(to = '%s/%s' % (room_jid, nick),
|
p = common.xmpp.Presence(to='%s/%s' % (room_jid, nick),
|
||||||
show = show, status = self.status)
|
show=show, status=self.status)
|
||||||
|
h = hmac.new(self.secret_hmac, room_jid).hexdigest()[:6]
|
||||||
|
id_ = self.connection.getAnID()
|
||||||
|
id_ = 'gajim_muc_' + id_ + '_' + h
|
||||||
|
p.setID(id_)
|
||||||
if gajim.config.get('send_sha_in_gc_presence'):
|
if gajim.config.get('send_sha_in_gc_presence'):
|
||||||
p = self.add_sha(p)
|
p = self.add_sha(p)
|
||||||
self.add_lang(p)
|
self.add_lang(p)
|
||||||
|
@ -1843,6 +1849,10 @@ class Connection(ConnectionHandlers):
|
||||||
xmpp_show = helpers.get_xmpp_show(show)
|
xmpp_show = helpers.get_xmpp_show(show)
|
||||||
p = common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype,
|
p = common.xmpp.Presence(to = '%s/%s' % (jid, nick), typ = ptype,
|
||||||
show = xmpp_show, status = status)
|
show = xmpp_show, status = status)
|
||||||
|
h = hmac.new(self.secret_hmac, jid).hexdigest()[:6]
|
||||||
|
id_ = self.connection.getAnID()
|
||||||
|
id_ = 'gajim_muc_' + id_ + '_' + h
|
||||||
|
p.setID(id_)
|
||||||
if gajim.config.get('send_sha_in_gc_presence') and show != 'offline':
|
if gajim.config.get('send_sha_in_gc_presence') and show != 'offline':
|
||||||
p = self.add_sha(p, ptype != 'unavailable')
|
p = self.add_sha(p, ptype != 'unavailable')
|
||||||
self.add_lang(p)
|
self.add_lang(p)
|
||||||
|
|
|
@ -34,6 +34,7 @@ import socket
|
||||||
import sys
|
import sys
|
||||||
import operator
|
import operator
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import hmac
|
||||||
|
|
||||||
from time import (altzone, daylight, gmtime, localtime, mktime, strftime,
|
from time import (altzone, daylight, gmtime, localtime, mktime, strftime,
|
||||||
time as time_time, timezone, tzname)
|
time as time_time, timezone, tzname)
|
||||||
|
@ -2207,6 +2208,7 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
return
|
return
|
||||||
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
jid_stripped, resource = gajim.get_room_and_nick_from_fjid(who)
|
||||||
timestamp = None
|
timestamp = None
|
||||||
|
id_ = prs.getID()
|
||||||
is_gc = False # is it a GC presence ?
|
is_gc = False # is it a GC presence ?
|
||||||
sigTag = None
|
sigTag = None
|
||||||
ns_muc_user_x = None
|
ns_muc_user_x = None
|
||||||
|
@ -2246,6 +2248,13 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco,
|
||||||
if self.connection.getRoster().getItem(agent): # to be sure it's a transport contact
|
if self.connection.getRoster().getItem(agent): # to be sure it's a transport contact
|
||||||
transport_auto_auth = True
|
transport_auto_auth = True
|
||||||
|
|
||||||
|
if not is_gc and id_ and id_.startswith('gajim_muc_') and \
|
||||||
|
ptype == 'error':
|
||||||
|
# Error presences may not include sent stanza, so we don't detect it's
|
||||||
|
# a muc preence. So detect it by ID
|
||||||
|
h = hmac.new(self.secret_hmac, jid_stripped).hexdigest()[:6]
|
||||||
|
if id_.split('_')[-1] = h:
|
||||||
|
is_gc = True
|
||||||
status = prs.getStatus() or ''
|
status = prs.getStatus() or ''
|
||||||
show = prs.getShow()
|
show = prs.getShow()
|
||||||
if not show in gajim.SHOW_LIST:
|
if not show in gajim.SHOW_LIST:
|
||||||
|
|
Loading…
Add table
Reference in a new issue