@@ -38,10 +38,6 @@ import (
38
38
"github.com/pkg/errors"
39
39
)
40
40
41
- // QuicklinkName is the reserved name for a quicklink.
42
- // Creating (or updating) a link with (to) the same name will be blocked by the server
43
- const QuicklinkName = "Quicklink"
44
-
45
41
func (h * Handler ) createPublicLinkShare (w http.ResponseWriter , r * http.Request , statInfo * provider.ResourceInfo ) (* link.PublicShare , * ocsError ) {
46
42
ctx := r .Context ()
47
43
log := appctx .GetLogger (ctx )
@@ -64,18 +60,8 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request,
64
60
}
65
61
}
66
62
67
- // check reserved names
68
- linkname := r .FormValue ("name" )
69
- quick , _ := strconv .ParseBool (r .FormValue ("quicklink" )) // no need to check the error - defaults to zero value!
70
- if ! quick && linkname == QuicklinkName {
71
- return nil , & ocsError {
72
- Code : response .MetaBadRequest .StatusCode ,
73
- Message : fmt .Sprintf ("not allowed to use `%s` as name" , linkname ),
74
- }
75
-
76
- }
77
-
78
63
// check if a quicklink should be created
64
+ quick , _ := strconv .ParseBool (r .FormValue ("quicklink" )) // no need to check the error - defaults to zero value!
79
65
if quick {
80
66
f := []* link.ListPublicSharesRequest_Filter {publicshare .ResourceIDFilter (statInfo .Id )}
81
67
req := link.ListPublicSharesRequest {Filters : f }
@@ -95,12 +81,10 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request,
95
81
}
96
82
97
83
for _ , l := range res .GetShare () {
98
- if l .DisplayName == QuicklinkName {
84
+ if l .Quicklink {
99
85
return l , nil
100
86
}
101
87
}
102
-
103
- linkname = QuicklinkName
104
88
}
105
89
106
90
newPermissions , err := permissionFromRequest (r , h )
@@ -164,7 +148,8 @@ func (h *Handler) createPublicLinkShare(w http.ResponseWriter, r *http.Request,
164
148
// set displayname and password protected as arbitrary metadata
165
149
req .ResourceInfo .ArbitraryMetadata = & provider.ArbitraryMetadata {
166
150
Metadata : map [string ]string {
167
- "name" : linkname ,
151
+ "name" : r .FormValue ("name" ),
152
+ "quicklink" : r .FormValue ("quicklink" ),
168
153
// "password": r.FormValue("password"),
169
154
},
170
155
}
@@ -306,15 +291,7 @@ func (h *Handler) updatePublicShare(w http.ResponseWriter, r *http.Request, shar
306
291
newName , ok := r .Form ["name" ]
307
292
if ok {
308
293
updatesFound = true
309
- if n := newName [0 ]; n != before .Share .DisplayName {
310
- if n == QuicklinkName {
311
- response .WriteOCSError (w , r , response .MetaBadRequest .StatusCode , fmt .Sprintf ("not allowed to rename a link to '%s'" , n ), nil )
312
- return
313
- }
314
- if before .Share .DisplayName == QuicklinkName {
315
- response .WriteOCSError (w , r , response .MetaBadRequest .StatusCode , "not allowed to rename a quicklink" , nil )
316
- return
317
- }
294
+ if newName [0 ] != before .Share .DisplayName {
318
295
updates = append (updates , & link.UpdatePublicShareRequest_Update {
319
296
Type : link .UpdatePublicShareRequest_Update_TYPE_DISPLAYNAME ,
320
297
DisplayName : newName [0 ],
0 commit comments