(c *gin.Context, req *ArchiveMetaReq)
| 105 | } |
| 106 | |
| 107 | func SharingArchiveMeta(c *gin.Context, req *ArchiveMetaReq) { |
| 108 | if !setting.GetBool(conf.ShareArchivePreview) { |
| 109 | common.ErrorStrResp(c, "sharing archives previewing is not allowed", 403) |
| 110 | return |
| 111 | } |
| 112 | sid, path, _ := strings.Cut(strings.TrimPrefix(req.Path, "/"), "/") |
| 113 | if sid == "" { |
| 114 | common.ErrorStrResp(c, "invalid share id", 400) |
| 115 | return |
| 116 | } |
| 117 | archiveArgs := model.ArchiveArgs{ |
| 118 | LinkArgs: model.LinkArgs{ |
| 119 | Header: c.Request.Header, |
| 120 | Type: c.Query("type"), |
| 121 | }, |
| 122 | Password: req.ArchivePass, |
| 123 | } |
| 124 | s, ret, err := sharing.ArchiveMeta(c.Request.Context(), sid, path, model.SharingArchiveMetaArgs{ |
| 125 | ArchiveMetaArgs: model.ArchiveMetaArgs{ |
| 126 | ArchiveArgs: archiveArgs, |
| 127 | Refresh: req.Refresh, |
| 128 | }, |
| 129 | Pwd: req.Password, |
| 130 | }) |
| 131 | if dealError(c, err) { |
| 132 | return |
| 133 | } |
| 134 | _ = countAccess(c.ClientIP(), s) |
| 135 | fakePath := fmt.Sprintf("/%s/%s", sid, path) |
| 136 | url := fmt.Sprintf("%s/sad%s", common.GetApiUrl(c), utils.EncodePath(fakePath, true)) |
| 137 | if s.Pwd != "" { |
| 138 | url += "?pwd=" + s.Pwd |
| 139 | } |
| 140 | common.SuccessResp(c, ArchiveMetaResp{ |
| 141 | Comment: ret.GetComment(), |
| 142 | IsEncrypted: ret.IsEncrypted(), |
| 143 | Content: toContentResp(ret.GetTree()), |
| 144 | Sort: ret.Sort, |
| 145 | RawURL: url, |
| 146 | Sign: "", |
| 147 | }) |
| 148 | } |
| 149 | |
| 150 | func SharingArchiveList(c *gin.Context, req *ArchiveListReq) { |
| 151 | if !setting.GetBool(conf.ShareArchivePreview) { |
no test coverage detected