parameters: (self, raw)
return_statement: return new_message
docstring: Process inbound message.
  
          @param raw: a RawMessage object
              which should be a json conforming to
              https://docs.joinmastodon.org/api/entities/#status
          @rtype: NewMessage
docstring_summary: Process inbound message.
docstring_tokens: Process inbound message .
function: def process_inbound(self, raw):
          """
          Process inbound message.
  
          @param raw: a RawMessage object
              which should be a json conforming to
              https://docs.joinmastodon.org/api/entities/#status
          @rtype: NewMessage
          """
          toot = MastodonStatus(raw.raw_data)
          new_message = NewInboundMessage()
          new_message.raw_msg_id = raw.raw_msg_id
          new_message.body_html = toot.body_html
          new_message.date = toot.date
          new_message.protocol = toot.protocol
          new_message.is_unread = True
          new_message.is_draft = False
          new_message.is_answered = False
          new_message.is_received = True
          new_message.importance_level = 0  # XXX tofix on parser
          new_message.external_references = toot.external_references
  
          participants = []
          for p in toot.participants:
              p.address = p.address
              participant, contact = self.get_participant(toot, p)
              new_message.participants.append(participant)
              participants.append((participant, contact))
  
          if not participants:
              raise Exception("no participant found in raw tweet {}".format(
                  raw.raw_msg_id))
  
          # Compute PI !!
          # TODO
  
          # compute tags
          self._get_tags(new_message)
          if new_message.tags:
              log.debug('Resolved tags {}'.format(new_message.tags))
  
          # build discussion_id from lookup_sequence
          lookup_sequence, discussion_id = self.lookup_discussion_sequence(
              new_message)
          log.debug('Lookup with sequence {} gives {}'.format(lookup_sequence,
                                                              discussion_id))
          new_message.discussion_id = discussion_id
  
          # upsert lookup tables
          discuss = Discussion(self.user)
          discuss.upsert_lookups_for_participants(new_message.participants)
          # Format features
          new_message.privacy_features = \
              marshal_features(new_message.privacy_features)
          try:
              new_message.validate()
          except Exception as exc:
              log.error(
                  "validation failed with error : « {} » \
                  for new_message {}[dump : {}]".format(
                      exc, new_message, vars(new_message)))
              raise exc
  
          return new_message
function_tokens: def process_inbound ( self , raw ) : toot = MastodonStatus ( raw . raw_data ) new_message = NewInboundMessage ( ) new_message . raw_msg_id = raw . raw_msg_id new_message . body_html = toot . body_html new_message . date = toot . date new_message . protocol = toot . protocol new_message . is_unread = True new_message . is_draft = False new_message . is_answered = False new_message . is_received = True new_message . importance_level = 0 # XXX tofix on parser new_message . external_references = toot . external_references participants = [ ] for p in toot . participants : p . address = p . address participant , contact = self . get_participant ( toot , p ) new_message . participants . append ( participant ) participants . append ( ( participant , contact ) ) if not participants : raise Exception ( "no participant found in raw tweet {}" . format ( raw . raw_msg_id ) ) # Compute PI !! # TODO # compute tags self . _get_tags ( new_message ) if new_message . tags : log . debug ( 'Resolved tags {}' . format ( new_message . tags ) ) # build discussion_id from lookup_sequence lookup_sequence , discussion_id = self . lookup_discussion_sequence ( new_message ) log . debug ( 'Lookup with sequence {} gives {}' . format ( lookup_sequence , discussion_id ) ) new_message . discussion_id = discussion_id # upsert lookup tables discuss = Discussion ( self . user ) discuss . upsert_lookups_for_participants ( new_message . participants ) # Format features new_message . privacy_features = marshal_features ( new_message . privacy_features ) try : new_message . validate ( ) except Exception as exc : log . error ( "validation failed with error : « {} » \
                  for new_message {}[dump : {}]" . format ( exc , new_message , vars ( new_message ) ) ) raise exc return new_message