42wim / matterbridge

bridge between mattermost, IRC, gitter, xmpp, slack, discord, telegram, rocketchat, twitch, ssh-chat, zulip, whatsapp, keybase, matrix, microsoft teams, nextcloud, mumble, vk and more with REST API (mattermost not required!)
Apache License 2.0
6.47k stars 609 forks source link

[found reason] xmpp -> discrod not rot relaying #1868

Open blob42 opened 2 years ago

blob42 commented 2 years ago

Describe the bug Messages are not relayed from XMPP to Discord. They are however relayed from Discord to XMPP

To Reproduce Writing on Discord forwards to xmpp room. Writing on xmpp room does not relay to Discord

Expected behavior A clear and concise description of what you expected to happen.

Screenshots/debug logs

XMPP -> Discord log

matterbridge    | time="2022-07-31T17:34:51Z" level=info msg="<message xml:lang='en' to='matterbridge-bot@xmpp.sp4ke.xyz/162265007945353
67991875' from='inglorious@conference.xmpp.sp4ke.xyz/chakib' type='groupchat' id='81c1ab4e-05b7-407c-99b3-b9c7ed550128'><origin-id xmlns
='urn:xmpp:sid:0' id='81c1ab4e-05b7-407c-99b3-b9c7ed550128'/><composing xmlns='http://jabber.org/protocol/chatstates'/><no-store xmlns='
urn:xmpp:hints'/></message>" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:51Z" level=debug msg="== Receiving xmpp.Chat{Remote:"inglorious@conference.xmpp.sp4ke.xyz/chaki
b", Type:"groupchat", Text:"", Subject:"", Thread:"", Ooburl:"", Oobdesc:"", ID:"81c1ab4e-05b7-407c-99b3-b9c7ed550128", ReplaceID:"", Ro
ster:xmpp.Roster(nil), Other:[]string{"", "", ""}, OtherElem:[]xmpp.XMLElement{xmpp.XMLElement{XMLName:xml.Name{Space:"urn:xmpp:sid:0",
Local:"origin-id"}, InnerXML:""}, xmpp.XMLElement{XMLName:xml.Name{Space:"http://jabber.org/protocol/chatstates", Local:"composing"}, In
nerXML:""}, xmpp.XMLElement{XMLName:xml.Name{Space:"urn:xmpp:hints", Local:"no-store"}, InnerXML:""}}, Stamp:time.Date(1, time.January,
1, 0, 0, 0, 0, time.UTC)}" func=handleXMPP file="bridge/xmpp/xmpp.go:298" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=info msg="<message xml:lang='en' to='matterbridge-bot@xmpp.sp4ke.xyz/162265007945353
67991875' from='inglorious@conference.xmpp.sp4ke.xyz/chakib' type='groupchat' id='d48a1290-5056-4726-b7de-bc52c07aa894'><archived by='in
glorious@conference.xmpp.sp4ke.xyz' id='1659288892043660' xmlns='urn:xmpp:mam:tmp'/><stanza-id by='inglorious@conference.xmpp.sp4ke.xyz'
 id='1659288892043660' xmlns='urn:xmpp:sid:0'/><origin-id xmlns='urn:xmpp:sid:0' id='d48a1290-5056-4726-b7de-bc52c07aa894'/><active xmln
s='http://jabber.org/protocol/chatstates'/><markable xmlns='urn:xmpp:chat-markers:0'/><body>hello</body></message>" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=debug msg="== Receiving xmpp.Chat{Remote:"inglorious@conference.xmpp.sp4ke.xyz/chaki
b", Type:"groupchat", Text:"hello", Subject:"", Thread:"", Ooburl:"", Oobdesc:"", ID:"d48a1290-5056-4726-b7de-bc52c07aa894", ReplaceID:"
", Roster:xmpp.Roster(nil), Other:[]string{"", "", "", "", ""}, OtherElem:[]xmpp.XMLElement{xmpp.XMLElement{XMLName:xml.Name{Space:"urn:
xmpp:mam:tmp", Local:"archived"}, InnerXML:""}, xmpp.XMLElement{XMLName:xml.Name{Space:"urn:xmpp:sid:0", Local:"stanza-id"}, InnerXML:""
}, xmpp.XMLElement{XMLName:xml.Name{Space:"urn:xmpp:sid:0", Local:"origin-id"}, InnerXML:""}, xmpp.XMLElement{XMLName:xml.Name{Space:"ht
tp://jabber.org/protocol/chatstates", Local:"active"}, InnerXML:""}, xmpp.XMLElement{XMLName:xml.Name{Space:"urn:xmpp:chat-markers:0", L
ocal:"markable"}, InnerXML:""}}, Stamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC)}" func=handleXMPP file="bridge/xmpp/xmpp.go:2
98" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=debug msg="Requesting avatar data" func=handleXMPP file="bridge/xmpp/xmpp.go:313" pr
efix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=debug msg="<= Sending message from chakib on xmpp.sp4ke to gateway" func=handleXMPP
file="bridge/xmpp/xmpp.go:342" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=debug msg="<= Message is config.Message{Text:"hello", Channel:"inglorious", Username
:"chakib", UserID:"inglorious@conference.xmpp.sp4ke.xyz/chakib", Avatar:"", Account:"xmpp.sp4ke", Event:"", Protocol:"", Gateway:"", Par
entID:"", Timestamp:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), ID:"d48a1290-5056-4726-b7de-bc52c07aa894", Extra:map[string][]i
nterface {}(nil)}" func=handleXMPP file="bridge/xmpp/xmpp.go:343" prefix=xmpp
matterbridge    | time="2022-07-31T17:34:52Z" level=info msg="<iq xml:lang='en' to='matterbridge-bot@xmpp.sp4ke.xyz/16226500794535367991
875' from='inglorious@conference.xmpp.sp4ke.xyz/chakib' type='error' id='items1'><error type='cancel'><feature-not-implemented xmlns='ur
n:ietf:params:xml:ns:xmpp-stanzas'/></error></iq>" prefix=xmpp
matterbridge    | time="2022-07-31T17:36:16Z" level=debug msg=PING func=func1 file="bridge/xmpp/xmpp.go:265" prefix=xmpp
matterbridge    | time="2022-07-31T17:36:16Z" level=info msg="<iq xml:lang='en' to='matterbridge-bot@xmpp.sp4ke.xyz/16226500794535367991
875' from='xmpp.sp4ke.xyz' type='result' id='c2s1'/>" prefix=xmpp

Environment (please complete the following information):

Additional context Bot intergration on the Discord server

config

[discord]
        [discord.inglorious]

        Token="***"
        Server="***"
        AutoWebhooks=true
        RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
        debug=true

[xmpp]
        [xmpp.sp4ke]
        Server="xmpp.sp4ke.xyz"
        Jid="matterbridge-bot@xmpp.sp4ke.xyz"
        Password="***"
        RemoteNickFormat="[{PROTOCOL}] <{NICK}> "
        Muc="conference.xmpp.sp4ke.xyz"
        Nick="[mb-bot]"
        debug=true

[[gateway]]
name="inglorious"
enable=true

[[gateway.inout]]
account="discord.inglorious"
channel="divinity"

[[gateway.inout]]
account="xmpp.sp4ke"
channel="Inglorious"
blob42 commented 1 year ago

I found the solution for the problem. I am using an uppercase in the channel name Inglorious for XMPP which is allowed in xmpp since the room name has an uppercase. However the channelID in gateway/gateway.go is fully lowercase. The code at this if statement is the reason.

I can make a pull request to handle this issue but I was wondering if it should be handled in the XMPP bridge by translating the channel to lowercase OR just adding a warning in the doc ?