# Stream message

> **Info:** This is release candidate documentation for **Stream Chat Angular SDK v8**. For the latest stable version, see the [latest version (v7)](https://getstream.io/chat/docs/sdk/angular/).

The [`StreamMessage`](https://github.com/GetStream/stream-chat-angular/blob/master/projects/stream-chat-angular/src/lib/types.ts) type represents a chat message.

The type is based on the `LocalMessage` type of `stream-chat` (the Stream [message](https://getstream.io/chat/docs/javascript/send-message/#message-response-structure) format with a `status` field), and it adds the following properties:

| Name              | Type                                         | Description                                                                                                                   |
| ----------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `readBy`          | `UserResponse[]`                             | The list of members that read the message, excluding the sender (includes up to 100 members, always empty for thread replies) |
| `translation`     | `string` (optional)                          | The message translation if message was translated with [auto-translation](https://getstream.io/chat/docs/javascript/translation/)                 |
| `errorStatusCode` | `number` (optional)                          | The HTTP status code of the error if sending the message failed                                                               |
| `quoted_message`  | `MessageResponse & { translation?: string }` | The quoted message, with its translation                                                                                      |

## Date fields

The SDK doesn't convert the date fields of messages, they use the same format as `stream-chat`: `TimestampNS` (unix nanoseconds, a branded `number`).

| Name                      | Type                       |
| ------------------------- | -------------------------- |
| `created_at`              | `TimestampNS`              |
| `updated_at`              | `TimestampNS`              |
| `deleted_at`              | `TimestampNS \| undefined` |
| `pinned_at`               | `TimestampNS \| undefined` |
| `pin_expires`             | `TimestampNS \| undefined` |
| `message_text_updated_at` | `TimestampNS \| undefined` |

Optional date fields are `undefined` (never `null`) if they aren't set. To get a `Date`, use the `nsToDate` helper exported by `stream-chat` (and `dateToNs` for the other direction). Don't pass a `TimestampNS` to `new Date()` or Angular's `date` pipe: both treat numbers as milliseconds.

## Custom fields

Custom message fields are stored under `message.custom` (for example `message.custom.priority`). To type them, see [custom types](https://getstream.io/chat/docs/sdk/angular/v8/concepts/custom-types/).

## Moderation

The moderation result of a message is available in `message.moderation` (for example, `message.moderation?.action` is `'bounce'` for bounced and `'remove'` for blocked messages).

## Example

Reading the messages of the active channel:

```ts
import { nsToDate } from "stream-chat";

this.channelService.activeChannelMessages$.subscribe((messages) => {
  const message = messages[messages.length - 1];
  if (message) {
    console.log(
      nsToDate(message.created_at).toISOString(),
      message.readBy.map((u) => u.id),
      message.custom,
      message.moderation?.action,
    );
  }
});
```

---

For the most recent version of this documentation, visit [https://getstream.io/chat/docs/sdk/angular/v8/types/stream-message/](https://getstream.io/chat/docs/sdk/angular/v8/types/stream-message/).