Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{NICK} Uses Rocket.Chat Username, Not Nickname #631

Open
jamoffat opened this issue Dec 2, 2018 · 4 comments
Open

{NICK} Uses Rocket.Chat Username, Not Nickname #631

jamoffat opened this issue Dec 2, 2018 · 4 comments

Comments

@jamoffat
Copy link
Contributor

jamoffat commented Dec 2, 2018

Describe the bug
When bridging a Rocket.Chat room, the user's Rocket.Chat username is displayed on other Discord rather than their nickname. This works fine in reverse, i.e., Discord nickname is properly displayed on Rocket.Chat, however.

To Reproduce
Bridge Rocket.Chat with Discord, change your nickname on Discord to be different from your username. Post messages from Rocket.Chat to Discord, observe behaviour. Notice behaviour of the inverse case.

Expected behavior
Bridge should use the nickname for the {NICK} formatting option, rather than the username.

Screenshots/debug logs
Rocket.Chat:
image

Discord:
image

Environment (please complete the following information):

  • OS: Debian 9
  • Matterbridge version: 1.12.0

Additional context

[discord.redacted]
Token="redacted"
Server="redacted"

ShowEmbeds=false
UseUserName=false
EditDisable=false
EditSuffix=" (edited)"
Label=""
RemoteNickFormat="<{NICK}> "
ShowJoinPart=false
StripNick=false
ShowTopicChange=false

[rocketchat.redacted]
WebhookURL="http://rocketchat:3000/hooks/redacted/redacted"
WebhookBindAddress="0.0.0.0:9999"
Nick="rocket.cat"
NoTLS=true
SkipTLSVerify=false
PrefixMessagesWithNick=true
Label=""
RemoteNickFormat="<{NICK}> "
ShowJoinPart=false
StripNick=false
ShowTopicChange=false

[general]
RemoteNickFormat="<{NICK}> "

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

[[gateway.inout]]
account="discord.redacted"
channel="testing"

    [gateway.inout.options]
    webhookurl="https://discordapp.com/api/webhooks/redacted/redacted"

[[gateway.inout]]
account="rocketchat.redacted"
channel="#testing"
@patcon
Copy link
Contributor

patcon commented Dec 2, 2018

Thanks @jamoffat! So you're saying that you would prefer instead of rocketchat "username" to be relayed, you would like "name" (sometimes called "Real Name" in UI, it seems).
Re: https://rocket.chat/docs/developer-guides/rest-api/users/info/#example-result-regular-user-callee

This seems to be what you'd need to change, if others think this change makes sense:

func (b *Brocketchat) handleRocketHook() {
for {
message := b.rh.Receive()
b.Log.Debugf("Receiving from rockethook %#v", message)
// do not loop
if message.UserName == b.GetString("Nick") {
continue
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.UserName, b.Account)
b.Remote <- config.Message{Text: message.Text, Username: message.UserName, Channel: message.ChannelName, Account: b.Account, UserID: message.UserID}
}
}

Also, #614 might let you set this as you please to any value on user object.

@jamoffat
Copy link
Contributor Author

jamoffat commented Dec 2, 2018

Thanks @jamoffat!

No problem @patcon! I spent ages tinkering with various settings and scouring the repo before asking, but discovered myself diving down a few too many "rabbit holes" so thought it might be quicker to ask on here. 😄

So you're saying that you would prefer instead of rocketchat "username" to be relayed, you would like "name" (sometimes called "Real Name" in UI, it seems).
Re: https://rocket.chat/docs/developer-guides/rest-api/users/info/#example-result-regular-user-callee

Bingo, it is given as "Name" in the Rocket.Chat UI as shown below (via User -> My Account -> Profile):
image

And as you've correctly pointed out, it is also referred to as "Real Name" elsewhere within Rocket.Chat sometimes:
image

So I think it is indeed "name" rather than "username" that I want relayed here.

This seems to be what you'd need to change, if others think this change makes sense:

func (b *Brocketchat) handleRocketHook() {
for {
message := b.rh.Receive()
b.Log.Debugf("Receiving from rockethook %#v", message)
// do not loop
if message.UserName == b.GetString("Nick") {
continue
}
b.Log.Debugf("<= Sending message from %s on %s to gateway", message.UserName, b.Account)
b.Remote <- config.Message{Text: message.Text, Username: message.UserName, Channel: message.ChannelName, Account: b.Account, UserID: message.UserID}
}
}

I had wondered about this function specifically and whether it was the key to solving this. I'll run a few tests and see what I can come up with! Thanks for your help! 😀

@patcon
Copy link
Contributor

patcon commented Dec 2, 2018

No prob! I can't speak for @42wim and whether this wouod be a mergeable change, but in a pinch I can help you build your own binary, if that's helpful. (Perhaps you're more skilled at golang, but it took me awhile to figure my system out at first!)

Also, does rocketchat notify on both name and username? I suspect that would be the sort of thing that would be a decider :)

@jamoffat
Copy link
Contributor Author

jamoffat commented Dec 17, 2018

No prob! I can't speak for @42wim and whether this wouod be a mergeable change, but in a pinch I can help you build your own binary, if that's helpful. (Perhaps you're more skilled at golang, but it took me awhile to figure my system out at first!)

I'm going to throw my hands up here and say I'm at your mercy on this one @patcon! I've put together a development environment which is getting close to where I need it to be, but I have to admit the finer points of actually getting the quoted code above into a workable binary is proving challenging! If you don't mind terribly much I would sincerely appreciate your assistance in producing a binary if this isn't significant enough to be merged! :)

Also, does rocketchat notify on both name and username? I suspect that would be the sort of thing that would be a decider :)

Rocket.chat notifies on username, i.e., "@jamoffat" will notify however "James Moffat" will not. That's not too much of an issue though, it's more important for names to be displayed rather than usernames for our use-case -- I think at this point anyway! :)

Cheers @patcon for all your help! Legend!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants