PlainApp
API 참조

채팅

기능 지원은 app.capabilities, 인가는 app.access와 호스트 권한으로 확인하세요. 예제는 합성 값을 사용합니다. 호출 전에 경로, ID, 입력, 필터를 바꾸세요.

타입 정의

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

작업

mutation

deleteChatItem

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

쿼리(예: "id:msg_x,id:msg_y")에 일치하는 채팅 메시지를 일괄 삭제합니다.

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

editChatText

기존 채팅 메시지의 텍스트를 편집하고 편집 결과를 반환합니다.

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

forwardChatItems

원본 내용을 변경하지 않고 전달한 뒤, 각 대상에게 선택 사항인 메모를 별도의 일반 텍스트 메시지로 보냅니다. 반환된 각 항목에는 고유한 전송 상태가 있습니다.

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

메시지를 다시 보냅니다. 수신자는 채널 메시지에서만 지정할 수 있습니다.

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

sendChatItems

peer:example-id 또는 channel:example-id로 한 곳 이상의 대상에 메시지를 보냅니다.

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

sendFolderShare

폴더 공유를 만들고 공유 카드를 선택한 채팅 대상에 보냅니다.

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

기존 공유 카드를 선택한 채팅 대상에 보냅니다.

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

chatConversations

최신 메시지 요약과 함께 채팅 대화를 나열합니다.

graphql
query chatConversations {
  chatConversations { id }
}
query

chatCount

쿼리에 일치하는 저장된 채팅 메시지 수를 셉니다.

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

chatItem

ID로 저장된 채팅 메시지 하나를 읽고 없으면 null을 반환합니다.

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

chatItems

대화의 모든 메시지를 가져옵니다. id 앞에 "channel:" 또는 "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

저장된 채팅 메시지를 페이지 단위로 검색합니다.

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

새로 저장된 채팅 메시지를 받습니다.

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

messagesUpdated

저장된 채팅 메시지의 업데이트를 받습니다.

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

messagesDeleted

채팅 메시지 삭제 알림을 받습니다.

graphql
subscription messagesDeleted {
  messagesDeleted
}