Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

[Suggestion] Rocket Chat files format

Open juliocbcotta opened this issue 10 years ago • 15 comments

Below I have a msg sent into the demo with a image file

{  
            "_id":"6za25dT2cerChWeTn",
            "rid":"FnMWBpumDYqi2LaXzKdgnfaCiHf2yxPiaX",
            "msg":"",
            "file":{  
               "_id":"YvdQMNiAYtjWmuYbw"
            },
            "groupable":false,
            "attachments":[  
               {  
                  "title":"File Uploaded: Screen Shot 2015-12-27 at 12.55.25 PM.png",
                  "title_link":"/ufs/rocketchat_uploads/YvdQMNiAYtjWmuYbw/Screen Shot 2015-12-27 at 12.55.25 PM.png",
                  "image_url":"/ufs/rocketchat_uploads/YvdQMNiAYtjWmuYbw/Screen Shot 2015-12-27 at 12.55.25 PM.png",
                  "image_type":"image/png",
                  "image_size":42365
               }
            ],
            ....

and here we have an audio file

{  
            "_id":"PM8spDaB5mxqrJBis",
            "rid":"KdgnfaCiHf2yxPiaXaFZWmPRqvpbZprmjj",
            "groupable":false,
            "msg":"",
            "attachments":[  
               {  
                  "audio_type":"audio/wav",
                  "audio_size":136236,
                  "title":"*File Uploaded*: audiorecord.wavnhttps://demo.rocket.chat/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
                  "audio_url":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
                  "title_link":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav"
               }
            ],
            "file":{  
               "_id":"17b0a6ce56a94b9e8"
            }
...
  1. I don't understand why "file" is not a list or why "attachments" is a list. As far as I understand, each file has its own "file" and an entry in the "atttachments" list. I can see that having the "attachments" field as a list open doors to a multi-file upload option in a single message, but so file should be a list too, right? If someone could clarify that to me, I would be very glad.

  2. Why the need to distinct audio and image files? I know that those files have a special way to me shown or played, I guess the media type should be enough to know how to handle the file. It would be a bit troublesome to deal with all possible file formats in the client if more file formats are included. So I would like to change it to a more general format without the prefixes.

 "attachments":[  
               {  
                  "type":"audio/wav",
                  "size":136236,
                  "title":"*File Uploaded*: audiorecord.wavnhttps://demo.rocket.chat/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
                  "url":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav",
                  "title_link":"/ufs/rocketchat_uploads/17b0a6ce56a94b9e8.wav"
               }
            ],

juliocbcotta avatar Dec 29 '15 02:12 juliocbcotta

Looks like a good idea to me

engelgabriel avatar Dec 30 '15 00:12 engelgabriel

:+1: Saves tons of headache for iOS and many more external integrators to come.

Sing-Li avatar Dec 30 '15 00:12 Sing-Li

maybe for clarity

type: "audio" mime_type: "audio/wav"

That way if need be things can be handled differently. Simplifies and covers our bases.

geekgonecrazy avatar Dec 30 '15 00:12 geekgonecrazy

@BugsBunnyBR

  1. One message can have only one file upload, attachments are not related with file upload, they are only the way to show the file preview, so attachments can have multiple items.

  2. Was developed that way to be compatible with the slack format, you can have the image and audio in the same attachment.

rodrigok avatar Dec 30 '15 11:12 rodrigok

I knew that was a reason for this... :(

engelgabriel avatar Dec 30 '15 12:12 engelgabriel

Thanks to all replies here!

  1. Ok, multiple file uploads per message is not possible. Not a problem, one client could just send multiple messages .:-)

  2. Ok, slack integration... 2a) How is it possible to have image and audio in the same attachment (which is related to the preview of just one file)? Could you provide an example? I am curious. :-D

2b) The slack format does not seems to help the Rocket Chat clients. Would it be too much trouble to have an integration layer separated from the RC protocol ? I have other API concerns that I would like to share, but it would be another topic and I will do so only if the slack integration is not a main issue.

juliocbcotta avatar Dec 30 '15 16:12 juliocbcotta

Seems like we should first and for most design our attachment system well. In my opinion if we design everything to be like slack.... We are doing it very wrong.... Just because they do it doesn't make it right

geekgonecrazy avatar Dec 30 '15 16:12 geekgonecrazy

I am going to agree here with @geekgonecrazy and @BugsBunnyBR. Yes having Slack compatibility is very good, and required, I feel we need to have something more efficient for ourselves than Slack's.

graywolf336 avatar Dec 30 '15 16:12 graywolf336

This happens all the time.

A) Internal inter-modules APIs can be designed and tuned for performance and efficiency - at the expense of all other factors.

B) Automated integration APIs should be designed for 100% compatibility with mating systems.

C) External human programmer-facing APIs - if we qualify message formats to be such - should be designed for ease of understanding and simplicity of 'calling code' development.

One solution is to have transformers between (A) <-> (C) or (A) <-> (B)

Personally, I think message formats belong to (A) and that iOS and Android native callers should contort themselves to gain performance/efficiency adapting to (A) without a transforming layer.

IMHO - Slack compatibility should be (B) and an (A)<->(B) transformer makes sense.

Sing-Li avatar Dec 30 '15 17:12 Sing-Li

@kormic with the iOS side of things might want to take a look at this as well.

geekgonecrazy avatar Dec 30 '15 22:12 geekgonecrazy

@BugsBunnyBR Attachments are not related with file uploads, you can use it to show a file preview or anything else. I'm not saying that we can't change or improve this. Any integration can you the attachments to show things, can be an image and an audio together.

The slack api do not implement the audio and video tags, I added that, we can change that but we should be compatible with slack.

rodrigok avatar Jan 02 '16 19:01 rodrigok

I am on mobile these days...definitely will take a look into this! :)

kormic avatar Jan 04 '16 09:01 kormic

So... Is there any conclusion or change that will happen from this issue?

juliocbcotta avatar Jan 08 '16 19:01 juliocbcotta

It seems like at the very least the properties on attachment should be changed to be generic like you suggested. So that you aren't having to look for a bunch of different attributes to determine what the attachment is.

geekgonecrazy avatar Jan 11 '16 15:01 geekgonecrazy

Hey everybody, sorry for the delay. While I m dealing with other issues right now and I can't have the whole picture, this sounds a good idea to me too. It will be easier to handle the file...

kormic avatar Jan 13 '16 13:01 kormic