71 lines
1.6 KiB
Plaintext
71 lines
1.6 KiB
Plaintext
syntax = "v1"
|
|
|
|
import "common.api"
|
|
|
|
type (
|
|
SessionIdReq {
|
|
Id int64 `path:"id"`
|
|
}
|
|
CreateGroupReq {
|
|
Name string `json:"name"`
|
|
Participants []int64 `json:"participants,optional"`
|
|
}
|
|
CreateDMReq {
|
|
TargetId int64 `json:"targetId"`
|
|
}
|
|
ChatSession {
|
|
Id int64 `json:"id"`
|
|
Type string `json:"type"`
|
|
Name string `json:"name"`
|
|
CreatorId int64 `json:"creatorId"`
|
|
Participants []int64 `json:"participants"`
|
|
LastMessage string `json:"lastMessage"`
|
|
LastMessageAt int64 `json:"lastMessageAt"`
|
|
CreatedAt int64 `json:"createdAt"`
|
|
}
|
|
ChatSessionListResp {
|
|
Items []ChatSession `json:"items"`
|
|
}
|
|
ChatMessage {
|
|
Id int64 `json:"id"`
|
|
SessionId int64 `json:"sessionId"`
|
|
SenderId int64 `json:"senderId"`
|
|
Type string `json:"type"`
|
|
Content string `json:"content"`
|
|
CreatedAt int64 `json:"createdAt"`
|
|
}
|
|
ChatMessageListResp {
|
|
Items []ChatMessage `json:"items"`
|
|
}
|
|
ListMessageReq {
|
|
SessionIdReq
|
|
PageReq
|
|
}
|
|
)
|
|
|
|
@server (
|
|
prefix: api/v1/chat
|
|
group: chat
|
|
)
|
|
service chat-api {
|
|
@doc "create group session"
|
|
@handler CreateGroup
|
|
post /sessions/group (CreateGroupReq) returns (ChatSession)
|
|
|
|
@doc "create dm session"
|
|
@handler CreateDM
|
|
post /sessions/dm (CreateDMReq) returns (ChatSession)
|
|
|
|
@doc "list user sessions"
|
|
@handler ListSessions
|
|
get /sessions (PageReq) returns (ChatSessionListResp)
|
|
|
|
@doc "get session detail"
|
|
@handler GetSession
|
|
get /sessions/:id (SessionIdReq) returns (ChatSession)
|
|
|
|
@doc "get message history"
|
|
@handler ListMessages
|
|
get /sessions/:id/messages (ListMessageReq) returns (ChatMessageListResp)
|
|
}
|