File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -433,11 +433,15 @@ Content-Type: application/vnd.api+json
433433Get information about all the sharings that have a rule for the given doctype.
434434This includes the content of the rules, the members, as well as the already
435435shared documents for this sharing.
436+ A ` shared_docs ` query parameter is supported to control whether or not the
437+ shared docs should be included in the response. Default is true.
438+ This can be costful in case of large sharings, so it can be a good idea to set
439+ it to false for performances.
436440
437441#### Request
438442
439443``` http
440- GET /sharings/doctype/io.cozy.files HTTP/1.1
444+ GET /sharings/doctype/io.cozy.files?shared_docs=true HTTP/1.1
441445Host: alice.example.net
442446Accept: application/vnd.api+json
443447```
Original file line number Diff line number Diff line change @@ -198,7 +198,10 @@ func CountNewShortcuts(c echo.Context) error {
198198func GetSharingsInfoByDocType (c echo.Context ) error {
199199 inst := middlewares .GetInstance (c )
200200 docType := c .Param ("doctype" )
201-
201+ withSharedDocs , err := strconv .ParseBool (c .QueryParam ("shared_docs" ))
202+ if err != nil {
203+ withSharedDocs = true
204+ }
202205 sharings , err := sharing .GetSharingsByDocType (inst , docType )
203206 if err != nil {
204207 inst .Logger ().WithNamespace ("sharing" ).Errorf ("GetSharingsByDocType error: %s" , err )
@@ -214,10 +217,14 @@ func GetSharingsInfoByDocType(c echo.Context) error {
214217 for sID := range sharings {
215218 sharingIDs = append (sharingIDs , sID )
216219 }
217- sDocs , err := sharing .GetSharedDocsBySharingIDs (inst , sharingIDs )
218- if err != nil {
219- inst .Logger ().WithNamespace ("sharing" ).Errorf ("GetSharedDocsBySharingIDs error: %s" , err )
220- return wrapErrors (err )
220+
221+ var sDocs map [string ][]couchdb.DocReference
222+ if withSharedDocs {
223+ sDocs , err = sharing .GetSharedDocsBySharingIDs (inst , sharingIDs )
224+ if err != nil {
225+ inst .Logger ().WithNamespace ("sharing" ).Errorf ("GetSharedDocsBySharingIDs error: %s" , err )
226+ return wrapErrors (err )
227+ }
221228 }
222229
223230 res := make ([]* sharing.APISharing , 0 , len (sharings ))
You can’t perform that action at this time.
0 commit comments