示例#1
0
    def _update(self, data: HangupsConversation) -> None:
        # We need this in order to allow `Client._sync`
        conversation = data

        self.id: str = getattr(getattr(conversation, 'conversation_id', None),
                               'id', None)
        self.type: ConversationType = try_enum(
            ConversationType, getattr(conversation, 'type', None))
        self.name: str = getattr(conversation, 'name', None)
        self.has_active_hangout: bool = getattr(conversation,
                                                'has_active_hangout', None)
        self.otr_status: ConversationHistoryStatus = try_enum(
            ConversationHistoryStatus, getattr(conversation, 'otr_status',
                                               None))
        self.otr_toggleable: ConversationHistoryToggleable = try_enum(
            ConversationHistoryToggleable,
            getattr(conversation, 'otr_toggle', None))
        self.conversation_history_supported: bool = getattr(
            conversation, 'conversation_history_supported', None)

        if not hasattr(self, '_participants'):
            self._participants: Dict[str, Participant] = {}

        for participant_data in getattr(conversation, 'participant_data', []):
            user = self._client._cache.get_user(participant_data.id.gaia_id)
            participant = self.get_participant(user.id)

            if participant:
                participant._update_participant(participant_data)
            else:
                self._participants[user.id] = Participant(
                    self._client, user._data, participant_data, self)

        self.network_type: NetworkType = try_enum(
            NetworkType, getattr(conversation, 'network_type', None))
        self.force_history_state: ForceHistory = try_enum(
            ForceHistory, getattr(conversation, 'force_history_state', None))
        self.group_link_sharing_status: GroupLinkSharingStatus = try_enum(
            GroupLinkSharingStatus,
            getattr(conversation, 'group_link_sharing_status', None))
示例#2
0
 def new_otr_toggle(self):
     return try_enum(ConversationHistoryToggleable,
                     self._event.otr_modification.new_otr_toggle)
示例#3
0
 def new_status(self):
     return try_enum(GroupLinkSharingStatus,
                     self._event.group_link_sharing_modification.new_status)
示例#4
0
 def new_otr_status(self):
     return try_enum(ConversationHistoryStatus,
                     self._event.otr_modification.new_otr_status)
示例#5
0
 def _update_participant(self, participant_data):
     self.fallback_name: str = getattr(participant_data, 'fallback_name',
                                       None)
     self.invitation_status: InvitationStatus = try_enum(
         InvitationStatus,
         getattr(participant_data, 'invitation_status', None))