diff --git a/internal/db/member.go b/internal/db/member.go index 2bff0cc..5ce96c7 100644 --- a/internal/db/member.go +++ b/internal/db/member.go @@ -21,7 +21,7 @@ func WithRoomMemberRole(role model.RoomMemberRole) CreateRoomMemberRelationConfi } } -func WithRoomMemberRelationPermissions(permissions model.RoomMemberPermission) CreateRoomMemberRelationConfig { +func WithRoomMemberPermissions(permissions model.RoomMemberPermission) CreateRoomMemberRelationConfig { return func(r *model.RoomMember) { r.Permissions = permissions } diff --git a/internal/op/room.go b/internal/op/room.go index ba80db4..ca2bc5c 100644 --- a/internal/op/room.go +++ b/internal/op/room.go @@ -206,23 +206,26 @@ func (r *Room) LoadOrCreateRoomMember(userID string) (*model.RoomMember, error) conf = append( conf, db.WithRoomMemberStatus(model.RoomMemberStatusActive), - db.WithRoomMemberRelationPermissions(model.AllPermissions), + db.WithRoomMemberPermissions(model.AllPermissions), db.WithRoomMemberRole(model.RoomMemberRoleCreator), db.WithRoomMemberAdminPermissions(model.AllAdminPermissions), ) - } else if r.IsGuest(userID) { - conf = append( - conf, - db.WithRoomMemberStatus(model.RoomMemberStatusActive), - db.WithRoomMemberRelationPermissions(model.NoPermission), - db.WithRoomMemberRole(model.RoomMemberRoleMember), - db.WithRoomMemberAdminPermissions(model.NoAdminPermission), - ) } else { - conf = append( - conf, - db.WithRoomMemberRelationPermissions(r.Settings.UserDefaultPermissions), - ) + if r.IsGuest(userID) { + conf = append( + conf, + db.WithRoomMemberPermissions(model.NoPermission), + db.WithRoomMemberRole(model.RoomMemberRoleMember), + db.WithRoomMemberAdminPermissions(model.NoAdminPermission), + ) + } else { + conf = append( + conf, + db.WithRoomMemberPermissions(r.Settings.UserDefaultPermissions), + db.WithRoomMemberRole(model.RoomMemberRoleMember), + db.WithRoomMemberAdminPermissions(model.NoAdminPermission), + ) + } if r.Settings.JoinNeedReview { conf = append(conf, db.WithRoomMemberStatus(model.RoomMemberStatusPending)) } else { @@ -242,7 +245,9 @@ func (r *Room) LoadOrCreateRoomMember(userID string) (*model.RoomMember, error) member.Role = model.RoomMemberRoleMember member.Permissions = model.NoPermission member.AdminPermissions = model.NoAdminPermission - member.Status = model.RoomMemberStatusActive + if member.Status.IsBanned() { + member.Status = model.RoomMemberStatusActive + } } else if member.Role.IsAdmin() { member.Permissions = model.AllPermissions } @@ -271,7 +276,9 @@ func (r *Room) LoadRoomMember(userID string) (*model.RoomMember, error) { member.Role = model.RoomMemberRoleMember member.Permissions = model.NoPermission member.AdminPermissions = model.NoAdminPermission - member.Status = model.RoomMemberStatusActive + if member.Status.IsBanned() { + member.Status = model.RoomMemberStatusActive + } } else if member.Role.IsAdmin() { member.Permissions = model.AllPermissions }