Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/pages/docs/chat/rooms/messages.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,50 @@ room.messages.send(text = "hello")
```
</Code>

## Get a single message <a id="get-by-serial"/>

<If lang="javascript,swift,kotlin">
Use the <If lang="javascript">[`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Messages.html#get)</If><If lang="swift">[`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-swift/main/AblyChat/documentation/ablychat/messages/get%28serial%3A%29)</If><If lang="kotlin">[`messages.get()`](https://sdk.ably.com/builds/ably/ably-chat-kotlin/main/dokka/chat-android/com.ably.chat/-messages/get.html)</If> method to get a message in a chat room.
</If>

<If lang="react">
Use the [`getMessage()`](https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-react.UseMessagesResponse.html#getMessage) method available from the response of the `useMessages` hook to send a message to the room:
</If>

<Code>
```javascript
await room.messages.get(serial);
```

```react
import { useMessages } from '@ably/chat/react';

const MyComponent = () => {
const { getMessage } = useMessages();

const handleMessageSend = () => {
getMessage(serial);
};

return (
<div>
<button onClick={handleMessageSend}>Send Message</button>
</div>
);
};
```

```swift
let message = try await room.messages.get(serial: serial)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does swift already have this functionality? Or will there be a delay between js and other SDKs? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're not. I don't remember why I let those be here (LLM generated for sure). Maybe we can get an estimate and leave this PR open until they actually get implemented?

```

```kotlin
room.messages.get(serial = serial)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for kotlin, is this method actually in yet?

```
</Code>



## Update a message <a id="update"/>

<Aside data-type='new'>
Expand Down
79 changes: 79 additions & 0 deletions static/open-specs/chat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,85 @@ paths:
statusCode: 500
href: "https://help.ably.io/error/50001"
/chat/{version}/rooms/{roomName}/messages/{serial}:
get:
summary: Retrieve a single message from a room
description: |
Fetches a single message from a specified room.
tags:
- rooms
parameters:
- name: version
in: path
required: true
description: The version of the Chat API endpoint to use.
schema:
type: string
example: v3
- name: roomName
in: path
required: true
description: The unique identifier of the room to fetch messages from. The `roomName` must be URI-encoded.
schema:
type: string
- name: serial
in: path
required: true
description: The unique identifier of the message to fetch. The `serial` must be URI-encoded.
schema:
type: string
example: "01826232498871-001@abcdefghij:001"
- $ref: '#/components/parameters/ClientIdHeader'
- $ref: '#/components/parameters/AuthorizationHeader'
- $ref: '#/components/parameters/AcceptHeader'
responses:
'200':
description: A single message retrieved from the room.
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
'400':
description: Invalid request.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInfo'
'401':
description: Unauthorized access.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInfo'
example:
error:
message: "Unauthorized access."
code: 40005
statusCode: 401
href: "https://help.ably.io/error/40101"
'404':
description: Message not found.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInfo'
example:
error:
message: "Message not found."
code: 40400
statusCode: 404
href: "https://help.ably.io/error/40401"
'500':
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorInfo'
example:
error:
message: "Internal server error."
code: 50001
statusCode: 500
href: "https://help.ably.io/error/50001"
put:
summary: Update a message in a room
description: |
Expand Down