def _keep(msg, account):
 if msg._deleted:
  return False
 if (msg._spam and (msg.author_id != account._id)):
  return False
 if (msg.author_id in account.enemies):
  return False
 if (isinstance(msg, Message) and (msg.to_id == account._id) and msg.del_on_recipient):
  return False
 if (msg.author_id == account._id):
  return False
 return True

def _keep ( msg , account ) : if msg . _deleted : return False if ( msg . _spam and ( msg . author_id != account . _id ) ) : return False if ( msg . author_id in account . enemies ) : return False if ( isinstance ( msg , Message ) and ( msg . to_id == account . _id ) and msg . del_on_recipient ) : return False if ( msg . author_id == account . _id ) : return False return True
adapted from listingcontroller .