Tham chiếu API

Trò chuyện

Kiểm tra app.capabilities để biết tính năng và app.access cùng quyền máy chủ để xác định quyền truy cập. Thay giá trị mẫu trước khi gọi.

Định nghĩa kiểu

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

Thao tác

mutation

deleteChatItem

Xóa thông điệp trò chuyện theo 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

Xóa hàng loạt thông điệp trò chuyện khớp truy vấn (ví dụ "id:msg_x,id:msg_y").

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

editChatText

Sửa văn bản thông điệp trò chuyện hiện có và trả về kết quả sửa.

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

forwardChatItems

Chuyển tiếp nguyên nội dung gốc, sau đó gửi ghi chú tùy chọn dưới dạng tin nhắn văn bản thuần riêng cho từng đích. Mỗi mục trả về có trạng thái gửi riêng.

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

Thử gửi lại tin nhắn. Chỉ có thể chỉ định người nhận cho tin nhắn trong kênh.

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

sendChatItems

Gửi tin nhắn đến một hoặc nhiều đích bằng peer:example-id hoặc channel:example-id.

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

sendFolderShare

Tạo chia sẻ thư mục và gửi thẻ chia sẻ đến các đích trò chuyện đã chọn.

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

Gửi thẻ của chia sẻ hiện có đến các đích trò chuyện đã chọn.

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

chatConversations

Liệt kê hội thoại cùng tóm tắt thông điệp mới nhất.

graphql
query chatConversations {
  chatConversations { id }
}
query

chatCount

Đếm thông điệp trò chuyện đã lưu khớp truy vấn.

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

chatItem

Đọc một thông điệp trò chuyện đã lưu theo ID; trả về null nếu không có.

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

chatItems

Lấy mọi thông điệp trong hội thoại. Thêm tiền tố "channel:" hoặc "peer:" vào id.

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

Tìm thông điệp trò chuyện đã lưu có phân trang.

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

Nhận thông điệp trò chuyện mới được lưu.

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

messagesUpdated

Nhận cập nhật thông điệp trò chuyện đã lưu.

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

messagesDeleted

Nhận thông báo xóa thông điệp trò chuyện.

graphql
subscription messagesDeleted {
  messagesDeleted
}