RocketChat / Rocket.Chat.Livechat

New Livechat client written in Preact
https://rocket.chat/omnichannel/live-chat
MIT License
246 stars 228 forks source link

image_url avoid adding ROOT_URL automatically #219

Open juliomac opened 5 years ago

juliomac commented 5 years ago

This is related to issue https://github.com/RocketChat/Rocket.Chat/issues/14202 and got solved there with Rocket Chat rc. 03

I am connecting to Rocket Chat from another Meteor app using DDP.connect and calling 'sendMessage' method as below.

      conn.apply('sendMessage',  [{
            _id: result.responseId,
            rid: message.rid,
            msg: result.fulfillmentText,
            attachments: [
                {
                title: "text",
                title_link: "https://link",
                text: "Rocket.Chat, the best open source chat",
                image_url:"https://myothersite.com/image.png"
                }
            ]
      }])

Server Setup Information:

Description:

Message is sent correctly but image is not rendered. The browser inspector shows that ROOT_URL is being added automatically to the image_url.

Inspector is showing: <img class="message__attachment__fHKkc message__attachment--image__1Hqn2" src="https://myrocketchatinstance.com.brhttps://myothersite.com/image.png">

Expected behavior:

It should have been just <img class="message__attachment__fHKkc message__attachment--image__1Hqn2" src="https://myothersite.com/image.png">

Attempts:

I have disabled on Administration->General-> the CDN prefix on all assets and I have cleared Administration->General Site URL and rebooted server. Still same results.

I have investigated the message database and it shows image_url correctly. It has not added ROOT_URL to it. So the issue occurs later on the process.

This is the HTML of the resulting response:

<li id="FsuNGdFCFJDDrGBjg" class="message-container__3plYK">
  <div class="message-avatars__2so-k">
     <div aria-label="User picture" class="avatar__2EzjE avatar--nobg__XAbXo message-avatars__avatar__2msz5">
         <img src="https://myrocketchatinstance.com.br/avatar/LibertasBot" alt="myalt" class="avatar__image__2g8Af">
      </div>
   </div>

<div class="message-content__3aoxV">
     <div class="message-bubble__1GudU message-bubble--nude__1DlEH">
       <div class="">
         <img src="https://myrocketchatinstance.com.brhttps://myothersite.com/image.png" class="image-attachment__inner__33czg">
       </div>
     </div>
     <div class="message-bubble__1GudU"><div class="">
        <div class="message-text__5cXOs">
           <p>Oi! Tudo bem? Posso ajudar?</p>
        </div>
      </div>
     </div>
    </div>
   <time datetime="2019-04-23T21:02:19.936Z" class="message-time__18le2">18:02</time>
</li>

It is working on the OLD version of Livechat. But it is not working working on the NEW Version of the LiveChat. The one that is called with 'https://chat.libertas.tur.br/livechat?version=1.0.0'

dudanogueira commented 4 years ago

Hi! I have the same problem, as reported here (at the wrong place last year. I didn't knew about this repo ): https://github.com/RocketChat/Rocket.Chat/issues/15829

This bug is still happening. It probably can fixed around this line and files: https://github.com/RocketChat/Rocket.Chat.Livechat/blob/develop/src/components/helpers.js#L119 https://github.com/RocketChat/Rocket.Chat.Livechat/blob/develop/src/api.js

I don't know meteor, so can't help much.

I will try to build to tamper with it, but it would be nice to have this working out of the box.

Livechat is a really cool feature.

Thanks!

dudanogueira commented 4 years ago

A workaround, at least for me, in order to send attachments to the user, is to use this endpoint for now: https://rocket.chat/docs/developer-guides/rest-api/rooms/upload/.

Instead of just passing the PDF link to the user, I will have to download the file (I am using a rasa bot), and upload it to the rocketchat using the api.

Not the ideal, but it works for now.