User Payload

User Payload

This section explains how you will generate the user payload string that will be used in Config initialization. User payload generation is accomplished with the following 2 steps:

Form Your User Data

The user payload must include the following fields in your data:

{
  "user_id": "string user id",
  "user_name": "string user name",
  "user_avatar_url": "string user avatar url",
  "user_followings": [
    "string user id 1",
    "string user id 2",
    "string user id 3"
  ],
  "user_creator_tags": [
    "string user creator tag 1",
    "string user creator tag 2",
    "string user creator tag 3"
  ],
  "user_consumer_tags": [
    "string user consumer tag 1",
    "string user consumer tag 2",
    "string user consumer tag 3"
  ],
  "expiration_time": integer timestamp in miliseconds
}

πŸ“˜

Creator / Consumer Tags

Creator / Consumer Tags enable you to control the visibility of specifis user's Moments Stories' to a dedicated audience. That way, in addition to the following mechanism in your app, you may create sub-communities, groups, etc.

If you wish to make user A's Stories visible to everyone, you can add ALL_CREATOR as the creator tag for user A. In this case all users, even the ones with empty consumer tag will see the Stories of user A.

There is another preoccupied tag ALL_CONSUMER for the consumer tag, let's say you defined user B's consumer tag as ALL_CONSUMER. In this case, user B will see every users' Stories if they have at least one creator tag.

🚧

Warning

All of the fields should be presented in your data.

Encrypt Your Data

User payload should be encrypted using AES Encryption in CBC mode with 256 Key size in bits. The payload is encrypted with an initialization-vector and secret-key. The initialization-vector is 16 characters long, whereas the secret-key is 32 characters. When the Storyly Moments instance is created, a random initialization-vector and secret-keys are generated along with the Storyly Moments token.

If you're not going to encrypt the data on your end, you may use the following helper function:

 MomentsUserPayload.init(
    id: String,
    username: String,
    avatarUrl: String,
    followings: Array,
    creatorTags: Array,
    consumerTags: Array,
    expirationTime: Integer
).encryptUserPayload(secretKey:SECRET_KEY, initializationVector:INITIALIZATION_VECTOR )

🚧

Warning

The user payload is valid if it can be decrypted with the initialization vector and secret key of the Storyly Moments instance and if its expiration time is not expired.