feat(pwa): add web share target for text and images with offline queue
This commit is contained in:
1 parent
c181ffea54
commit
86d2cd0138
9 files changed
+360
-2
No files matched your search
@@ -308,6 +308,11 @@ func (s *Server) Router() http.Handler {
|
||||
})
|
||||
})
|
||||
|
||||
// Web Share Target fallback when service worker is not active yet: redirect to /
|
||||
r.Post("/share-target", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
||||
})
|
||||
|
||||
// Embedded Frontend SPA Handler
|
||||
if s.staticFS != nil {
|
||||
fileServer := http.FileServer(http.FS(s.staticFS))
|
||||
|
||||
@@ -1533,6 +1533,24 @@ func TestPasswordResetFlow(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestShareTargetFallbackRedirects(t *testing.T) {
|
||||
store, err := storage.NewStore(":memory:")
|
||||
if err != nil {
|
||||
t.Fatalf("NewStore: %v", err)
|
||||
}
|
||||
defer store.Close()
|
||||
router := NewServer(&config.Config{Port: "8080", DatabasePath: ":memory:", JWTSecret: "test-jwt-secret-key"}, store, ws.NewHub(), nil).Router()
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodPost, "/share-target", nil)
|
||||
router.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusSeeOther {
|
||||
t.Fatalf("expected 303 See Other, got %d", rec.Code)
|
||||
}
|
||||
if loc := rec.Header().Get("Location"); loc != "/" {
|
||||
t.Fatalf("expected Location '/', got %q", loc)
|
||||
}
|
||||
}
|
||||
|
||||
// testSession starts a server-side session, as a login would, for tokens made directly in tests.
|
||||
func testSession(t *testing.T, store *storage.Store, userID string) string {
|
||||
t.Helper()
|
||||
|
||||
Reference in new issue
Block a user