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 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")
|
||||
@@ -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
|
||||
// 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)
|
||||
|
||||
// Update user profile with avatar URL
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewWebDAVClient(cfg *config.Config) *WebDAVClient {
|
||||
user: cfg.NextcloudUser,
|
||||
pass: cfg.NextcloudPass,
|
||||
basePrefix: strings.TrimRight(base, "/"),
|
||||
httpClient: &http.Client{Timeout: 30 * time.Second},
|
||||
httpClient: &http.Client{Timeout: 60 * time.Second},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,12 +91,10 @@ func (c *WebDAVClient) Upload(ctx context.Context, remotePath string, r io.Reade
|
||||
if c == nil {
|
||||
return fmt.Errorf("no webdav client configured")
|
||||
}
|
||||
// Ensure parent collections (skip for hidden avatar folders to avoid MKCOL timeouts)
|
||||
if !strings.HasPrefix(remotePath, ".avatars") {
|
||||
// Ensure parent collections
|
||||
if err := c.ensureParent(ctx, remotePath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// Construct URL
|
||||
// remotePath might be like /orgs/<id>/file.txt; ensure it joins to basePrefix
|
||||
rel := strings.TrimLeft(remotePath, "/")
|
||||
|
||||
Reference in New Issue
Block a user