def _extract_participants(self, participant_data, read_state, user_phone_number, self_gaia_id): # Builds a dictionary of the participants in a conversation/thread participant_list = {} for participant in participant_data: # Create a new participant and store its properties current_participant = Participant() current_participant.name = getattr(participant, "fallback_name", None) participant_id = getattr(participant, "id", None) current_participant.chat_id = self._try_int_attribute( participant_id, "chat_id") current_participant.gaia_id = self._try_int_attribute( participant_id, "gaia_id") current_participant.type = getattr(participant, "participant_type", None) # Parse participant phone details phone_number = getattr(participant, "phone_number", None) if phone_number is not None: current_participant.e164_number = getattr( phone_number, "e164", None) i18n_data = getattr(phone_number, "i18n_data", None) if i18n_data is not None: current_participant.country_code = getattr( i18n_data, "country_code", None) current_participant.international_number = getattr( i18n_data, "international_number", None) current_participant.national_number = getattr( i18n_data, "national_number", None) current_participant.region_code = getattr( i18n_data, "region_code", None) # Sometimes the phone number is missing... # This only seems to happen for the user, not others if (current_participant.gaia_id is not None and current_participant.gaia_id == self_gaia_id and (current_participant.e164_number is None and current_participant.international_number is None and current_participant.national_number is None)): current_participant.e164_number = user_phone_number current_participant.international_number = user_phone_number participant_list[current_participant.gaia_id] = current_participant # Parse read_state to get latest_read_timestamp for each participant if read_state is not None: for participant_read_state in read_state: participant_id = getattr(participant_read_state, "participant_id", None) gaia_id = self._try_int_attribute(participant_id, "gaia_id") latest_read_timestamp = self._try_int_attribute( participant_read_state, "latest_read_timestamp") if gaia_id in participant_list.keys(): participant_list[ gaia_id].latest_read_timestamp = latest_read_timestamp return participant_list