Skip to content

Commit

Permalink
Hotfix: add sharedby to received files (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsonsivar authored Dec 9, 2020
1 parent 1021006 commit 21f2772
Show file tree
Hide file tree
Showing 9 changed files with 768 additions and 749 deletions.
3 changes: 2 additions & 1 deletion core/space/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ type SharedDirEntry struct {
Bucket string
IsPublicLink bool
FileInfo
Members []Member // XXX: it is duplicated from FileInfo
Members []Member // XXX: it is duplicated from FileInfo
SharedBy string
}

type SearchFileEntry struct {
Expand Down
1 change: 1 addition & 0 deletions core/textile/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Model interface {
invitationId string,
accepted bool,
key []byte,
sharedBy string,
) (*ReceivedFileSchema, error)
CreateReceivedFileViaPublicLink(
ctx context.Context,
Expand Down
3 changes: 3 additions & 0 deletions core/textile/model/received_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type ReceivedFileViaInvitationSchema struct {
InvitationId string `json:"invitationId"`
BucketKey string `json:"bucketKey"`
EncryptionKey []byte `json:"encryptionKey"`
SharedBy string `json:"sharedBy"`
}

// ReceivedFileSchema represents data of files shared with a user
Expand Down Expand Up @@ -55,6 +56,7 @@ func (m *model) CreateReceivedFileViaInvitation(
invitationID string,
accepted bool,
key []byte,
inviterPubKey string,
) (*ReceivedFileSchema, error) {
log.Debug("Model.CreateReceivedFileViaInvitation: Storing received file", "file:"+file.Path)
if existingFile, err := m.FindReceivedFile(ctx, file.DbId, file.Bucket, file.Path); err == nil {
Expand All @@ -71,6 +73,7 @@ func (m *model) CreateReceivedFileViaInvitation(
InvitationId: invitationID,
BucketKey: file.BucketKey,
EncryptionKey: key,
SharedBy: inviterPubKey,
},
Accepted: accepted,
CreatedAt: time.Now().UnixNano(),
Expand Down
3 changes: 2 additions & 1 deletion core/textile/sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (tc *textileClient) createReceivedFiles(
if accepted {
encryptionKeys = invitation.Keys[i]
}
receivedFile, err := tc.GetModel().CreateReceivedFileViaInvitation(ctx, path, invitation.InvitationID, accepted, encryptionKeys)
receivedFile, err := tc.GetModel().CreateReceivedFileViaInvitation(ctx, path, invitation.InvitationID, accepted, encryptionKeys, invitation.InviterPublicKey)

// compose each create error
if err != nil {
Expand Down Expand Up @@ -274,6 +274,7 @@ func (tc *textileClient) buildPublicLinkSharedDirEntry(
},
Members: []domain.Member{},
IsPublicLink: true,
SharedBy: file.SharedBy,
}

return res, nil
Expand Down
5 changes: 3 additions & 2 deletions grpc/handlers_sharing.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ func (srv *grpcServer) GetSharedWithMeFiles(ctx context.Context, request *pb.Get
}

dirEntry := &pb.SharedListDirectoryEntry{
DbId: e.DbID,
Bucket: e.Bucket,
DbId: e.DbID,
Bucket: e.Bucket,
SharedBy: e.SharedBy,
Entry: &pb.ListDirectoryEntry{
Path: e.Path,
IsDir: e.IsDir,
Expand Down
1,484 changes: 747 additions & 737 deletions grpc/pb/space.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions grpc/pb/space.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grpc/proto/space.proto
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ message SharedListDirectoryEntry {
string dbId = 2;
string bucket = 3;
bool isPublicLink = 4;
string sharedBy = 5;
}

message ListDirectoriesResponse {
Expand Down
16 changes: 8 additions & 8 deletions mocks/Model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 21f2772

Please sign in to comment.