GetStream / pusher-chatkit-migration

Migrate Pusher Chatkit to Stream
11 stars 4 forks source link

[WIP] Pusher to stream webhook sync #6

Open thesyncim opened 4 years ago

thesyncim commented 4 years ago

WIP

thesyncim commented 4 years ago

@dcsena thanks for your input, I will address your comments tomorrow. (please bear with me since I'm not a JS developer :) )

dcsena commented 4 years ago

I have a message as followed:

{
  "payload": {
    "messages": [
      {
        "created_at": "2020-04-03T23:27:05Z",
        "id": ...,
        "parts": [
          {
            "content": "https://myurl.png",
            "type": "image/*"
          }
        ],
        "room_id": "...",
        "truncated": false,
        "updated_at": "2020-04-03T23:27:05Z",
        "user_id": "..."
      }
    ]
  },
  "metadata": {
    "created_at": "2020-04-03T23:27:05Z",
    "event_type": "v1.messages_created",
    "event_id": "...",
    "product": "chatkit"
  }
}

which I think will be ignored by your logic.

thesyncim commented 4 years ago

{ "content": "https://myurl.png", "type": "image/*" }

yes, currently this is skipped. will fix it.

(pusher has message.part.url for this use case)

Also, what's the best way to handle this? URL to get scrapped? attachment to be downloaded/migrated to our infrastructure?what if the content is not a link and instead is a base64 encoded image?

there are a lot of different ways to handle this, not sure what's the best one, and for unrecognized parts like this, I will just create a stream attachment with the same format:

{            
"content": "https://myurl.png",
"type": "image/*"
}

this will require some customization in the UI.

DMeechan commented 4 years ago

Any idea when this will be ready?

thesyncim commented 4 years ago

Any idea when this will be ready?

this is ready. feel free to adjust according to your needs and share the code with us so our converter does the mapping in the same way

please let us know if you have any issue

petervuoffspring commented 4 years ago

you call the wrong method getOrCreateRoom in class StreamSync. Should be getOrCreateChannelFromRoom I think

thesyncim commented 4 years ago

you call the wrong method getOrCreateRoom in class StreamSync. Should be getOrCreateChannelFromRoom I think

indeed, fixed

rapee commented 4 years ago

Hi, I've tried your webhook sync and found that streamClient often throws timeout error like this:

await this.streamClient().updateUsers(users);

// Error thrown
Error: timeout of 3000ms exceeded
    at createError (/chatkit-migration/webhook/node_modules/axios/lib/core/createError.js:16:15)
    at Timeout.handleRequestTimeout [as _onTimeout] (/chatkit-migration/webhook/node_modules/axios/lib/adapters/http.js:217:16)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)

I noticed that it happens to several other methods as well. My server location is in Singapore. Is this just me?

Do you support setting timeout for StreamChat client?