Chat
Gestiona mensajes de chat locales, canales y peers emparejados. Todas las operaciones GraphQL se envían a POST /graphql.
Definiciones de tipos
type ChatItem {
id: ID!
fromId: String! # "me" | peerId
toId: String! # peerId (direct) | "" (channel)
channelId: String! # "" for direct messages
content: String! # JSON-encoded message payload
createdAt: String! # ISO 8601
updatedAt: String!
status: String! # "sent" | "pending" | "failed"
statusData: String! # extra info on failure
}
type ChatChannel {
id: String!
name: String!
owner: String! # "me" | peerId
members: [ChatChannelMember!]!
version: Int!
status: String! # "active" | "left"
createdAt: String!
updatedAt: String!
}
type ChatChannelMember {
id: String!
status: String! # "active" | "pending"
}
type Peer {
id: String!
name: String!
ip: String!
status: String! # "online" | "offline"
port: Int!
deviceType: String! # "phone" | "tablet" | "pc"
createdAt: String!
updatedAt: String!
}
type AppFile {
id: ID!
size: Int! # bytes
mimeType: String!
realPath: String!
fileName: String!
createdAt: String!
updatedAt: String!
}Operaciones
chatItems
Obtiene todos los mensajes de una conversación. Antepón "channel:" o "peer:" al id.
query GetChatItems($id: String!) {
chatItems(id: $id) {
id fromId toId channelId
content createdAt updatedAt status statusData
}
}latestChatItems
Obtiene el último mensaje de cada conversación (canales + peers). Útil para construir una vista previa de la lista de conversaciones.
query GetLatestChatItems {
latestChatItems {
id fromId toId channelId content createdAt updatedAt status
}
}chatChannels
Lista todos los canales de chat propiedad del dispositivo o a los que se ha unido.
query GetChatChannels {
chatChannels {
id name owner version status createdAt updatedAt
members { id status }
}
}peers
Lista todos los peers conocidos que se han emparejado con este dispositivo.
query GetPeers {
peers { id name ip status port deviceType createdAt updatedAt }
}deletePeer
Elimina un registro de peer de este dispositivo. No desempareja en el lado remoto; usa unpairPeer para un desemparejamiento limpio bilateral.
mutation DeletePeer($id: ID!) {
deletePeer(id: $id)
}unpairPeer
Desempareja un dispositivo peer. Limpia el estado de emparejamiento en este dispositivo y señaliza al peer remoto cuando es alcanzable.
mutation UnpairPeer($id: ID!) {
unpairPeer(id: $id)
}appFiles
Lista paginada de archivos compartidos a través del chat.
query GetAppFiles($offset: Int!, $limit: Int!) {
appFiles(offset: $offset, limit: $limit) {
id size mimeType realPath fileName createdAt updatedAt
}
}appFileCount
Conteo total de archivos compartidos a través del chat.
query GetAppFileCount {
appFileCount
}sendChatItem
Envía un mensaje a un canal o peer. Formato de toId: "channel:<id>" o "peer:<id>".
mutation SendChatItem($toId: String!, $content: String!) {
sendChatItem(toId: $toId, content: $content) {
id fromId toId channelId content createdAt updatedAt status
}
}deleteChatItem
Elimina un mensaje de chat por ID.
mutation DeleteChatItem($id: ID!) {
deleteChatItem(id: $id)
}deleteChatItems
Borrado masivo de mensajes de chat que coinciden con una consulta (p. ej. "id:msg_x,id:msg_y").
mutation DeleteChatItems($query: String!) {
deleteChatItems(query: $query)
}retryChatItem
Reintenta el envío de un mensaje fallido.
mutation RetryChatItem($id: ID!) {
retryChatItem(id: $id) { id status }
}createChatChannel
Crea un nuevo canal cifrado propiedad de este dispositivo.
mutation CreateChatChannel($name: String!) {
createChatChannel(name: $name) {
id name owner version status createdAt
}
}updateChatChannel
Renombra un canal de chat.
mutation UpdateChatChannel($id: ID!, $name: String!) {
updateChatChannel(id: $id, name: $name) { id name version updatedAt }
}deleteChatChannel
Elimina un canal y todos sus mensajes.
mutation DeleteChatChannel($id: ID!) {
deleteChatChannel(id: $id)
}leaveChatChannel
Abandona un canal del que no eres propietario.
mutation LeaveChatChannel($id: ID!) {
leaveChatChannel(id: $id)
}addChatChannelMember
Invita a un peer a un canal de tu propiedad.
mutation AddMember($id: ID!, $peerId: String!) {
addChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}removeChatChannelMember
Elimina a un miembro de un canal de tu propiedad.
mutation RemoveMember($id: ID!, $peerId: String!) {
removeChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}acceptChatChannelInvite
Acepta una invitación para unirte a un canal al que fuiste invitado.
mutation AcceptChatChannelInvite($id: ID!) {
acceptChatChannelInvite(id: $id)
}declineChatChannelInvite
Rechaza una invitación de canal pendiente.
mutation DeclineChatChannelInvite($id: ID!) {
declineChatChannelInvite(id: $id)
}