Matterbridge: Attachements from telegram to rocket chat should be uploaded as attachments not links

Created on 7 Feb 2019  路  4Comments  路  Source: 42wim/matterbridge

Describe the bug
I have gateway rocket chat <-> telegram. MediaServer is configured and working. When I upload a file to telegram it appears as a link in rocket chat. Not attachment. Seems like #356 but rocket chat instead of mattermost.

Rocket chat has api call to upload file: https://rocket.chat/docs/developer-guides/rest-api/rooms/upload/

To Reproduce
Configure telegram -> rocket chat gateway and MediaServer. Try to upload file to telegram.

Expected behavior
Attached file should be uploaded as attachment to rocket chat. Not as a link.

Environment (please complete the following information):

  • OS: linux-amd64
  • Matterbridge version: version: 1.13.1 1d39c77

Additional context
config:

[general]
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
StripNick=false
MediaServerUpload="https://upload:[email protected]:8443/upload"
MediaServerDownload="https://upload:[email protected]:8443"

[rocketchat]
[rocketchat.chat]
WebhookURL="https://a.chat/hooks/e/Tm"
WebhookBindAddress="0.0.0.0:9998"
Nick="bridgebot"

[telegram.test]
Token="7Y"
RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
UseFirstName=false
[[gateway]]
name="test"
enable=true
[[gateway.in]]
account="telegram.test"
channel="-373"
[[gateway.in]]
account="telegram.test"
channel="-24"
[[gateway.in]]
account="telegram.test"
channel="-33"
[[gateway.out]]
account="rocketchat.chat"
channel="#test"

debug log:
[1320] DEBUG telegram: == Receiving event: &tgbotapi.Message{MessageID:43, From:(tgbotapi.User)(0xc000550050), Date:1549542988, Chat:(tgbotapi.Chat)(0xc0005322d0), ForwardFrom:(tgbotapi.User)(nil), ForwardFromChat:(tgbotapi.Chat)(nil), ForwardFromMessageID:0, ForwardDate:0, ReplyToMessage:(tgbotapi.Message)(nil), EditDate:0, Text:"", Entities:([]tgbotapi.MessageEntity)(nil), Audio:(tgbotapi.Audio)(nil), Document:(tgbotapi.Document)(nil), Animation:(tgbotapi.ChatAnimation)(nil), Game:(tgbotapi.Game)(nil), Photo:([]tgbotapi.PhotoSize)(0xc0000ba7c0), Sticker:(tgbotapi.Sticker)(nil), Video:(tgbotapi.Video)(nil), VideoNote:(tgbotapi.VideoNote)(nil), Voice:(tgbotapi.Voice)(nil), Caption:"", Contact:(tgbotapi.Contact)(nil), Location:(tgbotapi.Location)(nil), Venue:(tgbotapi.Venue)(nil), NewChatMembers:([]tgbotapi.User)(nil), LeftChatMember:(tgbotapi.User)(nil), NewChatTitle:"", NewChatPhoto:([]tgbotapi.PhotoSize)(nil), DeleteChatPhoto:false, GroupChatCreated:false, SuperGroupChatCreated:false, ChannelChatCreated:false, MigrateToChatID:0, MigrateFromChatID:0, PinnedMessage:(tgbotapi.Message)(nil), Invoice:(tgbotapi.Invoice)(nil), SuccessfulPayment:(tgbotapi.SuccessfulPayment)(nil), PassportData:(tgbotapi.PassportData)(nil)}
[1321] DEBUG telegram: Trying to download "file_3.jpg" with size 533494
[1321] DEBUG telegram: Download OK "file_3.jpg" 533494
[1321] DEBUG telegram: <= Sending message from IlIIlllIIl on telegram.test to gateway
[1321] DEBUG telegram: <= Message is config.Message{Text:"", Channel:"-3", Username:"IlIIlllIIl", UserID:"53", Avatar:"", Account:"telegram.test", Event:"", Protocol:"", Gateway:"", ParentID:"", Timestamp:time.Time{wall:0x0, ext:0, loc:(
time.Location)(nil)}, ID:"43", Extra:map[string][]interface {}{"file":[]interface {}{config.FileInfo{Name:"file_3.jpg", Data:([]uint8)(0xc0000ba2e0), Comment:"", URL:"", Size:0, Avatar:false, SHA:""}}}}
[1321] DEBUG gateway: mediaserver upload url: https://upload:[email protected]:8443/upload/cd/file_3.jpg
[1321] DEBUG gateway: mediaserver download URL = https://upload:[email protected]:8443/cd/file_3.jpg
[1321] DEBUG gateway: => Sending config.Message{Text:"", Channel:"-37", Username:"IlIIlllIIl", UserID:"53", Avatar:"", Account:"telegram.test", Event:"", Protocol:"", Gateway:"test", ParentID:"", Timestamp:time.Time{wall:0xbf0f2773356021dd, ext:1321306463352, loc:(
time.Location)(0x19f97e0)}, ID:"43", Extra:map[string][]interface {}{"file":[]interface {}{config.FileInfo{Name:"file_3.jpg", Data:([]uint8)(0xc0000ba2e0), Comment:"", URL:"https://upload:[email protected]:8443/cd/file_3.jpg", Size:0, Avatar:false, SHA:"cd66f2e7"}}}} from telegram.test (-37) to rocketchat.achat (#test)
[1321] DEBUG rocketchat: => Receiving config.Message{Text:"", Channel:"#test", Username:"[telegram] ", UserID:"53", Avatar:"", Account:"telegram.test", Event:"", Protocol:"", Gateway:"test", ParentID:"", Timestamp:time.Time{wall:0xbf0f2773356021dd, ext:1321306463352, loc:(
time.Location)(0x19f97e0)}, ID:"", Extra:map[string][]interface {}{"file":[]interface {}{config.FileInfo{Name:"file_3.jpg", Data:(*[]uint8)(0xc0000ba2e0), Comment:"", URL:"https://upload:[email protected]:8443/cdfile_3.jpg", Size:0, Avatar:false, SHA:"cd66f2e7"}}}}

enhancement

Most helpful comment

@iprok I'm going to take a look at this.
It's going to be a refactor of the rocketchat bridge using the streaming and rest API besides the webhooks.

Regarding your donation, thank you! But for now I'm getting my server hosting sponsored by DigitalOcean and this project is still a hobby.

I'd really appreciate it though if you would donate it to EDRi or EFF instead!

All 4 comments

We are still highly interested in matterbridge support of attachments in rocket chat. If it can speed up resolving this issue and #705 we would be glad to donate $100.

@iprok I'm going to take a look at this.
It's going to be a refactor of the rocketchat bridge using the streaming and rest API besides the webhooks.

Regarding your donation, thank you! But for now I'm getting my server hosting sponsored by DigitalOcean and this project is still a hobby.

I'd really appreciate it though if you would donate it to EDRi or EFF instead!

Just merged the refactor, to have uploads (and also edits/deletes) work.
This will only work with a (bot) user which you'll have to create.
Webhooks can't support any of those new features.

https://github.com/42wim/matterbridge/blob/716751cf7685471bbc969e19fe26f23e66f3c0b4/matterbridge.toml.sample#L895-L904

The edits/deletes only work for incoming messages from other bridges, the rocket chat libraries have not yet support to show messages edited or deleted from rocketchat self to other bridges.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

patcon picture patcon  路  3Comments

w3bb picture w3bb  路  6Comments

cwchristerw picture cwchristerw  路  6Comments

Gummikavalier picture Gummikavalier  路  4Comments

strugee picture strugee  路  6Comments