Referencia de la API

Chat

Consultar app.capabilities para comprobar la compatibilidad de funciones y app.access junto con los permisos del anfitrión para la autorización. Los ejemplos usan valores sintéticos; sustituir las rutas, ID, entradas y filtros antes de llamar.

Definiciones de tipos

graphql
type Mutation {
  deleteChatItem(id: ID!): Boolean!
  deleteChatItems(query: String!): ActionResult!
  editChatText(id: ID!, text: String!): ChatTextEdit!
  forwardChatItems(id: ID!, targets: [String!]!, note: String): [ChatItem!]!
  retryChatItem(id: ID!, recipientIds: [ID!]): ChatItem!
  sendChatItems(targets: [String!]!, content: ChatContentInput!): [ChatItem!]!
  sendFolderShare(targets: [String!]!, path: String!, name: String!, expiresAt: Instant): [ChatItem!]!
  sendShare(targets: [String!]!, shareId: ID!): [ChatItem!]!
}

type Query {
  chatConversations: [ChatConversation!]!
  chatCount(query: String!): Int!
  chatItem(id: ID!): ChatItem
  chatItems(target: String!, query: String!, offset: Int!, limit: Int!): [ChatItem!]!
  chatRecords(query: String!, offset: Int!, limit: Int!): [ChatItem!]!
}

type Subscription {
  messagesCreated: [ChatItem!]!
  messagesUpdated: [ChatItem!]!
  messagesDeleted: String!
}

type ActionResult {
	affectedCount: Int!
}

type ChatAttachment {
	id: ID!
	uri: String!
	size: Long!
	durationMs: Long!
	width: Int!
	height: Int!
	summary: String!
	fileName: String!
}

input ChatAttachmentInput {
	id: ID!
	uri: String!
	size: Long!
	durationMs: Long! = 0
	width: Int! = 0
	height: Int! = 0
	summary: String! = ""
	fileName: String! = ""
}

enum ChatAttachmentType {
	IMAGE
	FILE
}

union ChatContent = ChatMessageContent | ChatShareContent

input ChatContentInput @oneOf {
	message: ChatMessageInput
	share: ChatShareInput
}

type ChatConversation {
	id: ID!
	chat: ChatItem!
}

type ChatDeliveryResult {
	peerId: ID!
	peerName: String!
	error: String
}

type ChatItem {
	
	fromId: ID!
	
	toId: ID!
	
	channelId: ID
	id: ID!
	content: ChatContent!
	createdAt: Instant!
	updatedAt: Instant!
	status: ChatStatus!
	deliveryResults: [ChatDeliveryResult!]!
}

type ChatLinkPreview {
	url: String!
	title: String
	description: String
	image: String
	imageWidth: Int!
	imageHeight: Int!
	siteName: String
	domain: String
	createdAt: Instant!
}

type ChatMessageAttachment {
	type: ChatAttachmentType!
	attachment: ChatAttachment!
}

input ChatMessageAttachmentInput {
	type: ChatAttachmentType!
	attachment: ChatAttachmentInput!
}

type ChatMessageContent {
	text: String
	format: ChatTextFormat!
	items: [ChatMessageAttachment!]!
	linkPreviews: [ChatLinkPreview!]!
}

input ChatMessageInput {
	text: String
	format: ChatTextFormat! = PLAIN
	items: [ChatMessageAttachmentInput!]! = []
}

type ChatShareContent {
	shareId: ID!
	urlToken: String!
	peerInfo: ChatSharePeer!
	name: String!
	itemCount: Long!
	totalSize: Long!
	expiresAt: Instant
}

input ChatShareInput {
	shareId: ID!
	urlToken: String!
	peerInfo: ChatSharePeerInput!
	name: String!
	itemCount: Long! = 0
	totalSize: Long! = 0
	expiresAt: Instant
}

type ChatSharePeer {
	id: ID!
	ip: String!
	port: Int!
}

input ChatSharePeerInput {
	id: ID!
	ip: String!
	port: Int!
}

enum ChatStatus {
	SENT
	FAILED
	PARTIAL
	PENDING
}

type ChatTextEdit {
	changed: Boolean!
	chat: ChatItem!
}

enum ChatTextFormat {
	PLAIN
	MARKDOWN
}

scalar Instant

scalar Long

Operaciones

mutation

deleteChatItem

Eliminar un mensaje de chat por su ID.

graphql
# Always true: an id that is already gone is the state the caller asked
# for, and the contract has no way to say "nothing was there".
mutation deleteChatItem($id: ID!) {
  deleteChatItem(id: $id)
}
mutation

deleteChatItems

Eliminar en bloque mensajes de chat que coincidan con una consulta (p. ej., "id:msg_x,id:msg_y").

graphql
mutation deleteChatItems($query: String!) {
  deleteChatItems(query: $query) { affectedCount }
}
mutation

editChatText

Editar el texto de un mensaje de chat existente y devolver el resultado de la edición.

graphql
mutation editChatText($id: ID!, $text: String!) {
  editChatText(id: $id, text: $text) { changed }
}
mutation

forwardChatItems

Reenvía el contenido original sin cambios y luego envía la nota opcional como mensaje de texto plano separado a cada destino. Cada elemento devuelto tiene su propio estado de entrega.

graphql
mutation forwardChatItems($id: ID!, $targets: [String!]!, $note: String) {
  forwardChatItems(id: $id, targets: $targets, note: $note) { id status deliveryResults { peerId peerName error } content { __typename ... on ChatMessageContent { text format } } }
}
mutation

retryChatItem

Reintenta el envío. Solo se pueden indicar destinatarios para mensajes de canal.

graphql
mutation retryChatItem($id: ID!, $recipientIds: [ID!]) {
  retryChatItem(id: $id, recipientIds: $recipientIds) { fromId toId channelId id createdAt updatedAt status }
}
mutation

sendChatItems

Envía un mensaje a uno o más destinos mediante peer:example-id o channel:example-id.

graphql
mutation sendChatItems($targets: [String!]!, $content: ChatContentInput!) {
  sendChatItems(targets: $targets, content: $content) { fromId toId channelId id createdAt updatedAt status }
}
mutation

sendFolderShare

Crear un recurso compartido de carpeta y enviar su tarjeta a los destinos de chat seleccionados.

graphql
mutation sendFolderShare($targets: [String!]!, $path: String!, $name: String!, $expiresAt: Instant) {
  sendFolderShare(targets: $targets, path: $path, name: $name, expiresAt: $expiresAt) { fromId toId channelId id createdAt updatedAt status }
}
mutation

sendShare

Enviar la tarjeta de un recurso compartido existente a los destinos de chat seleccionados.

graphql
mutation sendShare($targets: [String!]!, $shareId: ID!) {
  sendShare(targets: $targets, shareId: $shareId) { fromId toId channelId id createdAt updatedAt status }
}
query

chatConversations

Listar las conversaciones de chat con resúmenes de sus mensajes más recientes.

graphql
query chatConversations {
  chatConversations { id }
}
query

chatCount

Contar los mensajes de chat almacenados que coincidan con la consulta.

graphql
query chatCount($query: String!) {
  chatCount(query: $query)
}
query

chatItem

Consultar un mensaje de chat almacenado por ID; devolver null si no existe.

graphql
query chatItem($id: ID!) {
  chatItem(id: $id) { fromId toId channelId id createdAt updatedAt status }
}
query

chatItems

Obtener todos los mensajes de una conversación. Añadir al id el prefijo "channel:" o "peer:".

graphql
# Messages in chronological order; `target`: `peer:<id>` or `channel:<id>`.
query chatItems($target: String!, $query: String!, $offset: Int!, $limit: Int!) {
  chatItems(target: $target, query: $query, offset: $offset, limit: $limit) { fromId toId channelId id createdAt updatedAt status }
}
query

chatRecords

Buscar mensajes de chat almacenados con paginación.

graphql
query chatRecords($query: String!, $offset: Int!, $limit: Int!) {
  chatRecords(query: $query, offset: $offset, limit: $limit) { fromId toId channelId id createdAt updatedAt status }
}
subscription

messagesCreated

Recibir los mensajes de chat recién almacenados.

graphql
subscription messagesCreated {
  messagesCreated { fromId toId channelId id createdAt updatedAt status }
}
subscription

messagesUpdated

Recibir actualizaciones de los mensajes de chat almacenados.

graphql
subscription messagesUpdated {
  messagesUpdated { fromId toId channelId id createdAt updatedAt status }
}
subscription

messagesDeleted

Recibir una notificación de eliminación de un mensaje de chat.

graphql
subscription messagesDeleted {
  messagesDeleted
}