diff --git a/mm-go-irckit/channel.go b/mm-go-irckit/channel.go index 7d4c7bd1..70e9aed6 100644 --- a/mm-go-irckit/channel.go +++ b/mm-go-irckit/channel.go @@ -162,14 +162,17 @@ func (ch *channel) Part(u *User, text string) { if _, ok := ch.usersIdx[u.ID()]; !ok { ch.mu.Unlock() - + for _, to := range ch.usersIdx { + if !to.Ghost { + to.Encode(msg) + } + } u.Encode(&irc.Message{ Prefix: ch.Prefix(), Command: irc.ERR_NOTONCHANNEL, Params: []string{ch.name}, - Trailing: "You're not on that channel", + Trailing: "User not on that channel", }) - return } @@ -335,8 +338,20 @@ func (ch *channel) Join(u *User) error { return nil } + msg := &irc.Message{ + Prefix: u.Prefix(), + Command: irc.JOIN, + Params: []string{ch.name}, + } + if _, exists := ch.usersIdx[u.ID()]; exists { ch.mu.Unlock() + for _, to := range ch.usersIdx { + // only send join messages to real users + if !to.Ghost { + to.Encode(msg) + } + } return nil } @@ -354,12 +369,6 @@ func (ch *channel) Join(u *User) error { return nil } - msg := &irc.Message{ - Prefix: u.Prefix(), - Command: irc.JOIN, - Params: []string{ch.name}, - } - // send regular users a notification of the join ch.mu.RLock() diff --git a/mm-go-irckit/userbridge.go b/mm-go-irckit/userbridge.go index e6511d54..111ac298 100644 --- a/mm-go-irckit/userbridge.go +++ b/mm-go-irckit/userbridge.go @@ -698,9 +698,6 @@ func (u *User) addUserToChannelWorker(channels <-chan *bridge.ChannelInfo, throt // traverse the order in reverse for i := len(mmPostList.Order) - 1; i >= 0; i-- { p := mmPostList.Posts[mmPostList.Order[i]] - if p.Type == model.PostTypeJoinLeave { - continue - } if p.DeleteAt > p.CreateAt { continue @@ -725,8 +722,27 @@ func (u *User) addUserToChannelWorker(channels <-chan *bridge.ChannelInfo, throt nick = botname } - if p.Type == model.PostTypeAddToTeam || p.Type == model.PostTypeRemoveFromTeam { + switch { + case p.Type == model.PostTypeAddToTeam: + nick = systemUser + ghost := u.createUserFromInfo(user) + u.Srv.Channel(brchannel.ID).Join(ghost) //nolint:errcheck + case p.Type == model.PostTypeRemoveFromTeam: nick = systemUser + ghost := u.createUserFromInfo(user) + u.Srv.Channel(brchannel.ID).Part(ghost, "") //nolint:errcheck + case p.Type == model.PostTypeJoinChannel: + ghost := u.createUserFromInfo(user) + u.Srv.Channel(brchannel.ID).Join(ghost) //nolint:errcheck + case p.Type == model.PostTypeLeaveChannel: + ghost := u.createUserFromInfo(user) + u.Srv.Channel(brchannel.ID).Part(ghost, "") //nolint:errcheck + case p.Type == model.PostTypeAddToChannel: + ghost := u.createUserFromInfo(u.br.GetUser(props["addedUserId"])) + u.Srv.Channel(brchannel.ID).Join(ghost) //nolint:errcheck + case p.Type == model.PostTypeRemoveFromChannel: + ghost := u.createUserFromInfo(u.br.GetUser(props["removedUserId"])) + u.Srv.Channel(brchannel.ID).Part(ghost, "") //nolint:errcheck } for _, post := range strings.Split(p.Message, "\n") {