Fix: if room join need review, guest need review too

pull/134/head
zijiren233 1 year ago
parent 69f5db92e1
commit d90154fa36

@ -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) { return func(r *model.RoomMember) {
r.Permissions = permissions r.Permissions = permissions
} }

@ -206,23 +206,26 @@ func (r *Room) LoadOrCreateRoomMember(userID string) (*model.RoomMember, error)
conf = append( conf = append(
conf, conf,
db.WithRoomMemberStatus(model.RoomMemberStatusActive), db.WithRoomMemberStatus(model.RoomMemberStatusActive),
db.WithRoomMemberRelationPermissions(model.AllPermissions), db.WithRoomMemberPermissions(model.AllPermissions),
db.WithRoomMemberRole(model.RoomMemberRoleCreator), db.WithRoomMemberRole(model.RoomMemberRoleCreator),
db.WithRoomMemberAdminPermissions(model.AllAdminPermissions), 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 { } else {
conf = append( if r.IsGuest(userID) {
conf, conf = append(
db.WithRoomMemberRelationPermissions(r.Settings.UserDefaultPermissions), 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 { if r.Settings.JoinNeedReview {
conf = append(conf, db.WithRoomMemberStatus(model.RoomMemberStatusPending)) conf = append(conf, db.WithRoomMemberStatus(model.RoomMemberStatusPending))
} else { } else {
@ -242,7 +245,9 @@ func (r *Room) LoadOrCreateRoomMember(userID string) (*model.RoomMember, error)
member.Role = model.RoomMemberRoleMember member.Role = model.RoomMemberRoleMember
member.Permissions = model.NoPermission member.Permissions = model.NoPermission
member.AdminPermissions = model.NoAdminPermission member.AdminPermissions = model.NoAdminPermission
member.Status = model.RoomMemberStatusActive if member.Status.IsBanned() {
member.Status = model.RoomMemberStatusActive
}
} else if member.Role.IsAdmin() { } else if member.Role.IsAdmin() {
member.Permissions = model.AllPermissions member.Permissions = model.AllPermissions
} }
@ -271,7 +276,9 @@ func (r *Room) LoadRoomMember(userID string) (*model.RoomMember, error) {
member.Role = model.RoomMemberRoleMember member.Role = model.RoomMemberRoleMember
member.Permissions = model.NoPermission member.Permissions = model.NoPermission
member.AdminPermissions = model.NoAdminPermission member.AdminPermissions = model.NoAdminPermission
member.Status = model.RoomMemberStatusActive if member.Status.IsBanned() {
member.Status = model.RoomMemberStatusActive
}
} else if member.Role.IsAdmin() { } else if member.Role.IsAdmin() {
member.Permissions = model.AllPermissions member.Permissions = model.AllPermissions
} }

Loading…
Cancel
Save