42wim / matterircd

Connect to your mattermost or slack using your IRC-client of choice.
MIT License
294 stars 60 forks source link

Matterircd ignores server on login when DefaultServer is set in configuration #557

Open kot0dama opened 12 months ago

kot0dama commented 12 months ago

Hi,

When using a matterircd instance for connecting to multiple Mattermost servers, if there is a DefaultServer in the configuration, it is impossible to connect to any other server even though they're listed in Restrict.

Is DefaultServer actually a forced server option? Or is it a way to define the default server when the user does not specify a specific server to log into in the mattermost /msg?

Steps to reproduce

This yields:

[2023-10-24T01:20:35Z] DEBUG matterircd: flushing buffer: &irc.Message{Prefix:(*irc.Prefix)(nil), Command:"PRIVMSG", Params:[]string{"mattermost"}, Trailing:"login chat.charmhub.io charmhub kotodama token=REDACTED
", EmptyTrailing:false
}
[2023-10-24T01:20:35Z] DEBUG matterircd: Executed &irc.Message{Prefix:(*irc.Prefix)(nil), Command:"PRIVMSG", Params:[]string{"mattermost"}, Trailing:"<redacted>", EmptyTrailing:false} <nil>
[2023-10-24T01:20:35Z] DEBUG matterircd: args_len: 4
[2023-10-24T01:20:35Z] DEBUG matterircd: team: myteam
[2023-10-24T01:20:35Z] DEBUG matterircd: server: .com
[2023-10-24T01:20:35Z] DEBUG matterircd: restrict: [whatever.com chat.charmhub.io]
loggerlevel: debug
[2023-10-24T01:20:36Z]  INFO bridge/mattermost: login as kotodama (team: myteam) on whatever.com
[2023-10-24T01:20:36Z]  INFO matterclient: Found version 7.8.0.7.8.0.1d38ab1b122bcd3de4a230cfc66281cd.true
[2023-10-24T01:20:36Z] DEBUG matterclient: trying login myteam kotodama whatever.com
[2023-10-24T01:20:36Z] DEBUG matterclient: trying login with personal token
[2023-10-24T01:20:36Z] ERROR bridge/mattermost: login failed: Invalid or expired session, please login again., 

Thank you!

hloeung commented 12 months ago

Yeah, I think it's these bits of code:

https://github.com/42wim/matterircd/blame/master/mm-go-irckit/service.go#L122

https://github.com/42wim/matterircd/blame/master/mm-go-irckit/service.go#L147

So if either of DefaultServer or DefaultTeam, IIUC, they will be used instead of what team and server args are provided. I'll work on a fix when I get some spare cycles.