prevent the right way bad show to crash us; add comment on special treatment of show is None in *status events

This commit is contained in:
Nikos Kouremenos 2005-11-28 17:34:43 +00:00
parent d38883a92a
commit a64709b7a4
1 changed files with 10 additions and 7 deletions

View File

@ -181,10 +181,9 @@ class Logger:
show_col = constants.SHOW_DND show_col = constants.SHOW_DND
elif show == 'offline': elif show == 'offline':
show_col = constants.SHOW_OFFLINE show_col = constants.SHOW_OFFLINE
elif show is None: else: # invisible in GC when someone goes invisible
show_col = constants.SHOW_ONLINE # it's a RFC violation .... but we should not crash
else: show_col = 'UNKNOWN'
show_col = None
return kind_col, show_col return kind_col, show_col
@ -230,16 +229,17 @@ class Logger:
kind_col, show_col = self.convert_human_values_to_db_api_values(kind, kind_col, show_col = self.convert_human_values_to_db_api_values(kind,
show) show)
if not show_col: # unknown show
return
# now we may have need to do extra care for some values in columns # now we may have need to do extra care for some values in columns
if kind == 'status': # we store (not None) time, jid, show, msg if kind == 'status': # we store (not None) time, jid, show, msg
# status for roster items # status for roster items
jid_id = self.get_jid_id(jid) jid_id = self.get_jid_id(jid)
if show is None: # show is None (xmpp), but we say that 'online'
show_col = constants.SHOW_ONLINE
elif kind == 'gcstatus': elif kind == 'gcstatus':
# status in ROOM (for pm status see status) # status in ROOM (for pm status see status)
if show is None: # show is None (xmpp), but we say that 'online'
show_col = constants.SHOW_ONLINE
jid, nick = jid.split('/', 1) jid, nick = jid.split('/', 1)
jid_id = self.get_jid_id(jid, 'ROOM') # re-get jid_id for the new jid jid_id = self.get_jid_id(jid, 'ROOM') # re-get jid_id for the new jid
contact_name_col = nick contact_name_col = nick
@ -255,6 +255,9 @@ class Logger:
contact_name_col = nick contact_name_col = nick
else: else:
jid_id = self.get_jid_id(jid) jid_id = self.get_jid_id(jid)
if show_col == 'UNKNOWN': # unknown show, do not log
return
values = (jid_id, contact_name_col, time_col, kind_col, show_col, values = (jid_id, contact_name_col, time_col, kind_col, show_col,
message_col, subject_col) message_col, subject_col)