Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 158b823

Browse files
committed
Allow profile moderation to be disabled without removing info
1 parent 2e95244 commit 158b823

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

repo/profile.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ var (
1515
// ErrModeratorInfoMissing indicates when the moderator information is
1616
// missing while also indicating they are a moderator
1717
ErrModeratorInfoMissing = errors.New("moderator is enabled but information is missing")
18-
// ErrNonModeratorShouldNotHaveInfo indicates when the moderator information
19-
// is present, but not indicating moderator is enabled
20-
ErrNonModeratorShouldNotHaveInfo = errors.New("moderator information is provided but moderator is not enabled")
2118
// ErrMissingModeratorFee indicates the fee schedule is missing
2219
ErrMissingModeratorFee = errors.New("moderator info is missing fee schedule")
2320
// ErrUnknownModeratorFeeType indicates the feeType is unknown
@@ -130,9 +127,6 @@ func (p *Profile) IsModerationEnabled() bool {
130127
}
131128

132129
func (p *Profile) validateModeratorFees() error {
133-
if !p.profileProto.Moderator && p.profileProto.ModeratorInfo != nil {
134-
return ErrNonModeratorShouldNotHaveInfo
135-
}
136130
if p.profileProto.Moderator && p.profileProto.ModeratorInfo == nil {
137131
return ErrModeratorInfoMissing
138132
}

repo/profile_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,24 @@ func TestProfileValidWithoutModeratorInfo(t *testing.T) {
154154
}
155155
}
156156

157+
func TestProfileValidWithModeratorInfoAndModerationDisabled(t *testing.T) {
158+
var (
159+
p = factory.MustNewProfile()
160+
pp = p.GetProtobuf()
161+
)
162+
pp.Moderator = false
163+
pp.ModeratorInfo = &pb.Moderator{
164+
Fee: &pb.Moderator_Fee{
165+
FeeType: pb.Moderator_Fee_PERCENTAGE,
166+
Percentage: 0,
167+
},
168+
}
169+
170+
if err := p.Valid(); err != nil {
171+
t.Errorf("expected profile to be valid with moderator info and moderation disabled, but errored (%s)", err)
172+
}
173+
}
174+
157175
func TestProfileInvalidWithoutModeratorFee(t *testing.T) {
158176
var (
159177
p = factory.MustNewProfile()

0 commit comments

Comments
 (0)