Kick users who don't belong in portal (ref #6)
This commit is contained in:
parent
13a8d9b9a9
commit
b45185beab
1 changed files with 27 additions and 0 deletions
27
portal.go
27
portal.go
|
@ -748,6 +748,33 @@ func (portal *Portal) SyncParticipants(source *User, metadata *gmproto.Conversat
|
|||
portal.OtherUserID = firstParticipant.ID.ParticipantID
|
||||
changed = true
|
||||
}
|
||||
if portal.MXID != "" {
|
||||
members, err := portal.MainIntent().JoinedMembers(portal.MXID)
|
||||
if err != nil {
|
||||
portal.zlog.Warn().Err(err).Msg("Failed to get joined members")
|
||||
} else {
|
||||
delete(members.Joined, portal.bridge.Bot.UserID)
|
||||
delete(members.Joined, source.MXID)
|
||||
for _, userID := range userIDs {
|
||||
delete(members.Joined, userID)
|
||||
}
|
||||
for userID := range members.Joined {
|
||||
_, err = portal.MainIntent().KickUser(portal.MXID, &mautrix.ReqKickUser{
|
||||
UserID: userID,
|
||||
Reason: "User is not participating in chat",
|
||||
})
|
||||
if err != nil {
|
||||
portal.zlog.Warn().Err(err).
|
||||
Str("user_id", userID.String()).
|
||||
Msg("Failed to kick extra user from portal")
|
||||
} else {
|
||||
portal.zlog.Debug().
|
||||
Str("user_id", userID.String()).
|
||||
Msg("Kicked extra user from portal")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userIDs, changed
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue