Fix avatar URL to full URL and increase WebDAV timeout to 60s with ensureParent enabled
This commit is contained in:
@@ -3848,7 +3848,7 @@ func getUserProfileHandler(w http.ResponseWriter, r *http.Request, db *database.
|
|||||||
|
|
||||||
// If avatar exists, return the backend URL instead of the internal WebDAV URL
|
// If avatar exists, return the backend URL instead of the internal WebDAV URL
|
||||||
if user.AvatarURL != nil && *user.AvatarURL != "" {
|
if user.AvatarURL != nil && *user.AvatarURL != "" {
|
||||||
user.AvatarURL = &[]string{fmt.Sprintf("/user/avatar?v=%d", time.Now().Unix())}[0]
|
user.AvatarURL = &[]string{fmt.Sprintf("https://go.b0esche.cloud/user/avatar?v=%d", time.Now().Unix())}[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
@@ -4048,7 +4048,7 @@ func uploadUserAvatarHandler(w http.ResponseWriter, r *http.Request, db *databas
|
|||||||
|
|
||||||
// Get public URL - for now, construct it manually since Nextcloud doesn't provide direct public URLs
|
// Get public URL - for now, construct it manually since Nextcloud doesn't provide direct public URLs
|
||||||
// In a real setup, you'd configure Nextcloud to serve public URLs or use a CDN
|
// In a real setup, you'd configure Nextcloud to serve public URLs or use a CDN
|
||||||
publicURL := fmt.Sprintf("/user/avatar?v=%d", time.Now().Unix())
|
publicURL := fmt.Sprintf("https://go.b0esche.cloud/user/avatar?v=%d", time.Now().Unix())
|
||||||
webdavURL := fmt.Sprintf("%s/%s", client.BaseURL, avatarPath)
|
webdavURL := fmt.Sprintf("%s/%s", client.BaseURL, avatarPath)
|
||||||
|
|
||||||
// Update user profile with avatar URL
|
// Update user profile with avatar URL
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func NewWebDAVClient(cfg *config.Config) *WebDAVClient {
|
|||||||
user: cfg.NextcloudUser,
|
user: cfg.NextcloudUser,
|
||||||
pass: cfg.NextcloudPass,
|
pass: cfg.NextcloudPass,
|
||||||
basePrefix: strings.TrimRight(base, "/"),
|
basePrefix: strings.TrimRight(base, "/"),
|
||||||
httpClient: &http.Client{Timeout: 30 * time.Second},
|
httpClient: &http.Client{Timeout: 60 * time.Second},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,11 +91,9 @@ func (c *WebDAVClient) Upload(ctx context.Context, remotePath string, r io.Reade
|
|||||||
if c == nil {
|
if c == nil {
|
||||||
return fmt.Errorf("no webdav client configured")
|
return fmt.Errorf("no webdav client configured")
|
||||||
}
|
}
|
||||||
// Ensure parent collections (skip for hidden avatar folders to avoid MKCOL timeouts)
|
// Ensure parent collections
|
||||||
if !strings.HasPrefix(remotePath, ".avatars") {
|
if err := c.ensureParent(ctx, remotePath); err != nil {
|
||||||
if err := c.ensureParent(ctx, remotePath); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Construct URL
|
// Construct URL
|
||||||
// remotePath might be like /orgs/<id>/file.txt; ensure it joins to basePrefix
|
// remotePath might be like /orgs/<id>/file.txt; ensure it joins to basePrefix
|
||||||
|
|||||||
Reference in New Issue
Block a user