Chat
Gestisci messaggi chat locali, canali e peer abbinati. Tutte le operazioni GraphQL vengono inviate a POST /graphql.
Definizioni di tipo
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!
ownerId: ID! # "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!
}Operazioni
chatItems
Recupera tutti i messaggi di una conversazione. Anteponi "channel:" o "peer:" all'id.
query GetChatItems($id: String!) {
chatItems(id: $id) {
id fromId toId channelId
content createdAt updatedAt status statusData
}
}latestChatItems
Recupera l'ultimo messaggio di ogni conversazione (canali + peer). Utile per creare un'anteprima della lista conversazioni.
query GetLatestChatItems {
latestChatItems {
id fromId toId channelId content createdAt updatedAt status
}
}chatChannels
Elenca tutti i canali chat di proprietà del dispositivo o a cui si è unito.
query GetChatChannels {
chatChannels {
id name ownerId version status createdAt updatedAt
members { id status }
}
}peers
Elenca tutti i peer noti abbinati a questo dispositivo.
query GetPeers {
peers { id name ip status port deviceType createdAt updatedAt }
}deletePeer
Elimina un record peer da questo dispositivo. Non disassocia sul lato remoto; usa unpairPeer per un disaccoppiamento pulito su entrambi i lati.
mutation DeletePeer($id: ID!) {
deletePeer(id: $id)
}unpairPeer
Disassocia un dispositivo peer. Cancella lo stato di abbinamento su questo dispositivo e segnala il peer remoto quando raggiungibile.
mutation UnpairPeer($id: ID!) {
unpairPeer(id: $id)
}appFiles
Elenco paginato dei file condivisi tramite chat.
query GetAppFiles($offset: Int!, $limit: Int!) {
appFiles(offset: $offset, limit: $limit) {
id size mimeType realPath fileName createdAt updatedAt
}
}appFileCount
Conteggio totale dei file condivisi tramite chat.
query GetAppFileCount {
appFileCount
}sendChatItem
Invia un messaggio a un canale o a un peer. Formato di 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 messaggio di chat per ID.
mutation DeleteChatItem($id: ID!) {
deleteChatItem(id: $id)
}deleteChatItems
Elimina in massa i messaggi chat corrispondenti a una query (es. "id:msg_x,id:msg_y").
mutation DeleteChatItems($query: String!) {
deleteChatItems(query: $query)
}retryChatItem
Riprova a inviare un messaggio non riuscito.
mutation RetryChatItem($id: ID!) {
retryChatItem(id: $id) { id status }
}createChatChannel
Crea un nuovo canale cifrato di proprietà di questo dispositivo.
mutation CreateChatChannel($name: String!) {
createChatChannel(name: $name) {
id name ownerId version status createdAt
}
}updateChatChannel
Rinomina un canale chat.
mutation UpdateChatChannel($id: ID!, $name: String!) {
updateChatChannel(id: $id, name: $name) { id name version updatedAt }
}deleteChatChannel
Elimina un canale e tutti i suoi messaggi.
mutation DeleteChatChannel($id: ID!) {
deleteChatChannel(id: $id)
}leaveChatChannel
Lascia un canale di cui non sei proprietario.
mutation LeaveChatChannel($id: ID!) {
leaveChatChannel(id: $id)
}addChatChannelMember
Invita un peer in un canale di tua proprietà.
mutation AddMember($id: ID!, $peerId: String!) {
addChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}removeChatChannelMember
Rimuovi un membro da un canale di tua proprietà.
mutation RemoveMember($id: ID!, $peerId: String!) {
removeChatChannelMember(id: $id, peerId: $peerId) {
id members { id status }
}
}acceptChatChannelInvite
Accetta un invito a unirti a un canale a cui sei stato invitato.
mutation AcceptChatChannelInvite($id: ID!) {
acceptChatChannelInvite(id: $id)
}declineChatChannelInvite
Rifiuta un invito canale in sospeso.
mutation DeclineChatChannelInvite($id: ID!) {
declineChatChannelInvite(id: $id)
}