Skip to content

Commit

Permalink
Merge pull request #7 from anyproto/fix-publish-list
Browse files Browse the repository at this point in the history
fix publish list
  • Loading branch information
cheggaaa authored Jan 20, 2025
2 parents 32fd845 + 1dcc7c6 commit d8659e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions publish/publishrepo/publishrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ func (p *publishRepo) ListPublishes(ctx context.Context, identity string) ([]dom
var publishes []domain.ObjectWithPublish
for cur.Next(ctx) {
var publish domain.ObjectWithPublish
if err = cur.Decode(&publish.Publish); err != nil {
if err = cur.Decode(&publish.Object); err != nil {
return nil, err
}
if publish.ActivePublishId != nil {
publish.Publish = &domain.Publish{}
_ = p.publishColl.FindOne(ctx, bson.D{{"_id", *publish.ActivePublishId}}).Decode(&publish.Publish)
}
publishes = append(publishes, publish)
}
Expand Down
6 changes: 6 additions & 0 deletions publish/publishrepo/publishrepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ func TestPublishRepo_ObjectPublishStatus(t *testing.T) {
require.NotNil(t, publishObj.Publish)
assert.Equal(t, domain.PublishStatusPublished, publishObj.Publish.Status)
assert.Equal(t, int64(123), publishObj.Publish.Size)

list, err := fx.ListPublishes(ctx, obj.Identity)
require.NoError(t, err)
require.Len(t, list, 1)
require.NotNil(t, list[0].Publish)
assert.Equal(t, domain.PublishStatusPublished, list[0].Publish.Status)
})
}

Expand Down

0 comments on commit d8659e0

Please sign in to comment.