Merge branch 'main' of ssh://kolaente.dev:9022/vlasov-y/api

This commit is contained in:
Yurii Vlasov 2023-01-31 09:11:47 +02:00
commit 95e2f1c85d
4 changed files with 13 additions and 6 deletions

View File

@ -47,10 +47,7 @@ which will run the docker image and expose port 80 on the host.
See [full docker example]({{< ref "full-docker-example.md">}}) for more varations of this config. See [full docker example]({{< ref "full-docker-example.md">}}) for more varations of this config.
### Setting user and group id of the user running vikunja The docker container runs as an unprivileged user and does not mount anything.
You can set the user and group id of the user running vikunja with the `PUID` and `PGID` evironment variables.
This follows the pattern used by [the linuxserver.io](https://docs.linuxserver.io/general/understanding-puid-and-pgid) docker images.
### API URL configuration in docker ### API URL configuration in docker

View File

@ -20,12 +20,12 @@ import (
"fmt" "fmt"
"os" "os"
"testing" "testing"
"xorm.io/builder"
"code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/config"
"code.vikunja.io/api/pkg/log" "code.vikunja.io/api/pkg/log"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"xorm.io/builder"
"xorm.io/xorm" "xorm.io/xorm"
"xorm.io/xorm/names" "xorm.io/xorm/names"
) )

View File

@ -19,13 +19,13 @@ package models
import ( import (
"testing" "testing"
"time" "time"
"xorm.io/builder"
"code.vikunja.io/api/pkg/db" "code.vikunja.io/api/pkg/db"
"code.vikunja.io/api/pkg/events" "code.vikunja.io/api/pkg/events"
"code.vikunja.io/api/pkg/user" "code.vikunja.io/api/pkg/user"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"xorm.io/builder"
) )
func TestTask_Create(t *testing.T) { func TestTask_Create(t *testing.T) {

View File

@ -295,6 +295,11 @@ func GetListBackground(c echo.Context) error {
_ = s.Rollback() _ = s.Rollback()
return handler.HandleHTTPError(err, c) return handler.HandleHTTPError(err, c)
} }
stat, err := bgFile.File.Stat()
if err != nil {
_ = s.Rollback()
return handler.HandleHTTPError(err, c)
}
// Unsplash requires pingbacks as per their api usage guidelines. // Unsplash requires pingbacks as per their api usage guidelines.
// To do this in a privacy-preserving manner, we do the ping from inside of Vikunja to not expose any user details. // To do this in a privacy-preserving manner, we do the ping from inside of Vikunja to not expose any user details.
@ -306,6 +311,11 @@ func GetListBackground(c echo.Context) error {
return handler.HandleHTTPError(err, c) return handler.HandleHTTPError(err, c)
} }
// Set Last-Modified header if we have the file stat, so clients can decide whether to use cached files
if stat != nil {
c.Response().Header().Set(echo.HeaderLastModified, stat.ModTime().UTC().Format(http.TimeFormat))
}
// Serve the file // Serve the file
return c.Stream(http.StatusOK, "image/jpg", bgFile.File) return c.Stream(http.StatusOK, "image/jpg", bgFile.File)
} }