From 825f7826f516a674dfeaedd52e583bfa041fb8be Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sun, 22 Aug 2021 17:51:57 +0100 Subject: [PATCH] box: add --box-owned-by to only show items owned by the login passed #5545 --- backend/box/api/types.go | 8 +++++++- backend/box/box.go | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/backend/box/api/types.go b/backend/box/api/types.go index 363fa3353..d3549f6aa 100644 --- a/backend/box/api/types.go +++ b/backend/box/api/types.go @@ -61,7 +61,7 @@ func (e *Error) Error() string { var _ error = (*Error)(nil) // ItemFields are the fields needed for FileInfo -var ItemFields = "type,id,sequence_id,etag,sha1,name,size,created_at,modified_at,content_created_at,content_modified_at,item_status,shared_link" +var ItemFields = "type,id,sequence_id,etag,sha1,name,size,created_at,modified_at,content_created_at,content_modified_at,item_status,shared_link,owned_by" // Types of things in Item const ( @@ -90,6 +90,12 @@ type Item struct { URL string `json:"url,omitempty"` Access string `json:"access,omitempty"` } `json:"shared_link"` + OwnedBy struct { + Type string `json:"type"` + ID string `json:"id"` + Name string `json:"name"` + Login string `json:"login"` + } `json:"owned_by"` } // ModTime returns the modification time of the item diff --git a/backend/box/box.go b/backend/box/box.go index eeb8157b8..addcc4fc9 100644 --- a/backend/box/box.go +++ b/backend/box/box.go @@ -139,6 +139,11 @@ func init() { Default: 1000, Help: "Size of listing chunk 1-1000.", Advanced: true, + }, { + Name: "owned_by", + Default: "", + Help: "Only show items owned by the login (email address) passed in.", + Advanced: true, }, { Name: config.ConfigEncoding, Help: config.ConfigEncodingHelp, @@ -254,6 +259,7 @@ type Options struct { RootFolderID string `config:"root_folder_id"` AccessToken string `config:"access_token"` ListChunk int `config:"list_chunk"` + OwnedBy string `config:"owned_by"` } // Fs represents a remote box @@ -619,6 +625,9 @@ OUTER: if activeOnly && item.ItemStatus != api.ItemStatusActive { continue } + if f.opt.OwnedBy != "" && f.opt.OwnedBy != item.OwnedBy.Login { + continue + } item.Name = f.opt.Enc.ToStandardName(item.Name) if fn(item) { found = true