# Introduction

## User conversations access

The user can access [Conversations](doc-341717#conversation-model) 
(and [Message](doc-341717#message-model) within them) that user participates in, in other words those that:

  * are authored by him
  * are sent to `audience_ids` that user belongs to
  * are sent to `user_ids` that contain user's ID

## Conversation model

### Example

```json
{
  "conversation": {
    "id": 1,
    "author_id": "7db2c508-1758-4b84-bb68-50b5c8e1f458",
    "audience_ids": [15],
    "unseen_messages_count": 0,
    "user_ids": ["7d503e59-18f2-4028-95fc-177fa25820c8"],
    "created_at": "2022-05-10T09:01:27.415094Z",
    "updated_at": "2022-05-10T09:01:27.415094Z"
  }
}

```

### Definition

Key | Type      | Readonly? | Mandatory?     | Description
--------- |-----------|----------- |----------------| ---------
id | integer   | yes  | yes            | 
author_id | UUID      | yes       | yes            | IDs of user that started the conversation
audience_ids | integer[] | no        | no<sup>1</sup> | Audience which members are participants of the conversation
unseen_messages_count | integer | yes | no   | count of user unseen messages in the conversation
user_ids | UUID[]    | no        | no<sup>1</sup>             | IDs of users which are participants of the conversation
created_at | datetime  | yes       | yes            | Time of creation    
updated_at | datetime  | yes       | yes            | Time of last update 

<sup>1</sup> At least one is required

### Message model

### Example

```json
{
  "id": 3,
  "author_id": "7db2c508-1758-4b84-bb68-50b5c8e1f458",
  "content": "Hello *there*",
  "seen": true,
  "created_at": "2022-05-10T09:42:15.861021Z",
  "updated_at": "2022-05-10T09:42:15.861021Z"
}

```

### Definition

Key | Type     | Readonly? | Mandatory? | Description
--------- |----------|----------- |------------| ---------
id | integer  | yes  | yes        |
author_id | UUID     | yes       | yes        | ID of user that sent the message
content | string      | no        | yes          |
seen       | boolean  | yes       | no         | States whether the user has seen this message
created_at | datetime | yes       | yes        | Time of creation
updated_at | datetime | yes       | yes        | Time of last update