|
|
@@ -112,10 +112,14 @@ type Room struct {
|
|
|
Name string `json:"name"`
|
|
|
Description string `json:"description,omitempty"`
|
|
|
Archived bool `json:"archived,omitempty"`
|
|
|
- GroupID string `json:"group_id,omitempty"`
|
|
|
+ GroupID string `json:"groupId,omitempty"`
|
|
|
Universal bool `json:"universal,omitempty"`
|
|
|
}
|
|
|
|
|
|
+type roomWithViewerState struct {
|
|
|
+ Room Room `json:"room"`
|
|
|
+}
|
|
|
+
|
|
|
type listRoomsRequest struct {
|
|
|
Page *pageRequest `json:"page,omitempty"`
|
|
|
}
|
|
|
@@ -125,40 +129,44 @@ type pageRequest struct {
|
|
|
}
|
|
|
|
|
|
type listRoomsResponse struct {
|
|
|
- Rooms []Room `json:"rooms"`
|
|
|
+ Rooms []roomWithViewerState `json:"rooms"`
|
|
|
Page struct {
|
|
|
- TotalCount int64 `json:"total_count"`
|
|
|
- HasMore bool `json:"has_more"`
|
|
|
+ TotalCount int64 `json:"totalCount,string"`
|
|
|
+ HasMore bool `json:"hasMore"`
|
|
|
} `json:"page"`
|
|
|
}
|
|
|
|
|
|
// ListRooms returns rooms visible to the token's user (single page, up to 100).
|
|
|
func (c *Client) ListRooms(ctx context.Context) ([]Room, error) {
|
|
|
- resp, err := call[struct{}, listRoomsResponse](ctx, c,
|
|
|
- "RoomDirectoryService", "ListRooms", &struct{}{})
|
|
|
+ resp, err := call[listRoomsRequest, listRoomsResponse](ctx, c,
|
|
|
+ "RoomDirectoryService", "ListRooms", &listRoomsRequest{Page: &pageRequest{PageSize: 100}})
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
- return resp.Rooms, nil
|
|
|
+ rooms := make([]Room, 0, len(resp.Rooms))
|
|
|
+ for _, rw := range resp.Rooms {
|
|
|
+ rooms = append(rooms, rw.Room)
|
|
|
+ }
|
|
|
+ return rooms, nil
|
|
|
}
|
|
|
|
|
|
// --- MessageService ---
|
|
|
|
|
|
type Message struct {
|
|
|
- EventID string `json:"event_id"`
|
|
|
- RoomID string `json:"room_id"`
|
|
|
- ThreadRoot string `json:"thread_root_event_id,omitempty"`
|
|
|
- AuthorUserID string `json:"author_user_id,omitempty"`
|
|
|
- Body string `json:"body,omitempty"`
|
|
|
- CreatedAt string `json:"created_at,omitempty"`
|
|
|
+ EventID string `json:"id"`
|
|
|
+ RoomID string `json:"roomId"`
|
|
|
+ ThreadRoot string `json:"threadRootEventId,omitempty"`
|
|
|
+ AuthorID string `json:"actorId,omitempty"`
|
|
|
+ Body string `json:"body,omitempty"`
|
|
|
+ CreatedAt string `json:"createdAt,omitempty"`
|
|
|
}
|
|
|
|
|
|
type createMessageRequest struct {
|
|
|
- RoomID string `json:"room_id"`
|
|
|
+ RoomID string `json:"roomId"`
|
|
|
Body string `json:"body"`
|
|
|
- ThreadRootEventID string `json:"thread_root_event_id,omitempty"`
|
|
|
- InReplyTo string `json:"in_reply_to,omitempty"`
|
|
|
- AlsoSendToChannel bool `json:"also_send_to_channel,omitempty"`
|
|
|
+ ThreadRootEventID string `json:"threadRootEventId,omitempty"`
|
|
|
+ InReplyTo string `json:"inReplyTo,omitempty"`
|
|
|
+ AlsoSendToChannel bool `json:"alsoSendToChannel,omitempty"`
|
|
|
}
|
|
|
|
|
|
type createMessageResponse struct {
|
|
|
@@ -181,8 +189,8 @@ func (c *Client) CreateMessage(ctx context.Context, roomID, body string, threadR
|
|
|
}
|
|
|
|
|
|
type getMessageRequest struct {
|
|
|
- RoomID string `json:"room_id"`
|
|
|
- EventID string `json:"event_id"`
|
|
|
+ RoomID string `json:"roomId"`
|
|
|
+ EventID string `json:"eventId"`
|
|
|
}
|
|
|
|
|
|
type getMessageResponse struct {
|