Skip to content

Commit 18df134

Browse files
authored
Merge pull request #90 from anyproto/GO-3631-remove-personal-space
GO-3631: Delete personal space
2 parents 95b132f + 78565d7 commit 18df134

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

spacestatus/spacestatus.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ type findStatusQuery struct {
119119
Identity string `bson:"identity,omitempty"`
120120
}
121121

122-
func newPersonalAccountQuery(identity string, status int) bson.M {
122+
func newTechAccountQuery(identity string, status int) bson.M {
123123
return bson.M{
124124
"identity": identity,
125125
"$and": []bson.M{
126126
{
127127
"$or": []bson.M{
128-
{"type": SpaceTypePersonal},
128+
{"type": SpaceTypeTech},
129129
{"type": bson.M{"$exists": false}},
130130
},
131131
},
@@ -174,7 +174,7 @@ func (s *spaceStatus) AccountDelete(ctx context.Context, payload AccountDeletion
174174
toBeDeletedTimestamp = tm.Add(s.deletionPeriod).Unix()
175175
)
176176
err = s.db.Tx(ctx, func(txCtx mongo.SessionContext) error {
177-
// Find personal space with SpaceStatusCreated status for the given identity
177+
// Find tech space with SpaceStatusCreated status for the given identity
178178
if !s.accountStatusFindTx(txCtx, identity, SpaceStatusCreated) {
179179
return coordinatorproto.ErrAccountIsDeleted
180180
}
@@ -270,9 +270,6 @@ func (s *spaceStatus) SpaceDelete(ctx context.Context, payload SpaceDeletion) (t
270270
return coordinatorproto.ErrSpaceNotExists
271271
}
272272
switch spType {
273-
case SpaceTypePersonal:
274-
log.Debug("cannot delete personal space", zap.Error(err), zap.String("spaceId", payload.SpaceId))
275-
return coordinatorproto.ErrUnexpected
276273
case SpaceTypeTech:
277274
log.Debug("cannot delete tech space", zap.Error(err), zap.String("spaceId", payload.SpaceId))
278275
return coordinatorproto.ErrUnexpected
@@ -413,7 +410,7 @@ func (s *spaceStatus) Status(ctx context.Context, spaceId string) (entry StatusE
413410
}
414411

415412
func (s *spaceStatus) accountStatusFindTx(txCtx mongo.SessionContext, identity string, status int) (found bool) {
416-
err := s.spaces.FindOne(txCtx, newPersonalAccountQuery(identity, status)).Err()
413+
err := s.spaces.FindOne(txCtx, newTechAccountQuery(identity, status)).Err()
417414
if err == nil {
418415
return true
419416
}

spacestatus/spacestatus_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ func TestSpaceStatus_SpaceDelete(t *testing.T) {
572572
})
573573
checkStatus(fx, res, delPeriod, err)
574574
})
575-
t.Run("personal space delete - error", func(t *testing.T) {
575+
t.Run("personal space delete - no error", func(t *testing.T) {
576576
fx := newFixture(t, 1, 0)
577577
fx.Run()
578578
fx.verifier.verify = true
@@ -588,7 +588,7 @@ func TestSpaceStatus_SpaceDelete(t *testing.T) {
588588
},
589589
SpaceId: spaceId,
590590
})
591-
require.Error(t, err)
591+
require.NoError(t, err)
592592
})
593593
t.Run("tech space delete - error", func(t *testing.T) {
594594
fx := newFixture(t, 1, 0)

0 commit comments

Comments
 (0)