def _log_muc_event(self, event_name, properties): if event_name not in [ 'muc-user-joined', 'muc-user-left', 'muc-user-status-show-changed' ]: return if (not app.settings.get('log_contact_status_changes') or not helpers.should_log(self._account, properties.jid)): return additional_data = AdditionalDataDict() if properties.muc_user is not None: if properties.muc_user.jid is not None: additional_data.set_value('gajim', 'real_jid', str(properties.muc_user.jid)) # TODO: Refactor if properties.type == PresenceType.UNAVAILABLE: show = 'offline' else: show = properties.show.value show = app.storage.archive.convert_show_values_to_db_api_values(show) app.storage.archive.insert_into_logs( self._account, properties.jid.bare, properties.timestamp, KindConstant.GCSTATUS, contact_name=properties.muc_nickname, message=properties.status or None, show=show, additional_data=additional_data)
def _log_presence(self, properties): if not app.settings.get('log_contact_status_changes'): return if not should_log(self._account, properties.jid.bare): return show = ShowConstant[properties.show.name] if properties.type.is_unavailable: show = ShowConstant.OFFLINE app.storage.archive.insert_into_logs(self._account, properties.jid.bare, time.time(), KindConstant.STATUS, message=properties.status, show=show)
def _log_muc_message(self, event): self._check_for_mam_compliance(event.room_jid, event.stanza_id) if (should_log(self._account, event.jid) and event.msgtxt and event.properties.muc_nickname): # if not event.nick, it means message comes from room itself # usually it hold description and can be send at each connection # so don't store it in logs app.storage.archive.insert_into_logs( self._account, event.jid, event.properties.timestamp, KindConstant.GC_MSG, message=event.msgtxt, contact_name=event.properties.muc_nickname, additional_data=event.additional_data, stanza_id=event.stanza_id, message_id=event.properties.id)
def log_message(self, message): if not message.is_loggable: return if not should_log(self._account, message.jid): return if message.message is None: return app.storage.archive.insert_into_logs( self._account, message.jid, message.timestamp, message.kind, message=message.message, subject=message.subject, additional_data=message.additional_data, message_id=message.message_id, stanza_id=message.message_id)
def is_loggable(self): return helpers.should_log(self.conn.name, self.jid.bare)