Subscriptions

When some user belongs to some group, there is a subscription for it. Subscription connects user to a group, set access rights, hold private user settings toward the group, like muting notification and so on.

Subscription usage diagram

To better understan subscriptions role in unichat, see the diagram:

graph LR p2p(private chat) --> group room(room) --> group channel(channel)--> group group -.-> subscription1 group -.-> subscription2 group -.-> subscription3 subscription1 -.-> user1 subscription2 -.-> user2 user1 -.-> contact1 user1 -.-> contact2 user1 -.-> contact3 user2 -.-> contact4 user2 -.-> contact5 user2 -.-> contact6 contact4 -.-> user3 contact1 -.-> user3

Tags

Also, each user can tag own subscription with some tags. Tags are individual and independent, allowing each participant to mark some group the way she or he prefers. It means that one participant could tag his subscription to some group as 'work' and 'important', while another can tag her subscription to the same group as 'boring' and 'dontreadit'

subscription record

Subscription record include information about group and current user rights and reading state for it. In full form it contains also <group record> with participating users records:

{
  "subscription": {
    {
      "id": 1958,
      "group_id": 252,
      "user_id": 1508,
      "role": "rw",
      "mute_until": null,
      "draft": null,
      "tags": null,
      "last_read_message_id": null,
      "created_at": "2018-10-16T18:03:27Z",
      "group": {
        "id": 252,
        "name": null,
        "is_deleted": false,
        "is_space": false,
        "created_at": "2018-10-16 18:03:27 UTC",
        "updated_at": "2018-10-16 18:03:27 UTC",
        "last_message_id": null,
        "last_serial": null,
        "strid": "p2p:1508:1509",
        "type": "private_chat",
        "participants": [
          {
            "id": 1958,
            "group_id": 252,
            "user_id": 1508,
            "role": "rw",
            "mute_until": null,
            "draft": null,
            "last_read_message_id": null,
            "created_at": "2018-10-16T18:03:27Z",
            "user": {
              "id": 1508,
              "nick": "test_user_2",
              "is_online":true
            }
          },
          {
            "id": 1959,
            "group_id": 252,
            "user_id": 1509,
            "role": "rw",
            "mute_until": null,
            "draft": null,
            "last_read_message_id": null,
            "created_at": "2018-10-16T18:03:27Z",
            "user": {
              "id": 1509,
              "nick": "test_user_3",
              "is_online":false
            }
          }
        ]
      },
      "user": {
        "id": 1508,
        "nick": "test_user_2"
      }
    }
  ]
}

in short form. group object will not be included. It can be requireset separately.

Note that tags field if exists, contain array of strings. This field is shown to the subscription owner only.