チャット
機能の対応状況は app.capabilities、認可は app.access とホストの権限で確認してください。例は合成値を使用しています。呼び出す前にパス、ID、入力、フィルターを置き換えてください。
型定義
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操作
deleteChatItem
ID を指定してチャットメッセージを削除します。
# 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)
}deleteChatItems
クエリ(例:"id:msg_x,id:msg_y")に一致するチャットメッセージを一括削除します。
mutation deleteChatItems($query: String!) {
deleteChatItems(query: $query) { affectedCount }
}editChatText
既存チャットメッセージのテキストを編集し、編集結果を返します。
mutation editChatText($id: ID!, $text: String!) {
editChatText(id: $id, text: $text) { changed }
}forwardChatItems
元の内容を変更せずに転送し、その後、対象ごとに任意のメモを別のプレーンテキストメッセージとして送信します。返される各項目には個別の配信ステータスがあります。
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 } } }
}retryChatItem
メッセージを再送します。宛先を指定できるのはチャネルメッセージのみです。
mutation retryChatItem($id: ID!, $recipientIds: [ID!]) {
retryChatItem(id: $id, recipientIds: $recipientIds) { fromId toId channelId id createdAt updatedAt status }
}sendChatItems
peer:example-id または channel:example-id を使って、1 件以上の宛先にメッセージを送信します。
mutation sendChatItems($targets: [String!]!, $content: ChatContentInput!) {
sendChatItems(targets: $targets, content: $content) { fromId toId channelId id createdAt updatedAt status }
}chatConversations
最新メッセージの要約付きでチャット会話を一覧表示します。
query chatConversations {
chatConversations { id }
}chatCount
クエリに一致する保存済みチャットメッセージ数を数えます。
query chatCount($query: String!) {
chatCount(query: $query)
}chatItem
ID を指定して保存済みチャットメッセージを 1 件読み取り、存在しない場合は null を返します。
query chatItem($id: ID!) {
chatItem(id: $id) { fromId toId channelId id createdAt updatedAt status }
}chatItems
会話内のすべてのメッセージを取得します。id の前に "channel:" または "peer:" を付けてください。
# 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 }
}chatRecords
保存済みチャットメッセージをページ単位で検索します。
query chatRecords($query: String!, $offset: Int!, $limit: Int!) {
chatRecords(query: $query, offset: $offset, limit: $limit) { fromId toId channelId id createdAt updatedAt status }
}messagesCreated
新しく保存されたチャットメッセージを受信します。
subscription messagesCreated {
messagesCreated { fromId toId channelId id createdAt updatedAt status }
}messagesUpdated
保存済みチャットメッセージの更新を受信します。
subscription messagesUpdated {
messagesUpdated { fromId toId channelId id createdAt updatedAt status }
}messagesDeleted
チャットメッセージの削除通知を受信します。
subscription messagesDeleted {
messagesDeleted
}