Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
fix: push all document history to the gateway
Browse files Browse the repository at this point in the history
  • Loading branch information
juligasa committed Jan 11, 2024
1 parent 155c8a5 commit 2c3afa6
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 209 deletions.
13 changes: 2 additions & 11 deletions backend/daemon/api/documents/v1alpha/documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,6 @@ func (api *Server) PushPublication(ctx context.Context, in *documents.PushPublic
return nil, status.Errorf(codes.InvalidArgument, "must specify publication ID")
}

if in.Version == "" {
return nil, status.Errorf(codes.InvalidArgument, "must specify version")
}

if in.Url == "" {
return nil, status.Errorf(codes.InvalidArgument, "must specify an url")
}
Expand All @@ -477,15 +473,10 @@ func (api *Server) PushPublication(ctx context.Context, in *documents.PushPublic

eid := hyper.EntityID(in.DocumentId)

heads, err := hyper.Version(in.Version).Parse()
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "unable to parse version %s: %v", in.Version, err)
}

entity, err := api.blobs.LoadEntityFromHeads(ctx, eid, heads...)
entity, err := api.blobs.LoadEntity(ctx, eid)

if err != nil {
return nil, status.Errorf(codes.Internal, "unable to get blobs from head: %v", err)
return nil, status.Errorf(codes.Internal, "unable to get entity[%s]: %v", eid.String(), err)
}

if entity == nil {
Expand Down
2 changes: 0 additions & 2 deletions backend/daemon/daemon_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ func TestDaemonPushPublication(t *testing.T) {
pub := publishDocument(t, ctx, alice)
_, err := alice.RPC.Documents.PushPublication(ctx, &documents.PushPublicationRequest{
DocumentId: pub.Document.Id,
Version: pub.Version,
Url: ipfs.TestGateway,
})
require.NoError(t, err)
_, err = alice.RPC.Documents.PushPublication(ctx, &documents.PushPublicationRequest{
DocumentId: pub.Document.Id,
Version: pub.Version,
Url: "https://gabo.es/",
})
require.Error(t, err)
Expand Down
345 changes: 167 additions & 178 deletions backend/genproto/documents/v1alpha/documents.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -624,17 +624,10 @@ export class PushPublicationRequest extends Message<PushPublicationRequest> {
*/
documentId = "";

/**
* Required. Specific version of the published document.
*
* @generated from field: string version = 2;
*/
version = "";

/**
* Required. URL of the gateway to push to. Multiaddress format accepted (comma separated).
*
* @generated from field: string url = 3;
* @generated from field: string url = 2;
*/
url = "";

Expand All @@ -647,8 +640,7 @@ export class PushPublicationRequest extends Message<PushPublicationRequest> {
static readonly typeName = "com.mintter.documents.v1alpha.PushPublicationRequest";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "document_id", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "version", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 3, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 2, name: "url", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PushPublicationRequest {
Expand Down
5 changes: 1 addition & 4 deletions proto/documents/v1alpha/documents.proto
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,8 @@ message PushPublicationRequest {
// Required. ID of the published document to be pushed.
string document_id = 1;

// Required. Specific version of the published document.
string version = 2;

// Required. URL of the gateway to push to. Multiaddress format accepted (comma separated).
string url = 3;
string url = 2;
}

// Request for listing publications.
Expand Down
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/go.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 7e62a4146b09f8d6408c3b742f87e28d
outs: ec1b893e1fd4134db83d381eb3a92f5f
srcs: 9d5bd127faaa2c51f5f7a93f99fec7a2
outs: 26885be15b79bd890b23f2f71cdf4d9f
4 changes: 2 additions & 2 deletions proto/documents/v1alpha/js.gensum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
srcs: 7e62a4146b09f8d6408c3b742f87e28d
outs: 54954dd2798244425318ba654611eec8
srcs: 9d5bd127faaa2c51f5f7a93f99fec7a2
outs: a5ea9a4a5fd5146fde132f3d63761543

0 comments on commit 2c3afa6

Please sign in to comment.