Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(None, Field(is_optional=True)), # always None?
(None, Field(is_optional=True)), # always 0? (expiration_timestamp?)
('chat_message', CLIENT_CHAT_MESSAGE),
(None, Field(is_optional=True)), # always None?
('membership_change', CLIENT_MEMBERSHIP_CHANGE),
('conversation_rename', CLIENT_CONVERSATION_RENAME),
('hangout_event', CLIENT_HANGOUT_EVENT),
('event_id', Field(is_optional=True)),
('advances_sort_timestamp', Field(is_optional=True)),
('otr_modification', CLIENT_OTR_MODIFICATION),
(None, Field(is_optional=True)), # 0, 1 or None? related to notifications?
('event_otr', EnumField(OffTheRecordStatus)),
(None, Field()), # always 1? (advances_sort_timestamp?)
)
CLIENT_EVENT_NOTIFICATION = Message(
('event', CLIENT_EVENT),
is_optional=True,
)
CLIENT_WATERMARK_NOTIFICATION = Message(
('participant_id', USER_ID),
('conversation_id', CONVERSATION_ID),
('latest_read_timestamp', Field()),
is_optional=True,
)
CLIENT_STATE_UPDATE_HEADER = Message(
('active_client_state', EnumField(ActiveClientState)),
(None, Field(is_optional=True)),
('request_trace_id', Field()),
(None, Field(is_optional=True)),
CLIENT_RESPONSE_HEADER = Message(
('status', Field()), # 1 => success
(None, Field(is_optional=True)),
(None, Field(is_optional=True)),
('request_trace_id', Field()),
('current_server_time', Field()),
)
CLIENT_SYNC_ALL_NEW_EVENTS_RESPONSE = Message(
(None, Field()), # 'csanerp'
('response_header', CLIENT_RESPONSE_HEADER),
('sync_timestamp', Field()),
('conversation_state', RepeatedField(CLIENT_CONVERSATION_STATE)),
)
CLIENT_GET_CONVERSATION_RESPONSE = Message(
(None, Field()), # 'cgcrp'
('response_header', CLIENT_RESPONSE_HEADER),
('conversation_state', CLIENT_CONVERSATION_STATE),
)
CLIENT_GET_ENTITY_BY_ID_RESPONSE = Message(
(None, Field()), # 'cgebirp'
('response_header', CLIENT_RESPONSE_HEADER),
('entities', RepeatedField(CLIENT_ENTITY)),
)
(None, Field()), # always 1? (advances_sort_timestamp?)
)
CLIENT_EVENT_NOTIFICATION = Message(
('event', CLIENT_EVENT),
is_optional=True,
)
CLIENT_WATERMARK_NOTIFICATION = Message(
('participant_id', USER_ID),
('conversation_id', CONVERSATION_ID),
('latest_read_timestamp', Field()),
is_optional=True,
)
CLIENT_STATE_UPDATE_HEADER = Message(
('active_client_state', EnumField(ActiveClientState)),
(None, Field(is_optional=True)),
('request_trace_id', Field()),
(None, Field(is_optional=True)),
('current_server_time', Field()),
(None, Field(is_optional=True)),
(None, Field(is_optional=True)),
# optional ID of the client causing the update?
(None, Field(is_optional=True)),
)
CLIENT_STATE_UPDATE = Message(
('state_update_header', CLIENT_STATE_UPDATE_HEADER),
('conversation_notification', Field(is_optional=True)), # always None?
('event_notification', CLIENT_EVENT_NOTIFICATION),
('focus_notification', CLIENT_SET_FOCUS_NOTIFICATION),
('type_', RepeatedField(Field())),
('data', Field()), # can be a dict
)),
)
CLIENT_CHAT_MESSAGE = Message(
(None, Field(is_optional=True)), # always None?
('annotation', RepeatedField(Field(), is_optional=True)),
('message_content', Message(
('segment', RepeatedField(MESSAGE_SEGMENT, is_optional=True)),
('attachment', RepeatedField(MESSAGE_ATTACHMENT, is_optional=True)),
)),
is_optional=True,
)
CLIENT_CONVERSATION_RENAME = Message(
('new_name', Field()),
('old_name', Field()),
is_optional=True,
)
CLIENT_HANGOUT_EVENT = Message(
('event_type', EnumField(ClientHangoutEventType)),
('participant_id', RepeatedField(USER_ID)),
('hangout_duration_secs', Field(is_optional=True)),
('transferred_conversation_id', Field(is_optional=True)), # always None?
('refresh_timeout_secs', Field(is_optional=True)),
('is_periodic_refresh', Field(is_optional=True)),
(None, Field(is_optional=True)), # always 1?
is_optional=True,
)
('old_name', Field()),
is_optional=True,
)
CLIENT_HANGOUT_EVENT = Message(
('event_type', EnumField(ClientHangoutEventType)),
('participant_id', RepeatedField(USER_ID)),
('hangout_duration_secs', Field(is_optional=True)),
('transferred_conversation_id', Field(is_optional=True)), # always None?
('refresh_timeout_secs', Field(is_optional=True)),
('is_periodic_refresh', Field(is_optional=True)),
(None, Field(is_optional=True)), # always 1?
is_optional=True,
)
CLIENT_OTR_MODIFICATION = Message(
('old_otr_status', EnumField(OffTheRecordStatus)),
('new_otr_status', EnumField(OffTheRecordStatus)),
('old_otr_toggle', EnumField(ClientOffTheRecordToggle)),
('new_otr_toggle', EnumField(ClientOffTheRecordToggle)),
is_optional=True,
)
CLIENT_MEMBERSHIP_CHANGE = Message(
('type_', EnumField(MembershipChangeType)),
(None, RepeatedField(Field())),
('participant_ids', RepeatedField(USER_ID)),
(None, Field()),
is_optional=True,
)
CLIENT_EVENT = Message(
(None, Field(is_optional=True)), # always None?
('group1', ENTITY_GROUP),
('group2', ENTITY_GROUP),
('group3', ENTITY_GROUP),
('group4', ENTITY_GROUP),
('group5', ENTITY_GROUP),
)
CLIENT_GET_SELF_INFO_RESPONSE = Message(
(None, Field()), # 'cgsirp'
(None, Field()), # response header
('self_entity', CLIENT_ENTITY),
)
CLIENT_RESPONSE_HEADER = Message(
('status', Field()), # 1 => success
(None, Field(is_optional=True)),
(None, Field(is_optional=True)),
('request_trace_id', Field()),
('current_server_time', Field()),
)
CLIENT_SYNC_ALL_NEW_EVENTS_RESPONSE = Message(
(None, Field()), # 'csanerp'
('response_header', CLIENT_RESPONSE_HEADER),
('sync_timestamp', Field()),
('conversation_state', RepeatedField(CLIENT_CONVERSATION_STATE)),
)
CLIENT_GET_CONVERSATION_RESPONSE = Message(
(None, Field()), # 'cgcrp'
('old_otr_status', EnumField(OffTheRecordStatus)),
('new_otr_status', EnumField(OffTheRecordStatus)),
('old_otr_toggle', EnumField(ClientOffTheRecordToggle)),
('new_otr_toggle', EnumField(ClientOffTheRecordToggle)),
is_optional=True,
)
CLIENT_MEMBERSHIP_CHANGE = Message(
('type_', EnumField(MembershipChangeType)),
(None, RepeatedField(Field())),
('participant_ids', RepeatedField(USER_ID)),
(None, Field()),
is_optional=True,
)
CLIENT_EVENT = Message(
('conversation_id', CONVERSATION_ID),
('sender_id', OPTIONAL_USER_ID),
('timestamp', Field()),
('self_event_state', Message(
('user_id', USER_ID),
('client_generated_id', Field(is_optional=True)),
('notification_level', EnumField(ClientNotificationLevel)),
is_optional=True,
)),
(None, Field(is_optional=True)), # always None?
(None, Field(is_optional=True)), # always 0? (expiration_timestamp?)
('chat_message', CLIENT_CHAT_MESSAGE),
(None, Field(is_optional=True)), # always None?
('membership_change', CLIENT_MEMBERSHIP_CHANGE),
('conversation_rename', CLIENT_CONVERSATION_RENAME),
('hangout_event', CLIENT_HANGOUT_EVENT),
"""Active client state."""
NO_ACTIVE_CLIENT = 0
IS_ACTIVE_CLIENT = 1
OTHER_CLIENT_IS_ACTIVE = 2
##############################################################################
# pblite Messages
##############################################################################
CONVERSATION_ID = Message(
('id_', Field()),
)
USER_ID = Message(
('gaia_id', Field()),
('chat_id', Field()),
)
OPTIONAL_USER_ID = Message(
('gaia_id', Field()),
('chat_id', Field()),
is_optional=True,
)
CLIENT_SET_TYPING_NOTIFICATION = Message(
('conversation_id', CONVERSATION_ID),
('user_id', USER_ID),
('timestamp', Field()),
('status', EnumField(TypingStatus)),
is_optional=True,
class ActiveClientState(enum.Enum):
"""Active client state."""
NO_ACTIVE_CLIENT = 0
IS_ACTIVE_CLIENT = 1
OTHER_CLIENT_IS_ACTIVE = 2
##############################################################################
# pblite Messages
##############################################################################
CONVERSATION_ID = Message(
('id_', Field()),
)
USER_ID = Message(
('gaia_id', Field()),
('chat_id', Field()),
)
OPTIONAL_USER_ID = Message(
('gaia_id', Field()),
('chat_id', Field()),
is_optional=True,
)
CLIENT_SET_TYPING_NOTIFICATION = Message(
('conversation_id', CONVERSATION_ID),
('type_', EnumField(SegmentType)),
('text', Field(is_optional=True)), # Can be None for linebreaks
('formatting', Message(
('bold', Field(is_optional=True)),
('italic', Field(is_optional=True)),
('strikethrough', Field(is_optional=True)),
('underline', Field(is_optional=True)),
is_optional=True,
)),
('link_data', Message(
('link_target', Field(is_optional=True)),
is_optional=True,
)),
)
MESSAGE_ATTACHMENT = Message(
('embed_item', Message(
# 249 (PLUS_PHOTO), 340, 335, 0
('type_', RepeatedField(Field())),
('data', Field()), # can be a dict
)),
)
CLIENT_CHAT_MESSAGE = Message(
(None, Field(is_optional=True)), # always None?
('annotation', RepeatedField(Field(), is_optional=True)),
('message_content', Message(
('segment', RepeatedField(MESSAGE_SEGMENT, is_optional=True)),
('attachment', RepeatedField(MESSAGE_ATTACHMENT, is_optional=True)),
)),
is_optional=True,
)