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

Fix join and part/leave on replay #567

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mm-go-irckit/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (ch *channel) Part(u *User, text string) {
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
Expand Down
28 changes: 24 additions & 4 deletions mm-go-irckit/userbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -725,8 +722,31 @@ 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, "")
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, "")
case p.Type == model.PostTypeAddToChannel:
if addedUserID, ok := props["addedUserId"].(string); ok {
ghost := u.createUserFromInfo(u.br.GetUser(addedUserID))
u.Srv.Channel(brchannel.ID).Join(ghost) //nolint:errcheck
}
case p.Type == model.PostTypeRemoveFromChannel:
if removedUserID, ok := props["removedUserId"].(string); ok {
ghost := u.createUserFromInfo(u.br.GetUser(removedUserID))
u.Srv.Channel(brchannel.ID).Part(ghost, "")
}
}

for _, post := range strings.Split(p.Message, "\n") {
Expand Down
Loading