GetStream / stream-chat-android

:speech_balloon: Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
https://getstream.io/chat/sdk/android/
Other
1.47k stars 273 forks source link

channel automatically gets removed #564

Closed abhirup-patra closed 4 years ago

abhirup-patra commented 4 years ago

Channels created automatically removed without being removed manually.

JcMinarro commented 4 years ago

Hello @abhirup-patra Could you share with us the steps to reproduce it? Any log?

abhirup-patra commented 4 years ago

I am sharing with you the response of the view holder for two different apps. One of web and the other of android.

This one is of web of the same user.

`{ "channels": [ { "channel": { "id": "user56878_131347_user46772", "type": "messaging", "cid": "messaging:user56878_131347_user46772", "last_message_at": "2020-07-09T07:47:22.002043Z", "created_at": "2020-07-09T07:47:21.614063Z", "updated_at": "2020-07-09T07:47:21.614064Z", "created_by": { "id": "user46772", "role": "user", "created_at": "2020-07-07T06:26:37.090871Z", "updated_at": "2020-07-09T11:14:32.575437Z", "last_active": "2020-07-09T11:12:33.093784Z", "banned": false, "online": true, "image": "", "invisible": false, "name": "jan3001" }, "frozen": false, "member_count": 2, "config": { "created_at": "2020-07-06T16:49:24.469202388Z", "updated_at": "2020-07-06T16:49:24.469205098Z", "name": "messaging", "typing_events": true, "read_events": true, "connect_events": true, "search": true, "reactions": true, "replies": true, "mutes": true, "uploads": true, "url_enrichment": true, "message_retention": "infinite", "max_message_length": 5000, "automod": "disabled", "automod_behavior": "flag", "commands": [ { "name": "giphy", "description": "Post a random gif to the channel", "args": "[text]", "set": "fun_set" } ] }, "created_date": "2020-07-03T16:57:52.630565Z", "ad_id": "131347", "price": "0.00", "channel_name": "Need SDET", "ad_slug": "avl020720143333-131347-available-need-sdet", "chat_user_id": "user56878", "display_name": "Need SDET", "image": "", "role": "user", "account_type": "personal", "ad_type": "available", "currency_code": "INR", "location": "Kannur", "members_data": [ { "account_type": "personal", "chat_user_id": "user56878", "display_name": "Need SDET", "user_id": 56878, "user_image": "" }, { "account_type": "personal", "chat_user_id": "user46772", "display_name": "jan3001", "user_id": 46772, "user_image": "" } ], "name": "Need SDET", "online": true, "ad_title": "Need SDET" }, "messages": [ { "id": "user46772-4e339250-f850-4a15-96a7-59691e0f4488", "text": "hi", "html": "\u003cp\u003ehi\u003c/p\u003e\n", "type": "regular", "user": { "id": "user46772", "role": "user", "created_at": "2020-07-07T06:26:37.090871Z", "updated_at": "2020-07-09T11:14:32.575437Z", "last_active": "2020-07-09T11:12:33.093784Z", "banned": false, "online": true, "image": "", "invisible": false, "name": "jan3001" }, "attachments": [ { "type": "file", "asset_url": "https://res.cloudinary.com/daaebj3mb/raw/upload/v1594280840/zpoznkv8xgrorbei0udw.pdf", "name": "10127(5).pdf", "file_name": "10127(5).pdf", "file_size": 1072, "file_type": "pdf", "mime_type": "application/pdf" } ], "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": null,
      "reply_count": 0,
      "created_at": "2020-07-09T07:47:22.002043Z",
      "updated_at": "2020-07-09T07:47:22.002043Z",
      "mentioned_users": [

      ],
      "silent": false,
      "time": "",
      "isToday": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": ""
    }
  ],
  "watcher_count": 1,
  "read": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "invisible": false,
        "name": "jan3001",
        "image": ""
      },
      "last_read": "2020-07-09T07:47:22.002043904Z",
      "unread_messages": 0
    },
    {
      "user": {
        "id": "user56878",
        "role": "user",
        "created_at": "2020-07-02T13:02:38.683895Z",
        "updated_at": "2020-07-09T08:17:52.033191Z",
        "last_active": "2020-07-09T08:17:52.033191Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "bashir"
      },
      "last_read": "2020-07-09T07:47:21.643192576Z",
      "unread_messages": 1
    }
  ],
  "members": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "role": "owner",
      "created_at": "2020-07-09T07:47:21.619572Z",
      "updated_at": "2020-07-09T07:47:21.619572Z"
    },
    {
      "user": {
        "id": "user56878",
        "role": "user",
        "created_at": "2020-07-02T13:02:38.683895Z",
        "updated_at": "2020-07-09T08:17:52.033191Z",
        "last_active": "2020-07-09T08:17:52.033191Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "bashir"
      },
      "role": "member",
      "created_at": "2020-07-09T07:47:21.619572Z",
      "updated_at": "2020-07-09T07:47:21.619572Z"
    }
  ],
  "membership": {
    "user": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "role": "channel_member",
    "created_at": "2020-07-09T07:47:21.619572Z",
    "updated_at": "2020-07-09T07:47:21.619572Z"
  }
},
{
  "channel": {
    "id": "user54211_133741_user46772",
    "type": "messaging",
    "cid": "messaging:user54211_133741_user46772",
    "last_message_at": "2020-07-09T06:58:53.946283Z",
    "created_at": "2020-07-07T08:25:06.73254Z",
    "updated_at": "2020-07-07T08:25:06.732541Z",
    "created_by": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "name": "jan3001",
      "image": "",
      "invisible": false
    },
    "frozen": false,
    "member_count": 2,
    "config": {
      "created_at": "2020-07-06T16:49:24.469202388Z",
      "updated_at": "2020-07-06T16:49:24.469205098Z",
      "name": "messaging",
      "typing_events": true,
      "read_events": true,
      "connect_events": true,
      "search": true,
      "reactions": true,
      "replies": true,
      "mutes": true,
      "uploads": true,
      "url_enrichment": true,
      "message_retention": "infinite",
      "max_message_length": 5000,
      "automod": "disabled",
      "automod_behavior": "flag",
      "commands": [
        {
          "name": "giphy",
          "description": "Post a random gif to the channel",
          "args": "[text]",
          "set": "fun_set"
        }
      ]
    },
    "ad_id": "133741",
    "ad_slug": "wan060720054652-133741-wanted-new-or-used-austin-healey-3000",
    "currency_code": "INR",
    "members_data": [
      {
        "account_type": "personal",
        "chat_user_id": "user54211",
        "display_name": "New or Used Austin Healey 3000",
        "user_id": 54211,
        "user_image": ""
      },
      {
        "account_type": "personal",
        "chat_user_id": "user46772",
        "display_name": "jan3001",
        "user_id": 46772,
        "user_image": ""
      }
    ],
    "role": "user",
    "account_type": "personal",
    "name": "New or Used Austin Healey 3000",
    "online": true,
    "display_name": "New or Used Austin Healey 3000",
    "image": "",
    "chat_user_id": "user54211",
    "ad_type": "wanted",
    "channel_name": "New or Used Austin Healey 3000",
    "created_date": "2020-07-06T05:48:22.290733Z",
    "location": "Kannur",
    "price": "250000.00",
    "ad_title": "New or Used Austin Healey 3000"
  },
  "messages": [
    {
      "id": "user46772-1c553447-79a4-42cd-bf2d-85d55155579a",
      "text": "hii",
      "html": "\u003cp\u003ehii\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T08:25:07.075256Z",
      "updated_at": "2020-07-07T08:25:07.075256Z",
      "mentioned_users": [

      ],
      "silent": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": "",
      "time": "",
      "isToday": false,
      "isStartDay": false
    },
    {
      "id": "user46772-692fdd28-aa7c-4f59-bfe1-3743f5476c65",
      "text": "jii",
      "html": "\u003cp\u003ejii\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T09:06:47.177Z",
      "updated_at": "2020-07-07T09:06:47.177Z",
      "mentioned_users": [

      ],
      "silent": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": "",
      "time": "",
      "isToday": false
    },
    {
      "id": "user46772-bfb7675b-dea8-4184-b9a7-bf5d51702726",
      "text": "hi",
      "html": "\u003cp\u003ehi\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-09T06:58:53.946283Z",
      "updated_at": "2020-07-09T06:58:53.946283Z",
      "mentioned_users": [

      ],
      "silent": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": "",
      "time": "",
      "isToday": false,
      "isStartDay": false
    }
  ],
  "watcher_count": 1,
  "read": [
    {
      "user": {
        "id": "user54211",
        "role": "user",
        "created_at": "2020-07-03T06:41:55.370105Z",
        "updated_at": "2020-07-09T07:10:24.865943Z",
        "last_active": "2020-07-09T07:10:24.865943Z",
        "banned": false,
        "online": false,
        "image": "",
        "invisible": false,
        "name": "gsubbu"
      },
      "last_read": "2020-07-07T08:25:06.748027136Z",
      "unread_messages": 3
    },
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "name": "jan3001",
        "image": "",
        "invisible": false
      },
      "last_read": "2020-07-09T06:58:53.946283776Z",
      "unread_messages": 0
    }
  ],
  "members": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "role": "owner",
      "created_at": "2020-07-07T08:25:06.736098Z",
      "updated_at": "2020-07-07T08:25:06.736098Z"
    },
    {
      "user": {
        "id": "user54211",
        "role": "user",
        "created_at": "2020-07-03T06:41:55.370105Z",
        "updated_at": "2020-07-09T07:10:24.865943Z",
        "last_active": "2020-07-09T07:10:24.865943Z",
        "banned": false,
        "online": false,
        "invisible": false,
        "name": "gsubbu",
        "image": ""
      },
      "role": "member",
      "created_at": "2020-07-07T08:25:06.736098Z",
      "updated_at": "2020-07-07T08:25:06.736098Z"
    }
  ],
  "membership": {
    "user": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "role": "channel_member",
    "created_at": "2020-07-07T08:25:06.736098Z",
    "updated_at": "2020-07-07T08:25:06.736098Z"
  }
},
{
  "channel": {
    "id": "user57095_133790_user46772",
    "type": "messaging",
    "cid": "messaging:user57095_133790_user46772",
    "last_message_at": "2020-07-07T11:37:56.350715Z",
    "created_at": "2020-07-07T09:25:48.506481Z",
    "updated_at": "2020-07-07T09:25:48.506481Z",
    "created_by": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "frozen": false,
    "member_count": 2,
    "config": {
      "created_at": "2020-07-06T16:49:24.469202388Z",
      "updated_at": "2020-07-06T16:49:24.469205098Z",
      "name": "messaging",
      "typing_events": true,
      "read_events": true,
      "connect_events": true,
      "search": true,
      "reactions": true,
      "replies": true,
      "mutes": true,
      "uploads": true,
      "url_enrichment": true,
      "message_retention": "infinite",
      "max_message_length": 5000,
      "automod": "disabled",
      "automod_behavior": "flag",
      "commands": [
        {
          "name": "giphy",
          "description": "Post a random gif to the channel",
          "args": "[text]",
          "set": "fun_set"
        }
      ]
    },
    "ad_slug": "avl060720080709-133790-available-new-mercedes-benz-v-class",
    "currency_code": "INR",
    "members_data": [
      {
        "account_type": "company",
        "chat_user_id": "user57095",
        "display_name": "New Mercedes-Benz V-Class",
        "user_id": 57095,
        "user_image": ""
      },
      {
        "account_type": "personal",
        "chat_user_id": "user46772",
        "display_name": "jan3001",
        "user_id": 46772,
        "user_image": ""
      }
    ],
    "price": "5900000.00",
    "role": "user",
    "ad_id": "133790",
    "ad_title": "New Mercedes-Benz V-Class",
    "ad_type": "available",
    "display_name": "New Mercedes-Benz V-Class",
    "name": "New Mercedes-Benz V-Class",
    "created_date": "2020-07-06T08:07:21.196624Z",
    "location": "India",
    "account_type": "company",
    "channel_name": "New Mercedes-Benz V-Class",
    "chat_user_id": "user57095",
    "image": "",
    "online": true
  },
  "messages": [
    {
      "id": "user46772-847aeb84-1925-41f9-84ea-f11bb9a56866",
      "text": "hii",
      "html": "\u003cp\u003ehii\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T09:25:48.891991Z",
      "updated_at": "2020-07-07T09:25:48.891992Z",
      "mentioned_users": [

      ],
      "silent": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": "",
      "time": "",
      "isToday": false
    },
    {
      "id": "55f2bc7c-c4d8-4541-9588-39dd10889b89",
      "text": "hi",
      "html": "\u003cp\u003ehi\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user57095",
        "role": "user",
        "created_at": "2020-07-06T07:15:28.201729Z",
        "updated_at": "2020-07-08T14:13:36.27179Z",
        "last_active": "2020-07-08T14:13:36.27179Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "royalcustoms"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T11:34:57.846297Z",
      "updated_at": "2020-07-07T11:34:57.846297Z",
      "mentioned_users": [

      ],
      "silent": false
    },
    {
      "id": "9df9718a-2f10-42b1-9587-3fc58c976f9c",
      "text": "thank you for contacting Royal customs vip vehicle factory in dubai, my name is mohamad ammar, i'm the regional manager for the MEA/Africa region, please let us know how we can help you",
      "html": "\u003cp\u003ethank you for contacting Royal customs vip vehicle factory in dubai, my name is mohamad ammar, i’m the regional manager for the MEA/Africa region, please let us know how we can help you\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user57095",
        "role": "user",
        "created_at": "2020-07-06T07:15:28.201729Z",
        "updated_at": "2020-07-08T14:13:36.27179Z",
        "last_active": "2020-07-08T14:13:36.27179Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "royalcustoms"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T11:37:26.930326Z",
      "updated_at": "2020-07-07T11:37:26.930327Z",
      "mentioned_users": [

      ],
      "silent": false
    },
    {
      "id": "c7981e64-1953-4720-92c7-c6c600cc8166",
      "text": "for more details donnot hesitate to contact us: +971562475536",
      "html": "\u003cp\u003efor more details donnot hesitate to contact us: +971562475536\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user57095",
        "role": "user",
        "created_at": "2020-07-06T07:15:28.201729Z",
        "updated_at": "2020-07-08T14:13:36.27179Z",
        "last_active": "2020-07-08T14:13:36.27179Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "royalcustoms"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T11:37:56.350715Z",
      "updated_at": "2020-07-07T11:37:56.350715Z",
      "mentioned_users": [

      ],
      "silent": false
    }
  ],
  "watcher_count": 1,
  "read": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "last_read": "2020-07-07T11:37:56.350715904Z",
      "unread_messages": 0
    },
    {
      "user": {
        "id": "user57095",
        "role": "user",
        "created_at": "2020-07-06T07:15:28.201729Z",
        "updated_at": "2020-07-08T14:13:36.27179Z",
        "last_active": "2020-07-08T14:13:36.27179Z",
        "banned": false,
        "online": false,
        "name": "royalcustoms",
        "image": ""
      },
      "last_read": "2020-07-08T11:29:16.074625792Z",
      "unread_messages": 0
    }
  ],
  "members": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "role": "owner",
      "created_at": "2020-07-07T09:25:48.511683Z",
      "updated_at": "2020-07-07T09:25:48.511683Z"
    },
    {
      "user": {
        "id": "user57095",
        "role": "user",
        "created_at": "2020-07-06T07:15:28.201729Z",
        "updated_at": "2020-07-08T14:13:36.27179Z",
        "last_active": "2020-07-08T14:13:36.27179Z",
        "banned": false,
        "online": false,
        "image": "",
        "name": "royalcustoms"
      },
      "role": "member",
      "created_at": "2020-07-07T09:25:48.511684Z",
      "updated_at": "2020-07-07T09:25:48.511684Z"
    }
  ],
  "membership": {
    "user": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "role": "channel_member",
    "created_at": "2020-07-07T09:25:48.511683Z",
    "updated_at": "2020-07-07T09:25:48.511683Z"
  }
},
{
  "channel": {
    "id": "user55593_116092_user46772",
    "type": "messaging",
    "cid": "messaging:user55593_116092_user46772",
    "last_message_at": "2020-07-07T10:13:37.189848Z",
    "created_at": "2020-07-07T06:27:03.129072Z",
    "updated_at": "2020-07-07T06:27:03.129072Z",
    "created_by": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "name": "jan3001",
      "image": "",
      "invisible": false
    },
    "frozen": false,
    "member_count": 2,
    "config": {
      "created_at": "2020-07-06T16:49:24.469202388Z",
      "updated_at": "2020-07-06T16:49:24.469205098Z",
      "name": "messaging",
      "typing_events": true,
      "read_events": true,
      "connect_events": true,
      "search": true,
      "reactions": true,
      "replies": true,
      "mutes": true,
      "uploads": true,
      "url_enrichment": true,
      "message_retention": "infinite",
      "max_message_length": 5000,
      "automod": "disabled",
      "automod_behavior": "flag",
      "commands": [
        {
          "name": "giphy",
          "description": "Post a random gif to the channel",
          "args": "[text]",
          "set": "fun_set"
        }
      ]
    },
    "ad_slug": "wan120620035055-116092-wanted-part-time-manager-position-in-accounting-auditing",
    "chat_user_id": "user55593",
    "display_name": "Part Time Manager Position in Accounting \u0026 Auditing",
    "members_data": [
      {
        "account_type": "personal",
        "chat_user_id": "user55593",
        "display_name": "Part Time Manager Position in Accounting \u0026 Auditing",
        "user_id": 55593,
        "user_image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1591933662/profile/photo_1591933662570_iasckg.png"
      },
      {
        "account_type": "personal",
        "chat_user_id": "user46772",
        "display_name": "jan3001",
        "user_id": 46772,
        "user_image": ""
      }
    ],
    "ad_id": "116092",
    "ad_title": "Part Time Manager Position in Accounting \u0026 Auditing",
    "channel_name": "Part Time Manager Position in Accounting \u0026 Auditing",
    "price": "0.00",
    "account_type": "personal",
    "ad_type": "wanted",
    "currency_code": "INR",
    "name": "Part Time Manager Position in Accounting \u0026 Auditing",
    "role": "user",
    "created_date": "2020-06-12T08:38:43.087382Z",
    "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1591933662/profile/photo_1591933662570_iasckg.png",
    "location": "Thiruvananthapuram",
    "online": true
  },
  "messages": [
    {
      "id": "user46772-96eef8d1-0bce-4166-8d84-9c95e258e8bf",
      "text": "hi",
      "html": "\u003cp\u003ehi\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T06:27:03.503149Z",
      "updated_at": "2020-07-07T06:27:03.503149Z",
      "mentioned_users": [

      ],
      "silent": false,
      "isToday": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": "",
      "time": ""
    },
    {
      "id": "user46772-59f8482c-e49c-4433-b439-760157aa4814",
      "text": "hii",
      "html": "\u003cp\u003ehii\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T10:13:37.189848Z",
      "updated_at": "2020-07-07T10:13:37.189848Z",
      "mentioned_users": [

      ],
      "silent": false,
      "cid": "",
      "date": "",
      "time": "",
      "isToday": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false
    }
  ],
  "watcher_count": 1,
  "read": [
    {
      "user": {
        "id": "user55593",
        "role": "user",
        "created_at": "2020-07-03T05:58:36.133683Z",
        "updated_at": "2020-07-03T05:58:36.136631Z",
        "last_active": "2020-07-03T05:58:36.136631Z",
        "banned": false,
        "online": false,
        "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1591933662/profile/photo_1591933662570_iasckg.png",
        "invisible": false,
        "name": "gigilalc1253"
      },
      "last_read": "2020-07-07T06:27:03.142315776Z",
      "unread_messages": 2
    },
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "last_read": "2020-07-07T10:13:37.189848832Z",
      "unread_messages": 0
    }
  ],
  "members": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "role": "owner",
      "created_at": "2020-07-07T06:27:03.131679Z",
      "updated_at": "2020-07-07T06:27:03.131679Z"
    },
    {
      "user": {
        "id": "user55593",
        "role": "user",
        "created_at": "2020-07-03T05:58:36.133683Z",
        "updated_at": "2020-07-03T05:58:36.136631Z",
        "last_active": "2020-07-03T05:58:36.136631Z",
        "banned": false,
        "online": false,
        "name": "gigilalc1253",
        "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1591933662/profile/photo_1591933662570_iasckg.png",
        "invisible": false
      },
      "role": "member",
      "created_at": "2020-07-07T06:27:03.131679Z",
      "updated_at": "2020-07-07T06:27:03.131679Z"
    }
  ],
  "membership": {
    "user": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "role": "channel_member",
    "created_at": "2020-07-07T06:27:03.131679Z",
    "updated_at": "2020-07-07T06:27:03.131679Z"
  }
},
{
  "channel": {
    "id": "user26383_131325_user46772",
    "type": "messaging",
    "cid": "messaging:user26383_131325_user46772",
    "last_message_at": "2020-07-07T09:24:51.762064Z",
    "created_at": "2020-07-07T09:24:51.367187Z",
    "updated_at": "2020-07-07T09:24:51.367187Z",
    "created_by": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "name": "jan3001",
      "image": "",
      "invisible": false
    },
    "frozen": false,
    "member_count": 2,
    "config": {
      "created_at": "2020-07-06T16:49:24.469202388Z",
      "updated_at": "2020-07-06T16:49:24.469205098Z",
      "name": "messaging",
      "typing_events": true,
      "read_events": true,
      "connect_events": true,
      "search": true,
      "reactions": true,
      "replies": true,
      "mutes": true,
      "uploads": true,
      "url_enrichment": true,
      "message_retention": "infinite",
      "max_message_length": 5000,
      "automod": "disabled",
      "automod_behavior": "flag",
      "commands": [
        {
          "name": "giphy",
          "description": "Post a random gif to the channel",
          "args": "[text]",
          "set": "fun_set"
        }
      ]
    },
    "ad_slug": "avl020720130033-131325-available-new-abarth-2000-pininfarina",
    "currency_code": "INR",
    "account_type": "personal",
    "created_date": "2020-07-02T13:02:04.427242Z",
    "location": "Kolkata",
    "online": true,
    "role": "user",
    "chat_user_id": "user26383",
    "display_name": "New Abarth 2000 Pininfarina",
    "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1588842926/profile/26383/1588842926_200507602698_r4mvh1.jpg",
    "members_data": [
      {
        "account_type": "personal",
        "chat_user_id": "user26383",
        "display_name": "New Abarth 2000 Pininfarina",
        "user_id": 26383,
        "user_image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1588842926/profile/26383/1588842926_200507602698_r4mvh1.jpg"
      },
      {
        "account_type": "personal",
        "chat_user_id": "user46772",
        "display_name": "jan3001",
        "user_id": 46772,
        "user_image": ""
      }
    ],
    "ad_id": "131325",
    "ad_title": "New Abarth 2000 Pininfarina",
    "ad_type": "available",
    "channel_name": "New Abarth 2000 Pininfarina",
    "name": "New Abarth 2000 Pininfarina",
    "price": "5000.00"
  },
  "messages": [
    {
      "id": "user46772-ee67ae4f-0f25-4a59-977b-0d4b81bf22b9",
      "text": "hii",
      "html": "\u003cp\u003ehii\u003c/p\u003e\n",
      "type": "regular",
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "attachments": [

      ],
      "latest_reactions": [

      ],
      "own_reactions": [

      ],
      "reaction_counts": {

      },
      "reaction_scores": {

      },
      "reply_count": 0,
      "created_at": "2020-07-07T09:24:51.762064Z",
      "updated_at": "2020-07-07T09:24:51.762064Z",
      "mentioned_users": [

      ],
      "silent": false,
      "time": "",
      "isToday": false,
      "isStartDay": false,
      "commandInfo": {

      },
      "isYesterday": false,
      "cid": "",
      "date": ""
    }
  ],
  "watcher_count": 1,
  "read": [
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "last_read": "2020-07-07T09:24:51.762064896Z",
      "unread_messages": 0
    },
    {
      "user": {
        "id": "user26383",
        "role": "user",
        "created_at": "2020-07-02T12:53:51.082457Z",
        "updated_at": "2020-07-09T11:08:32.830517Z",
        "last_active": "2020-07-09T11:08:32.830517Z",
        "banned": false,
        "online": false,
        "name": "piyali saha",
        "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1588842926/profile/26383/1588842926_200507602698_r4mvh1.jpg"
      },
      "last_read": "2020-07-07T09:24:51.390981376Z",
      "unread_messages": 1
    }
  ],
  "members": [
    {
      "user": {
        "id": "user26383",
        "role": "user",
        "created_at": "2020-07-02T12:53:51.082457Z",
        "updated_at": "2020-07-09T11:08:32.830517Z",
        "last_active": "2020-07-09T11:08:32.830517Z",
        "banned": false,
        "online": false,
        "image": "https://res.cloudinary.com/daaebj3mb/image/upload/v1588842926/profile/26383/1588842926_200507602698_r4mvh1.jpg",
        "name": "piyali saha"
      },
      "role": "member",
      "created_at": "2020-07-07T09:24:51.371683Z",
      "updated_at": "2020-07-07T09:24:51.371683Z"
    },
    {
      "user": {
        "id": "user46772",
        "role": "user",
        "created_at": "2020-07-07T06:26:37.090871Z",
        "updated_at": "2020-07-09T11:14:32.575437Z",
        "last_active": "2020-07-09T11:12:33.093784Z",
        "banned": false,
        "online": true,
        "image": "",
        "invisible": false,
        "name": "jan3001"
      },
      "role": "owner",
      "created_at": "2020-07-07T09:24:51.371683Z",
      "updated_at": "2020-07-07T09:24:51.371683Z"
    }
  ],
  "membership": {
    "user": {
      "id": "user46772",
      "role": "user",
      "created_at": "2020-07-07T06:26:37.090871Z",
      "updated_at": "2020-07-09T11:14:32.575437Z",
      "last_active": "2020-07-09T11:12:33.093784Z",
      "banned": false,
      "online": true,
      "image": "",
      "invisible": false,
      "name": "jan3001"
    },
    "role": "channel_member",
    "created_at": "2020-07-07T09:24:51.371683Z",
    "updated_at": "2020-07-07T09:24:51.371683Z"
  }
}

], "duration": "34.12ms" }`

While the viewmodel in android returns a different value. viewmodel.getChannel returning size of 3 whereas it should return a size of 6. I am not able to provide you the data from viewmodel

abhirup-patra commented 4 years ago

its a major issue that is faced in android. The viewmodel itself is returning less channel than present. Please look into it as soon as possible

Thanks

samiuelson commented 4 years ago

@abhirup-patra What SDK version are you using?

abhirup-patra commented 4 years ago

4.2.11 beta 5

abhirup-patra commented 4 years ago
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        // setup the client
        //configureStreamClient();
        // example for how to observe the unread counts

        viewModel = new ViewModelProvider(this).get(ChannelListViewModel.class);
        Chat.getInstance().getUnreadMessages().observe(getViewLifecycleOwner(), (Number count) -> {
            Log.i(TAG, String.format("Total unread message count is now %d", count));
             chat_count = (int) count;
            if ( chat_count > 0) {
                AppPreferences.getInstance().setNewPushEnable(true);
               //showNewMessageIndicatorNew
                if (myactivity != null) {
                    myactivity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            ((HomeActivity) getActivity()).showNewMessageIndicatorNew();
                        }
                    });
                }

            }else {
                AppPreferences.getInstance().setNewPushEnable(false);
            }
        });
        binding = FragmentChannelListBinding.inflate(inflater, container, false);

        // Specify the current activity as the lifecycle owner.
        binding.setLifecycleOwner(this);

        // just get all channels
        FilterObject filter = Filters.INSTANCE.eq("type", "messaging");

        QuerySort querySort = new QuerySort().desc("last_message_at");
        viewModel.setQuery(filter,querySort);

        if(Utils.isInternetConnected(getActivity())) {
            binding.setViewModel(viewModel);
            binding.channelList.setViewModel(viewModel, this);

        }else {
            Utils.showToastLong("No internet connection available",getActivity());
            binding.progressBar.setVisibility(View.GONE);
            binding.pBar.setVisibility(View.GONE);
        }

        setCustomChannelItem(getContext(), binding);
        return binding.getRoot();
    }

    private void setCustomChannelItem(Context context, FragmentChannelListBinding binding){
        CustomViewHolderFactory factory = new CustomViewHolderFactory(ChannelListFragment.this, context);
        binding.channelList.setViewHolderFactory(factory);
    }

this is how i am declaring and calling

abhirup-patra commented 4 years ago
@Override
    public BaseChannelListItemViewHolder createChannelViewHolder
            (ChannelListItemAdapter adapter, ViewGroup parent, int viewType) {
        ChannelListViewStyle style = adapter.getStyle();
        // inflate the layout specified in the style
//        View v = LayoutInflater.from(parent.getContext()).inflate(style.channelPreviewLayout, parent, false);
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.ad_chat_user_item_new, parent, false);

        BaseChannelListItemViewHolder holder = new BaseChannelListItemViewHolder(v) {
            @Override
            public void bind(Context context, Channel channelState, int position, @Nullable ChannelItemPayloadDiff payloads) {

                ivUser = v.findViewById(R.id.iv_users_image);
                ivUserStatus = v.findViewById(R.id.iv_user_status);
                lastM = v.findViewById(R.id.tv_last_message);
                userTv = v.findViewById(R.id.tv_chat_username);
                channelTv = v.findViewById(R.id.tv_ad_title);
                unreadTv = v.findViewById(R.id.tv_notification_count);
                dateTv = v.findViewById(R.id.lastUpdatedDate);

                int msgSize = channelState.getMessages().size()-1;

                try {

                    if (!channelState.getMessages().get(msgSize).getAttachments().isEmpty()) {
                        if (channelState.getMessages().get(msgSize).getAttachments().get(0).getType().equalsIgnoreCase("file")) {
                            lastM.setText("file");
                            lastM.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.drawable.ic_insert_drive_file_black_24dp),null,null,null);
                        }
                        else if (channelState.getMessages().get(msgSize).getAttachments().get(0).getType().equalsIgnoreCase("image")) {
                            lastM.setText("image");
                            lastM.setCompoundDrawablesWithIntrinsicBounds(context.getResources().getDrawable(R.drawable.ic_image_black_24dp),null,null,null);
                        }

                    }
                    else {
                        lastM.setText(channelState.getMessages().get(msgSize).getText());
                        lastM.setCompoundDrawablesWithIntrinsicBounds(null,null,null,null);

                    }
                    userTv.setText(channelState.getMembers().get(0).getUser().getId());
                    channelTv.setText(channelState.getExtraData().get("name").toString());

                    if (channelState.getUnreadCount()>0)
                        unreadTv.setVisibility(View.VISIBLE);
                    else
                        unreadTv.setVisibility(View.INVISIBLE);

                    unreadTv.setText(channelState.getUnreadCount().toString());

                    Date date = channelState.getLastMessageAt();
                    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                    String strDate = dateFormat.format(date);
                    // System.out.println("Converted String: " + strDate);
                    getTimeFromDate(strDate);
//                dateTv.setText(channelState.getLastMessageAt().getTime());

                    if (channelState.getMembers().size()>=2) {

                        String u1 = channelState.getMembers().get(0).getUserId().substring(4);
                        String u2 = channelState.getMembers().get(1).getUserId().substring(4);

                        int userNumber = 0;

                        if (!u1.equalsIgnoreCase(String.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()))) {
                            userNumber = 0;
                        } else if (!u2.equalsIgnoreCase(String.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()))) {
                            userNumber = 1;
//                    getCategoryDataFromAlgoliaForListScreen(channelState,u2);
                        }

                        ImageLoader.DisplayImageWithPlaceHolder(context, (String) channelState.getMembers().get(userNumber).getUser().getExtraData().get("image"), R.drawable.profile, ivUser);
                        userTv.setText(String.valueOf(channelState.getMembers().get(userNumber).getUser().getExtraData().get("name")));

                        if (channelState.getMembers().get(userNumber).getUser().getOnline()) {
                            ivUserStatus.setVisibility(View.VISIBLE);
                        } else {
                            ivUserStatus.setVisibility(View.GONE);
                            //getTimeFromDate((CharSequence)channel.createdBy.getLastActive());
                        }
                    }
                }
                catch (Exception e){
                    e.printStackTrace();
//                    Utils.showToast("Some error occured, Please try again",context);
                }

                v.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ((ChannelListFragment)fragment).openChannel(channelState);
                    }
                });

            }

            @Override
            public void setStyle(ChannelListViewStyle style) {

            }

            @Override
            public void setUserClickListener(ChannelListView.UserClickListener l) {

            }

            @Override
            public void setChannelClickListener(ChannelListView.ChannelClickListener l) {

            }

            @Override
            public void setChannelLongClickListener(ChannelListView.ChannelClickListener l) {

            }
        };
        configureHolder(holder, adapter);
        return holder;

    }

this is the custom made channel list section

abhirup-patra commented 4 years ago

@JcMinarro Kindly look into this. The unread count is coming but the viewmodel is returning less channel than that is present.

abhirup-patra commented 4 years ago

if chat domain is not used, viewmodel throws exception of unable to create instance and if chat domain is used then viewmodel shows less number of channels.

i am sharing how i am initialising chat domain.

`disconnectChatDomainIfAlreadyInitialized(); chatDomain = new ChatDomain.Builder(getApplicationContext(), client, user).build();

    Log.e("clientInitialization: ",extraData.toString() );
    Log.e("clientToken: ",token );
    client.setUser(user, token, new InitConnectionListener(){
        @Override
        public void onError(@NotNull ChatError error) {
            super.onError(error);
            Log.i("StreamChatError", error.getLocalizedMessage());
        }

        @Override
        public void onSuccess(@NotNull ConnectionData data) {

            user=data.getUser();
            unread_count= user.getUnreadCount();

           // Log.i("StreamChatError", "works");
            if (from.equalsIgnoreCase("splash") || from.equalsIgnoreCase("login")){
                PageRedirection.gotoHomeActivity(context);
            }

            Log.i("countTest", "onSuccess: "+unread_count);

            if(unread_count > 0){
                AppPreferences.getInstance().setNewPushEnable(true);
            }else {
                AppPreferences.getInstance().setNewPushEnable(false);
            }
            Log.e("clientInitSuccess: ", String.valueOf(data));
            Log.i("StreamChat", "setUser completed"+id);
            Log.i("unread_count", String.valueOf(unread_count));
            Log.e("showNewMsgIndicator1: ", String.valueOf(AppPreferences.getInstance().getNewPushEnable()));
            super.onSuccess(data);
        }
    });`

the disconnectChatDomain function is called similar to how one example showed in this repo -

private static void disconnectChatDomainIfAlreadyInitialized() { try { chatDomain = ChatDomain.instance(); BuildersKt.launch(GlobalScope.INSTANCE, Dispatchers.getIO(), CoroutineStart.DEFAULT, (scope, continuation) -> chatDomain.disconnect(continuation)); } catch(UninitializedPropertyAccessException e) { ChatLogger.Companion.get("ChatImpl").logD("ChatDomain was not initialized yet. No need to disconnect."); } }

abhirup-patra commented 4 years ago

@JcMinarro is this solved in this build? still not able to get all the channel lists

JcMinarro commented 4 years ago

Hello @abhirup-patra

We are investigating this issue yet

abhirup-patra commented 4 years ago

happening with the latest sdk as well. recently implemented beta 10, there is channels available for the user but those are not getting returned.

devUndef1ned commented 4 years ago

@abhirup-patra Hello! We're investigating your issues. Could you please provide more details about how you use it in your app? 1) Where do you set user (activity/fragments/application in what callbacks of the lifecycle?) 2) What do you mean channels get removed? Do you see them but then they get removed? Or you can't see a whole list from the beginning? How do you reproduce it? Do you create new channels at another app/ website? Looking forward to your response. It will help us a lot!

abhirup-patra commented 4 years ago
  1. All the codes are provided above. You can check that. The channel is created from a different activity and redirected to a different activity to view the room.

  2. When the room is created then i can see the message and even chat with the user as well. But when i exit the app and come back after a day or two, the channels are not displayed anymore. The channelview model is even returning blank.

If you want i can share you the full code along with the videos as well for your consideration

abhirup-patra commented 4 years ago

this method is called inside an activity to create channel and then redirecting the user to it.

private void createNewChannel() {
      // isUserExistsInGetStream(String.valueOf(chatDetailsModel.getChat_user_id()), chatDetailsModel);

        binding.progressBar.show();

        ChatMember chatMember = new ChatMember();
        chatMember.setAccount_type(chatDetailsModel.getAccount_type());
        chatMember.setChat_user_id(chatDetailsModel.getChat_user_id());
        chatMember.setDisplay_name(chatDetailsModel.getChannel_name());
        chatMember.setUser_image(chatDetailsModel.getAd_owner_img());
        chatMember.setUser_id(Integer.valueOf(chatDetailsModel.getChat_user_id().replace("user","")));

        ChatMember chatMember2 = new ChatMember();
        chatMember2.setAccount_type(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getAccount_type());
        chatMember2.setChat_user_id("user"+String.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()));
        chatMember2.setDisplay_name(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getDisplay_name());
        chatMember2.setUser_image(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_image());
        chatMember2.setUser_id(Integer.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()));

        HashMap<String, Object> extraData = new HashMap<>();
        HashMap<String, Object> member_info = new HashMap<>();

        member_info.put("name", chatDetailsModel.getChannel_name());
        member_info.put("image", chatDetailsModel.getAd_owner_img());
        extraData.put("role","owner");

        List<String> members = new ArrayList<>();
        ArrayList<ChatMember> members_data = new ArrayList<>();

//        extraData.put("name", "user" + String.valueOf(allDataChild.getAdOwnerDetails().getUserId())
//                                                            + '_' + String.valueOf(allDataChild.getAdId()) + '_' + "user" + USER_ID);

        extraData.put("name",chatDetailsModel.getChannel_name());
        extraData.put("image",chatDetailsModel.getAd_owner_img());
        extraData.put("online",true);
        extraData.put("role","user");
        extraData.put("created_at",chatDetailsModel.getCreated_date());
        extraData.put("chat_user_id",chatDetailsModel.getChat_user_id());
        extraData.put("channel_name",chatDetailsModel.getChannel_name());
        extraData.put("display_name",chatDetailsModel.getChannel_name());
        extraData.put("ad_id",chatDetailsModel.getAd_id());
        extraData.put("ad_title",chatDetailsModel.getAd_title());
        extraData.put("currency_code",chatDetailsModel.getCurrency_code());
        extraData.put("price",chatDetailsModel.getPrice());
        extraData.put("account_type",chatDetailsModel.getAccount_type());
        extraData.put("ad_type",chatDetailsModel.getAd_type());
        extraData.put("location",chatDetailsModel.getLocation());
        extraData.put("created_date",chatDetailsModel.getCreated_date());
        extraData.put("ad_slug",chatDetailsModel.getAd_slug());

        members_data.add(chatMember);
        members_data.add(chatMember2);

        if(!newAdOwnerToken.equalsIgnoreCase("") && newAdOwnerToken!=null){
            StreamChat.client.disconnect();
            StreamChat.clientInitialization("user" + chatMember2.getUser_id(),chatMember2.getDisplay_name(),AppPreferences.getInstance().getChatToken(),chatMember2.getUser_image(),AvailableAdDetailsActivity.this, "AvailableAdDetails");
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    User currentUser = StreamChat.client.getCurrentUser();
                    extraData.put("name",AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getDisplay_slug());
                    extraData.put("image",AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_image());
                    currentUser.setExtraData(extraData);
                    members.add(currentUser.getId());
                }
            },3000);
        }else {
            User currentUser = StreamChat.client.getCurrentUser();
            if(currentUser!=null) {
                currentUser.setExtraData(extraData);
                members.add(currentUser.getId());
            }
        }

        User user1 = new User();
        user1.setId(chatDetailsModel.getChat_user_id());
        user1.setExtraData(member_info);
        members.add(user1.getId());

      /*  User currentUser = StreamChat.client.getCurrentUser();
        currentUser.setExtraData(extraData);
        members.add(currentUser.getId());*/

        extraData.put("members", members);
        extraData.put("members_data", members_data);

        Log.e("chatDetailsModel", extraData.toString());
        Log.e("channelId", chatDetailsModel.getChannel_id());

          String channelId =chatDetailsModel.getChannel_id();
        //  String channelId = allDataChild.getAdOwnerDetails().getDisplayName().replaceAll("[0-9]","").toLowerCase();
        // String channelId = USER_NAME.replaceAll(" ", "-").toLowerCase();
//       String channelId = "user" + String.valueOf(allDataChild.getAdOwnerDetails().getUserId()) + '_' +
//                String.valueOf(allDataChild.getAdId()) + '_' + "user" + USER_ID ;

        QueryChannelRequest request = new QueryChannelRequest().withData(extraData);

        StreamChat.client.queryChannel(ModelType.channel_messaging, channelId, request).enqueue(new Function1<Result<Channel>, Unit>() {
            @Override
            public Unit invoke(Result<Channel> channelResult) {

                if (channelResult.isSuccess()) {

                    io.getstream.chat.android.client.models.Channel channel = channelResult.data();

                    Intent intent = new Intent(getApplicationContext(), ChannelActivity.class);

                    Log.i("testChat", "onClick: " + chatDetailsModel.getAd_id());

                    intent.putExtra("from","adDetails");
                    intent.putExtra("ad_id", chatDetailsModel.getAd_id());
                    intent.putExtra("ad_title", chatDetailsModel.getAd_title());
                    intent.putExtra("ad_memeber_id", chatDetailsModel.getChat_user_id());
                    intent.putExtra("ad_member_image", chatDetailsModel.getAd_owner_img());
                    intent.putExtra("ad_member_name", chatDetailsModel.getAd_owner_name());
                    intent.putExtra("ad_owner_user_id", chatDetailsModel.getChat_user_id());
                    //intent.putExtra("ad_image",allDataChild.getFeatureImage());
                    intent.putExtra("location", chatDetailsModel.getLocation());
                    intent.putExtra("currency_code", chatDetailsModel.getCurrency_code());
                    intent.putExtra("price", chatDetailsModel.getPrice());
                    intent.putExtra("ad_type", chatDetailsModel.getAd_type());
                    intent.putExtra("created_date", chatDetailsModel.getCreated_date());
                    intent.putExtra("ad_slug", chatDetailsModel.getAd_slug());
                    intent.putExtra("display_slug", chatDetailsModel.getDisplay_slug());
                    intent.putExtra("coming_from","adDetails");
                    intent.putExtra("is_job","n");
                    intent.putExtra(EXTRA_CHANNEL_TYPE, channel.getType());
                    intent.putExtra(EXTRA_CHANNEL_ID,  chatDetailsModel.getChannel_id());

                    if (chatDetailsModel.getAd_type().equalsIgnoreCase("wanted"))
                        intent.putExtra("adImage", "");
                    else
                        intent.putExtra("adImage", chatDetailsModel.getChannel_image());
                    //intent.putExtra("slug", allDataChild.getSlug());

                    AppData.msgDesc = binding.messageET.getText().toString();
                    Message message = new Message();
                    message.setText(AppData.msgDesc);

                    StreamChat.channelController = StreamChat.client.channel(channel.getType(), channelId);
                    StreamChat.channelController.sendMessage(message).enqueue(result -> Unit.INSTANCE);
                    binding.messageET.setText("");
                    binding.messageET.clearFocus();
                    binding.sendButton.setEnabled(true);
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            binding.progressBar.hide();

                            saveRecentAd(allDataChild.getAdGeneratedId(), allDataChild.getAdId(), String.valueOf(allDataChild.getAdOwnerDetails().getUserId()), mapLocLong, mapLocLang, "", allDataChild.getCity(), allDataChild.getCategoryId(), allDataChild.getState(), "", allDataChild.getCountryCode(),"chat");

                            startActivity(intent);
                        }
                    }, 3000);
                   // startActivity(intent);

                }
                else {
                    binding.progressBar.hide();
                    Log.e("channelResult.error(): ", String.valueOf(channelResult.error()));
//                    Toast.makeText(AvailableAdDetailsActivity.this, channelResult.error().getMessage(), Toast.LENGTH_LONG).show();

                    createChatAuthTokenForAdOwner(chatDetailsModel.getChat_user_id().replace("user",""),chatDetailsModel,false,"");

                }

                return null;
            }
        });
    }

this method is called if the other user is not registered with getstream before

private void createChatAuthTokenForAdOwner(String id,ChatDetailsModel chatDetailsModel, boolean isJob, String url){

        viewModel1.createChatAuthTokenForAdOwner(id).observe(this,responseBodyResponse -> {
                if (responseBodyResponse != null) {
                    this.responseBody = responseBodyResponse;
                    try {

                        JSONObject jsonObject = new JSONObject(responseBody.string());
                        if (jsonObject.getBoolean("status") == true) {
                            String data = jsonObject.getString("data");
                           // Utils.showToastLong(data,AvailableAdDetailsActivity.this);
                            Log.e( "ChatAuthTokenAdOwner: ",data );
                            newAdOwnerToken = data;
//                            StreamChat.clientInitialization(chatDetailsModel.getChat_user_id(),chatDetailsModel.getDisplay_slug(),newAdOwnerToken,chatDetailsModel.getAd_owner_img(),this);
                           /* HashMap<String, Object> extraData = new HashMap<>();
                            extraData.put("name", chatDetailsModel.getDisplay_slug());
                            extraData.put("image", chatDetailsModel.getAd_owner_img());

                            User user1 = new User(chatDetailsModel.getChat_user_id());
                            user1.setExtraData(extraData);

                            Log.e("NewClientInitialize: ", user1.getId());
                            Chat.getInstance().getClient().setUser(user1, newAdOwnerToken, new InitConnectionListener() {
                                @Override
                                public void onError(@NotNull ChatError error) {
                                   // super.onError(error);
                                   // Log.i("AdDetailsError", "setUser not completed");
                                    Log.i("AdDetailsError", error.getLocalizedMessage());
                                }

                                @Override
                                public void onSuccess(@NotNull ConnectionData data) {
                                  //  super.onSuccess(data);

                                    Log.i("AdDetails", "setUser completed");

                                }
                            });*/

                            //ChatClient client = AbentraApp.chat.getClient();

                            StreamChat.client.disconnect();

                            User user = new User();
                            user.setId(chatDetailsModel.getChat_user_id());
                            user.getExtraData().put("name", chatDetailsModel.getDisplay_slug());
                            user.getExtraData().put("image", chatDetailsModel.getAd_owner_img());
                            // User token is typically provided by your server when the user authenticates
                            //String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VtbWVyLWJyb29rLTIifQ.CzyOx8kgrc61qVbzWvhV1WD3KPEo5ZFZH-326hIdKz0";
                            StreamChat.client.setUser(user, newAdOwnerToken, new InitConnectionListener() {
                                @Override
                                public void onSuccess(ConnectionData data) {
                                    Log.i("AdDetails", "setUser completed"+chatDetailsModel.getChat_user_id());

                                    if (isJob && !url.isEmpty())
                                        createNewChannelForApplyJob(url);
                                    else
                                        createNewChannel();
//                                    StreamChat.client.disconnect();
                                }

                                @Override
                                public void onError(ChatError error) {
//                                    Toast.makeText(getApplicationContext(), error.toString(), Toast.LENGTH_LONG).show();
                                    Utils.showToast("Some error occured, Please try again later",getApplicationContext());
                                    Log.e("AdDetails", "setUser onError="+error.toString()+"||ID||"+chatDetailsModel.getChat_user_id());
                                }
                            });

                           /* new Handler().postDelayed(new Runnable() {
                                @Override
                                public void run() {
                                    binding.progressBar.hide();
                                    //createNewChannel();
                                }
                            }, 3000);*/

                        } else {
                            String errorMsg = jsonObject.getString("errormsg");
                            Utils.showToastLong(errorMsg, this);
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                } else {
                    Utils.showToast(this.getString(R.string.no_data), this);
                }

        });
    }
devUndef1ned commented 4 years ago

Hello, @abhirup-patra ! Thank you for the submitted details. It helped us to solve this issue. We released a new version of our UX components (4.3.0-beta1). Could you please check our fix? Does it solve your issue?

abhirup-patra commented 4 years ago

Hi @ogkuzmin a new error is coming up now. Unable to fetch the channelListViewModel.

import com.getstream.sdk.chat.viewmodel.ChannelListViewModel;
                                       ^
  symbol:   class ChannelListViewModel
  location: package com.getstream.sdk.chat.viewmodel
devUndef1ned commented 4 years ago

@abhirup-patra Now it's available via full name com.getstream.sdk.chat.viewmodel.channels.ChannelsViewModel

abhirup-patra commented 4 years ago

new errors- 1.

import com.getstream.sdk.chat.adapter.BaseAttachmentViewHolder;
                                     ^
  symbol:   class BaseAttachmentViewHolder
  location: package com.getstream.sdk.chat.adapter
zsmb13 commented 4 years ago

You'll find the BaseAttachmentViewHolder class in the com.getstream.sdk.chat.adapter.viewholder.attachment package in the latest version (4.3.0-beta-3). This and other changes are listed in the release notes.

abhirup-patra commented 4 years ago

@ogkuzmin

missing ChannelViewModelFactory symbol

Also this right now is not working anymore? Any other way out?

Channel channel2 = viewModel.getChannel();

i need to get the channel as i am using that in my code in this activity only

devUndef1ned commented 4 years ago

@abhirup-patra Are you looking channel to show its' content on the scree? Or do you want to create a new channel?

  1. For showing channel content there is com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel (you have to pass CID of channel to its' constructor)

  2. If you want to create new channel you can do it through com.getstream.sdk.chat.viewmodel.CreateChannelViewModel

abhirup-patra commented 4 years ago

@ogkuzmin let me send you the code about how i was doing before this change.

The ChannelViewModelFactory was used for custom design of the channel activity.

and the viewModel.getChannel was used to fetch the channel.

Sharing the code. Advice me how to do this in this new change.

private void initViewModel() {

        // setup the viewmodel, remember to also set the channel

        ChannelController channelController = client.channel(channelType, channelId);

        **ChannelViewModelFactory** factory = new **ChannelViewModelFactory**(getApplication(), channelType, channelId);
        **viewModel = new ViewModelProvider(this, factory).get(ChannelsViewModel.class);**
        messageListViewModel = new MessageListViewModel(cid,StreamChat.chatDomain,StreamChat.client);
        uploadViewModel = new ViewModelProvider(this).get(CustomPostAdViewModel.class);

        Channel channel2 = viewModel.getChannel();

        //abhirup changed 6/8/20
        MessageListViewModelBindingKt.bindView(messageListViewModel,binding.messageList,this);

        ChannelActivity activity = this;

        clickListeners(activity);

        binding.setViewModel(viewModel);
        binding.messageList.setAttachmentClickListener(activity);
//        binding.messageInput.setPermissionRequestListener(activity);
        binding.messageList.setViewHolderFactory(new BubbleMessageViewHolderFactory(activity));

//        binding.messageList.setViewModel(viewModel, activity);
        binding.messageInput.setViewModel(viewModel, activity, this);

        viewModel.getInitialized().observe(this, channel -> {

            if (from.equalsIgnoreCase("adDetails")) {

                binding.tvUserStatus.setText("Online");
            }
            else {

                if (channel2.getMembers().size()>=2) {

                    String u1 = channel2.getMembers().get(0).getUserId().substring(4);
                    String u2 = channel2.getMembers().get(1).getUserId().substring(4);

//

                    int userNumber = 0;

                    if (!u1.equalsIgnoreCase(String.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()))) {
                        userNumber = 0;
                    } else if (!u2.equalsIgnoreCase(String.valueOf(AppPreferences.getInstance().getLoginUserDetails().getData().getUser_details().getUser_id()))) {
                        userNumber = 1;
                    }

                    if (channel2.getMembers().get(userNumber).getUser().getOnline()) {
                        binding.tvUserStatus.setText("ONLINE");
                    } else {
                        Date date = channel2.getMembers().get(0).getUser().getLastActive();
                        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
                        String strDate = dateFormat.format(date);
                        // System.out.println("Converted String: " + strDate);
                        getTimeFromDate(strDate);
                        //getTimeFromDate((CharSequence)channel.createdBy.getLastActive());
                    }
                }

            }

        });

    }

this method was called in the onCreate of the activity and the other datas are fetched from the previous channel when clicked on it.

Please have a look at the code and advice accordingly. The bold texts are the parts where the compiler is not able to find the symbols anymore. They were previously available with the previous beta builds. 4.2.11 beta builds

abhirup-patra commented 4 years ago

please advice!

devUndef1ned commented 4 years ago

@abhirup-patra Sorry for delay! I read your code snippet. For your use case MessageListViewModel will do all this work. You can instantiate it via:

MessageListViewModel viewModel = new MessageListViewModel(cid, ChatDomain.instance(), ChatClient.instance())

This viewModel already has channel. You can get it via viewModel.getChannel()

About online status. You can get source of status updates (LiveData<Boolean>) from class Chat. For that invoke Chat.getInstance().getOnlineStatus()

Does it cover your requirements?

abhirup-patra commented 4 years ago

not really. getInitialised function is missing from the view model and 2ndly, i want to use a custom messageviewholder. I am not able to use it. It is throwing error.

Unable to start activity ComponentInfo{abentra.com/abentra.com.views.fragments.stream_chat.ChannelActivity}: java.lang.IllegalStateException: Adapter was already inited, please set MessageViewHolderFactory first

If you have any tutorial about the usage of custom message view holder please refer it here

devUndef1ned commented 4 years ago

@abhirup-patra If I got your intention correctly about getInitialized you can change it via

interface Chat {
...
fun setUser(
        user: User,
        token: String,
        callbacks: InitConnectionListener = object : InitConnectionListener() {}
    )
}

You pass your own callback for InitConnectionListener and then you'll get know when you are initialized

devUndef1ned commented 4 years ago

@abhirup-patra If you use library built-in MessageListView you can use its' method setMessageViewHolderFactory and pass your custom instance that extends MessageViewHolderFactory

abhirup-patra commented 4 years ago

@ogkuzmin i am using the same but it is throwing the above error of initlialising the messagelistviewholderfactory. I am not able to understand that.

I have used the built in library of messagelistview and have also created the custom messagelistviewholder

devUndef1ned commented 4 years ago

@abhirup-patra You have to set an instance of MessageViewHolderFactory and any other customisation factories before binding of view model and view happens. For example in onCreate. Our Views are not strongly required View Models, you can still use them separately.

abhirup-patra commented 4 years ago

@ogkuzmin

Tried creating instance of the messagevieholderfactory in oncreate still same error pops up.

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // we're using data binding in this example
        binding = DataBindingUtil.setContentView(this, R.layout.activity_channel);
        // most the business logic of the chat is handled in the ChannelViewModel view model
        binding.setLifecycleOwner(this);
        binding.messageList.setMessageViewHolderFactory(new MessageViewHolderFactory());
        client = ChatClient.instance();
        getIntentData();
        initViewModel();

    }

please advice how to do that. and the setViewModel function for messageListView is in think not available anymore

devUndef1ned commented 4 years ago

@abhirup-patra Please, check that you use lates version of our SDK (4.3.0-beta-4), make clean project and rebuild your new version. This exception occurs when you try to customise view after RecyclerView's adapter was initialised. It happens in method MessageListView.init. If you use our ViewModels, then it happens in MessageListViewModelBinding.bind. So your code seems correct.

Now in view there is not any setViewModel method because we don't want to force using MVVM pattern, you're free to use MVP, MV* or other pattern with our views. You can setup MessageListView with your own ViewHolderFactories, different handlers and update it state via method MessageListView::displayNewMessage where you have to pass an instance of MessageListItemWrapper:

data class MessageListItemWrapper(
    var loadingMore: Boolean = false,
    val hasNewMessages: Boolean = false,
    var listEntities: List<MessageListItem> = listOf(),
    val isTyping: Boolean = false,
    val isThread: Boolean = false
)

If you use MVVM pattern with custom view model you can see sources of MessageListViewModelBinding.bind as an example how to setup view with view model

abhirup-patra commented 4 years ago

@ogkuzmin

ok so i was able to solve it. it required me to set the custom messageviewholder in oncreate method.

Now regarding sending of message now.

Previously i just had to send the message as an object, now i have to send the message as a string along with a transformer. I have no idea about message transformer here. can you please guide me with this?

Here is my code snippet, what to use in place of the null keyword for message transformer? i am sending text as well as url for attachment views

binding.sendButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                binding.sendButton.setEnabled(false);
                message.setType("regular");
                message.setText(binding.messageInput.getText().toString());
                if (!message.getAttachments().isEmpty() && binding.messageInput.getText().toString().trim().isEmpty())
                    messageInputViewModel.sendMessage(message.getAttachments().get(0).getAssetUrl(), null);
                else if (message.getAttachments().isEmpty() && binding.messageInput.getText().toString().trim().isEmpty())
                    Utils.showToast("Cannot send empty message",getContext());
                else
                    messageInputViewModel.sendMessage(message.getText(),null);
                binding.messageInput.setText("");
                binding.sendButton.setEnabled(true);
                message = new Message();
                binding.imageViewLayout.setVisibility(GONE);
                binding.messageInput.setVisibility(VISIBLE);
                binding.imageAttachment.setVisibility(GONE);
                binding.textOfAttachment.setVisibility(GONE);
                binding.sendButton.setVisibility(VISIBLE);

            }
        });
devUndef1ned commented 4 years ago

If you want to customise your sending message you can pass lambda function that transform message (for example for each message you want to mention every chat member then you can pass such lambda:

 {
  mentionedUserIds.addAll(userId1, userId2 ... )
}

)

But if you don't need it you can omit it, or pass empty Unit.INSTANCE. Also I can mention that in our ViewModel there is method MessageInputViewModel::sendMessageWithAttachments

abhirup-patra commented 4 years ago

@ogkuzmin when i am sending a message as a string, it is getting sent without any prblem, but when trying to send a message as an url like i used to previously do, i am not able to do so.

i am initialising the view model like this viewModel = new ChannelsViewModelImpl();

it thows error in this line itself like this. kotlin.UninitializedPropertyAccessException: lateinit property instance has not been initialized

i am sending a message similar to this.

messageInputViewModel.sendMessage(message.getAttachments().get(0).getAssetUrl(), message1 -> Unit.INSTANCE);

which is wrong i guess

Previously what i was doing is that i was attaching the url to the attachment of the message and sending the message as a whole. It was lot easier that way. Now as i see, i will have to send a file as a message to send an attachment but i am uploading the file to another server and just want to send the url only. Please let me know how to send the message as a message object only. not regarding the presence of string message or anything

devUndef1ned commented 4 years ago

You have to use any view models only after you've successfully set user (Chat::setUser). That's why you got an exception with ChannelsViewModelImpl. Also, you can send your files uploaded to another server by creating your own message message transformation. In message there is the attachments field. You can add there your own attachment with url that you uploaded to server, additionally you can define mime type to such attachment, its' size if you want and other attributes. (see Attachment class)

abhirup-patra commented 4 years ago

@ogkuzmin

can you provide an example of how to do that? i have created the attachment with the url and mime and other stuffs. Just dont know how to use the transformation thing. Please help me out here. I am using java so if possible kindly provide a code in java

devUndef1ned commented 4 years ago

@abhirup-patra there is a possible code sample:

public class SomeFragment extends Fragment {

    private MessageInputViewModel viewModel;

    public void setViewModel(MessageInputViewModel viewModel) {
        this.viewModel = viewModel;
    }

    public void sendMessageWithAttachments(Collection<String> urls) {
        viewModel.sendMessage("", new AttachmentUrlTransformer(urls, "image"));
    }

    private static class AttachmentUrlTransformer implements Function1<Message, Unit> {

        private final Collection<String> urls;
        private final String type;

        public AttachmentUrlTransformer(Collection<String> urls, String type) {
            this.urls = urls;
            this.type = type;
        }

        @Override
        public Unit invoke(Message message) {
            List<Attachment> attachmentList = new ArrayList<>();
            for (String url: urls)  {
                Attachment attachment = new Attachment();
                attachment.setUrl(url);
                attachment.setType(type);
                attachmentList.add(attachment);
            }
            message.setAttachments(attachmentList);
            return Unit.INSTANCE;
        }
    }
}

You have to specify type of your attachments. It could be one of the followings: audio, image, video, file, giphy, link. Later we'll ad some others and provide possibility for custom types

abhirup-patra commented 4 years ago

thanks sir. This solves my issue. You can close it if you like. Thanks alot for the help though

JcMinarro commented 4 years ago

Thanks @ogkuzmin and @abhirup-patra I am closing this issue then