mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-10 18:10:49 +09:00
Merge pull request #848 from anyproto/webclipper-panic
fix webclipper panic
This commit is contained in:
commit
ba664fd69a
3 changed files with 19 additions and 2 deletions
|
@ -150,7 +150,10 @@ func (sf *sfile) upload(s *state.State, id string, source FileSource, isSync boo
|
|||
if !ok {
|
||||
return UploadResult{Err: fmt.Errorf("not a file block")}
|
||||
}
|
||||
upl := sf.newUploader().SetBlock(f).SetOrigin(source.Origin.Origin).SetImportType(source.Origin.ImportType)
|
||||
upl := sf.newUploader().SetBlock(f)
|
||||
if source.Origin != nil {
|
||||
upl.SetOrigin(source.Origin.Origin).SetImportType(source.Origin.ImportType)
|
||||
}
|
||||
if source.Path != "" {
|
||||
upl.SetFile(source.Path)
|
||||
} else if source.Url != "" {
|
||||
|
|
|
@ -785,6 +785,7 @@ func (s *Service) CreateObjectFromUrl(ctx context.Context, req *pb.RpcObjectCrea
|
|||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
s.enrichDetailsWithOrigin(req.Details, model.ObjectOrigin_webclipper)
|
||||
createReq := objectcreator.CreateObjectRequest{
|
||||
ObjectTypeKey: objectTypeKey,
|
||||
Details: req.Details,
|
||||
|
@ -824,7 +825,7 @@ func (s *Service) pasteBlocks(id string, content *bookmark.ObjectContent) error
|
|||
}
|
||||
for _, r := range uploadArr {
|
||||
r.ContextId = id
|
||||
uploadReq := UploadRequest{RpcBlockUploadRequest: r}
|
||||
uploadReq := UploadRequest{RpcBlockUploadRequest: r, ObjectOrigin: domain.ObjectWebclipper()}
|
||||
if err = s.UploadBlockFile(nil, uploadReq, groupID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -869,3 +870,10 @@ func (s *Service) GetLogFields() []zap.Field {
|
|||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
func (s *Service) enrichDetailsWithOrigin(details *types.Struct, origin model.ObjectOrigin) {
|
||||
if details == nil || details.Fields == nil {
|
||||
details = &types.Struct{Fields: map[string]*types.Value{}}
|
||||
}
|
||||
details.Fields[bundle.RelationKeyOrigin.String()] = pbtypes.Int64(int64(origin))
|
||||
}
|
||||
|
|
|
@ -20,6 +20,12 @@ func ObjectOriginNone() *ObjectOrigin {
|
|||
}
|
||||
}
|
||||
|
||||
func ObjectWebclipper() *ObjectOrigin {
|
||||
return &ObjectOrigin{
|
||||
Origin: model.ObjectOrigin_webclipper,
|
||||
}
|
||||
}
|
||||
|
||||
func ObjectOriginClipboard() *ObjectOrigin {
|
||||
return &ObjectOrigin{
|
||||
Origin: model.ObjectOrigin_clipboard,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue