matterbridge icon indicating copy to clipboard operation
matterbridge copied to clipboard

XMPP media is presented as link

Open allilengyi opened this issue 4 years ago • 9 comments

Describe the bug When sending an image from protocol A to xmpp then one receives a clickable link but there is no media offered to download in the client. Sure, when clicking on the link, I can view the image in the browser.

Expected behavior I expect a file offered to download in xmpp clients

Screenshots/debug logs Screenshot from XMPP client Dino Bildschirmfoto vom 2021-01-30 23-18-19

Relevant part from the matterbridge log

[0911] DEBUG xmpp:         [handleXMPP:bridge/xmpp/xmpp.go:237] == Receiving xmpp.Chat{Remote:"[email protected]/XR Berlin Events", Type:"groupchat", Text:"https://xmpp-media.extinctionrebellion.de/xrberlinevents/afe34065/file_10.jpg", Subject:"", Thread:"", Ooburl:"", Oobdesc:"", ID:"0a0484bdf90bd9c5", ReplaceID:"", Roster:xmpp.Roster(nil), Other:[]string{}, OtherElem:[]xmpp.XMLElement(nil), Stamp:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}

Environment (please complete the following information):

  • OS: debian 9
  • Matterbridge version: 1.21.0 cf13fff7

Additional context Might this be an issue with the apache config? Permissions? ports? I checked that file sending/receiving works with the xmpp server that is used to bridge. Matterbridge config file.

[general]
#IgnoreFailureOnStart=true
MediaDownloadPath="/var/www/matterbridge/xrberlinevents"
MediaServerDownload="https://xmpp-media.extinctionrebellion.de/xrberlinevents"
MediaDownloadSize=5000000

[xmpp.xr_berlin_events]
Server="jabber.systemli.org:5222"
#Jid your userid
Jid="[email protected]"
Password=""
Muc="conference.jabber.systemli.org"
Nick="XR Berlin Events"
RemoteNickFormat=""

[telegram.tgbot]
#See https://core.telegram.org/bots#6-botfather 
#and https://www.linkedin.com/pulse/telegram-bots-beginners-marco-frau
Token=""
RemoteNickFormat=""
MessageFormat="HTMLNick"

# gateway.out = nachrichten werden von der bridge in diesen Kanal gesendet. *Kein* Traffic aus dem Kanal
[[gateway]]
name="XR_Berlin_Events"
enable=true

[[gateway.out]]
account="xmpp.xr_berlin_events"
channel="xr_berlin_events"

[[gateway.in]]
account="telegram.tgbot"
channel="-100xxx"

allilengyi avatar Jan 30 '21 22:01 allilengyi

Isn't this normal for images? You can always right-click and choose save link as ..

42wim avatar Feb 01 '21 20:02 42wim

To indicate that the link is a media share, the following should be included in the message:

  <x xmlns='jabber:x:oob'>
    <url>https://...</url>
  </x>

The URL in this fragment should match the URL provided in the <body> of the message. So a full message for the file https://example.com/cat.jpg would be:

<message from='[email protected]' to='[email protected]'>
  <body>https://example.com/cat.jpg</body>
  <x xmlns='jabber:x:oob'>
    <url>https://example.com/cat.jpg</url>
  </x>
</message>

This will trigger inline display in modern XMPP clients.

For more information see Modern XMPP: File transfer -> HTTP upload.

mwild1 avatar Feb 05 '21 13:02 mwild1

So I guess this issue is then a feature request to support HTTP Upload

allilengyi avatar Feb 05 '21 21:02 allilengyi

Well it seems there is already a URL for the file, so there is no need to "upload". Just include the metadata I mentioned if you know that the URL is meant to be an inline share/attachment.

mwild1 avatar Feb 05 '21 22:02 mwild1

I am not a software developer. I am currently looking into the code, to see where things have to be changed.

allilengyi avatar Feb 05 '21 22:02 allilengyi

I guess the problem is that Oobdesc is included into the message: https://github.com/42wim/matterbridge/blob/master/vendor/github.com/matterbridge/go-xmpp/xmpp.go#L878-L893

allilengyi avatar Feb 05 '21 22:02 allilengyi

Ah, thanks for the link to the source. Oobdesc is something that's ignored by most clients these days (they will insist on the message body matching the URL for various reasons, including preventing the ability to spoof URLs).

So it looks like just Ooburl needs to be set when the message from the other protocol is a share/attachment, and the right metadata will be included :)

mwild1 avatar Feb 05 '21 22:02 mwild1

Ooburl ist set https://github.com/42wim/matterbridge/blob/master/bridge/xmpp/xmpp.go#L342-L378 however, SendOOB does not include the <body> tag. I will see if I can modify the code und build matterbridge on my own successfully.

allilengyi avatar Feb 05 '21 22:02 allilengyi

To solve this issue, this might be helpfull: https://salsa.debian.org/mdosch/go-sendxmpp/-/blob/master/httpupload.go It think it would be a good idea to implement native xmpp upload to fix this issue.

sirdrakeistda avatar Apr 12 '22 11:04 sirdrakeistda