Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1520,7 +1520,7 @@ components:
description: The folder's title, or the collection's for its backdrop.
field:
type: string
enum: [backdrop_image_url, cover_image_url, focus_gif_url, hero_backdrop_url, hero_video_url, title_logo_url]
enum: [backdrop_image_url, cover_image_url, focus_gif_url, hero_backdrop_url, title_logo_url]
url: { type: string }
site:
type: string
Expand Down Expand Up @@ -1642,7 +1642,9 @@ components:
focus_gif_url: { type: string, maxLength: 2048 }
focus_gif_enabled: { type: boolean }
hero_backdrop_url: { type: string, maxLength: 2048 }
hero_video_url: { type: string, maxLength: 2048 }
hero_video_url:
type: string
description: Always empty. A value sent is ignored and never stored or pushed.
title_logo_url: { type: string, maxLength: 2048 }

FolderRef:
Expand Down
2 changes: 1 addition & 1 deletion docs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ erDiagram
string focus_gif_url
bool focus_gif_enabled "defaults to 1, matching Nuvio"
string hero_backdrop_url
string hero_video_url
string hero_video_url "always empty, kept so stored snapshots keep their bytes"
string title_logo_url
string sub_key "nullable — in a subscribed collection, its snapshot key"
}
Expand Down
6 changes: 3 additions & 3 deletions internal/api/community_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestCollectionWithheldMediaRoute(t *testing.T) {
}
art := vault.FolderArt{
TileShape: "POSTER", CoverImageURL: "https://image.tmdb.org/t/p/w500/cover.jpg",
HeroVideoURL: "https://Cdn.Example.com:8443/hero.mp4",
TitleLogoURL: "https://Cdn.Example.com:8443/logo.png",
}
collection, err := x.f.db.CreateUserCollection(ctx, x.f.caller.ID, vault.CollectionForm{
Title: "Art", ViewMode: "ROWS", BackdropImageURL: "https://i.postimg.cc/backdrop.jpg",
Expand All @@ -288,10 +288,10 @@ func TestCollectionWithheldMediaRoute(t *testing.T) {

x.f.db.ShareCommunityMediaFrom([]string{"image.tmdb.org", "*.example.org"})
trusted := newCommunityServer(t, x.f.db, CommunityTrustedImages)
hero := `"field":"hero_video_url","url":"https://Cdn.Example.com:8443/hero.mp4","site":"cdn.example.com"}`
logo := `"field":"title_logo_url","url":"https://Cdn.Example.com:8443/logo.png","site":"cdn.example.com"}`
want := `{"pictures":[` +
`{"title":"Art","field":"backdrop_image_url","url":"https://i.postimg.cc/backdrop.jpg","site":"i.postimg.cc"},` +
`{"title":"One",` + hero + `,{"title":"Two",` + hero +
`{"title":"One",` + logo + `,{"title":"Two",` + logo +
`],"sites":["image.tmdb.org","*.example.org"]}`
if w := serve(t, trusted, http.MethodGet, path, "", false); w.Code != http.StatusOK || strings.TrimSpace(w.Body.String()) != want {
t.Errorf("on a server trusting some sites: %d %s\nwant %s", w.Code, w.Body.String(), want)
Expand Down
1 change: 0 additions & 1 deletion internal/vault/community_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func (db *DB) CollectionWithheldMedia(ctx context.Context, profileID, collection
add(f.Title, "cover_image_url", f.CoverImageURL)
add(f.Title, "focus_gif_url", f.FocusGIFURL)
add(f.Title, "hero_backdrop_url", f.HeroBackdropURL)
add(f.Title, "hero_video_url", f.HeroVideoURL)
add(f.Title, "title_logo_url", f.TitleLogoURL)
}
return out, nil
Expand Down
30 changes: 15 additions & 15 deletions internal/vault/community_media_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func mediaCollection(title string) CollectionForm {
FolderArt: FolderArt{
TileShape: "POSTER", CoverEmoji: "🎬", CoverImageURL: "https://img.example/cover.jpg",
FocusGIFURL: "https://img.example/focus.gif", FocusGIFEnabled: true,
HeroBackdropURL: "https://img.example/hero.jpg", HeroVideoURL: "https://img.example/hero.mp4",
TitleLogoURL: "https://img.example/logo.png",
HeroBackdropURL: "https://img.example/hero.jpg",
TitleLogoURL: "https://img.example/logo.png",
},
Title: "F", Catalogs: []FolderCatalogRef{newScoped("k", "S", "{}")},
}},
Expand All @@ -27,7 +27,7 @@ func mediaCollection(title string) CollectionForm {

// artMedia is a's media addresses, empty ones included.
func artMedia(a FolderArt) []string {
return []string{a.CoverImageURL, a.FocusGIFURL, a.HeroBackdropURL, a.HeroVideoURL, a.TitleLogoURL}
return []string{a.CoverImageURL, a.FocusGIFURL, a.HeroBackdropURL, a.TitleLogoURL}
}

// treeMedia is every media address tree holds.
Expand Down Expand Up @@ -95,15 +95,15 @@ func TestWithheldMediaLeavesCommunityAndCopies(t *testing.T) {
}
}

if got := treeMedia(mustOwnCollection(t, db, owner, source.ID)); len(got) != 6 {
t.Errorf("publisher's own row holds %v, want all 6 addresses", got)
if got := treeMedia(mustOwnCollection(t, db, owner, source.ID)); len(got) != 5 {
t.Errorf("publisher's own row holds %v, want all 5 addresses", got)
}
stored, err := sharingAll(db).GetPublication(ctx, owner, source.Publication.ID)
if err != nil {
t.Fatal(err)
}
if got := snapshotMedia(stored.Snapshot); len(got) != 6 {
t.Errorf("stored snapshot holds %v, want all 6 addresses", got)
if got := snapshotMedia(stored.Snapshot); len(got) != 5 {
t.Errorf("stored snapshot holds %v, want all 5 addresses", got)
}
}

Expand All @@ -117,8 +117,8 @@ func TestWithheldMediaUpdate(t *testing.T) {
owner, subscriber := newTestProfile(t, db, "owner"), newTestProfile(t, db, "subscriber")
source := publishCollection(t, db, owner, mediaCollection("Art"))
added := *subscribe(t, db, subscriber, source.Publication.ID).Collection
if got := treeMedia(added); len(got) != 6 {
t.Fatalf("copy added while media is shared holds %v, want all 6 addresses", got)
if got := treeMedia(added); len(got) != 5 {
t.Fatalf("copy added while media is shared holds %v, want all 5 addresses", got)
}
db.WithholdCommunityMedia()
pubID := source.Publication.ID
Expand Down Expand Up @@ -285,15 +285,15 @@ func TestTrustedMediaLeavesCommunityAndCopies(t *testing.T) {
}
}

if got := treeMedia(mustOwnCollection(t, db, owner, source.ID)); len(got) != 6 {
t.Errorf("publisher's own row holds %v, want all 6 addresses", got)
if got := treeMedia(mustOwnCollection(t, db, owner, source.ID)); len(got) != 5 {
t.Errorf("publisher's own row holds %v, want all 5 addresses", got)
}
stored, err := sharingAll(db).GetPublication(ctx, owner, source.Publication.ID)
if err != nil {
t.Fatal(err)
}
if got := snapshotMedia(stored.Snapshot); len(got) != 6 {
t.Errorf("stored snapshot holds %v, want all 6 addresses", got)
if got := snapshotMedia(stored.Snapshot); len(got) != 5 {
t.Errorf("stored snapshot holds %v, want all 5 addresses", got)
}
}

Expand All @@ -305,8 +305,8 @@ func TestTrustedMediaUpdate(t *testing.T) {
db := newTestDB(t)
owner, subscriber := newTestProfile(t, db, "owner"), newTestProfile(t, db, "subscriber")
source := publishCollection(t, db, owner, mixedMediaCollection("Art"))
if got := treeMedia(*subscribe(t, db, subscriber, source.Publication.ID).Collection); len(got) != 6 {
t.Fatalf("copy added while media is shared holds %v, want all 6 addresses", got)
if got := treeMedia(*subscribe(t, db, subscriber, source.Publication.ID).Collection); len(got) != 5 {
t.Fatalf("copy added while media is shared holds %v, want all 5 addresses", got)
}
db.ShareCommunityMediaFrom([]string{trustedSite})
pubID := source.Publication.ID
Expand Down
50 changes: 42 additions & 8 deletions internal/vault/folder_appearance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

// The Nuvio appearance fields (focus glow on the collection; focus GIF and
// Modern Home hero fields on a folder) survive create, an in-place update of
// Modern Home hero backdrop and title logo on a folder) survive create, an in-place update of
// an existing folder, and DuplicateCollection's tree copy.
func TestCollectionAppearanceFieldsRoundTrip(t *testing.T) {
ctx := context.Background()
Expand All @@ -24,7 +24,6 @@ func TestCollectionAppearanceFieldsRoundTrip(t *testing.T) {
FocusGIFURL: "https://example.com/focus.gif",
FocusGIFEnabled: true,
HeroBackdropURL: "https://example.com/backdrop.jpg",
HeroVideoURL: "https://example.com/hero.mp4",
TitleLogoURL: "https://example.com/logo.png",
},
Catalogs: CatalogRefs(listed.ID),
Expand All @@ -44,7 +43,6 @@ func TestCollectionAppearanceFieldsRoundTrip(t *testing.T) {

folder.ID = &created.Folders[0].ID
folder.FocusGIFEnabled = false
folder.HeroVideoURL = ""
folder.TitleLogoURL = "https://example.com/logo2.png"
updated, err := db.UpdateUserCollection(ctx, owner, created.ID, collectionRevision(t, db, created.ID), CollectionForm{
Title: "C", ViewMode: "TABBED_GRID",
Expand Down Expand Up @@ -80,10 +78,46 @@ func TestCollectionAppearanceFieldsRoundTrip(t *testing.T) {
func assertFolderAppearance(t *testing.T, label string, got Folder, want FolderData) {
t.Helper()
if got.FocusGIFURL != want.FocusGIFURL || got.FocusGIFEnabled != want.FocusGIFEnabled ||
got.HeroBackdropURL != want.HeroBackdropURL || got.HeroVideoURL != want.HeroVideoURL ||
got.TitleLogoURL != want.TitleLogoURL {
t.Errorf("%s folder appearance = {gif %q %v, backdrop %q, video %q, logo %q}, want {gif %q %v, backdrop %q, video %q, logo %q}",
label, got.FocusGIFURL, got.FocusGIFEnabled, got.HeroBackdropURL, got.HeroVideoURL, got.TitleLogoURL,
want.FocusGIFURL, want.FocusGIFEnabled, want.HeroBackdropURL, want.HeroVideoURL, want.TitleLogoURL)
got.HeroBackdropURL != want.HeroBackdropURL || got.TitleLogoURL != want.TitleLogoURL {
t.Errorf("%s folder appearance = {gif %q %v, backdrop %q, logo %q}, want {gif %q %v, backdrop %q, logo %q}",
label, got.FocusGIFURL, got.FocusGIFEnabled, got.HeroBackdropURL, got.TitleLogoURL,
want.FocusGIFURL, want.FocusGIFEnabled, want.HeroBackdropURL, want.TitleLogoURL)
}
}

// A hero video that arrives with a folder is never stored, on create or on an
// in-place update.
func TestHeroVideoIsNeverStored(t *testing.T) {
ctx := context.Background()
db := newTestDB(t)
owner := newTestProfile(t, db, "owner")
listed, err := db.CreateUserCatalog(ctx, owner, listedCatalogForm("Listed"))
if err != nil {
t.Fatalf("create listed catalog: %v", err)
}
folder := FolderData{
Title: "Folder",
FolderArt: FolderArt{TileShape: "POSTER", HeroVideoURL: "https://example.com/hero.mp4"},
Catalogs: CatalogRefs(listed.ID),
}
form := CollectionForm{Title: "C", ViewMode: "TABBED_GRID", Folders: []FolderData{folder}}
created, err := db.CreateUserCollection(ctx, owner, form)
if err != nil {
t.Fatalf("CreateUserCollection: %v", err)
}
if got := created.Folders[0].HeroVideoURL; got != "" {
t.Errorf("created hero video = %q, want none", got)
}

form.Folders[0].ID = &created.Folders[0].ID
if _, err := db.UpdateUserCollection(ctx, owner, created.ID, collectionRevision(t, db, created.ID), form); err != nil {
t.Fatalf("UpdateUserCollection: %v", err)
}
reloaded, err := db.GetUserCollections(ctx, owner)
if err != nil {
t.Fatalf("GetUserCollections: %v", err)
}
if got := reloaded[0].Folders[0].HeroVideoURL; got != "" {
t.Errorf("updated hero video = %q, want none", got)
}
}
6 changes: 4 additions & 2 deletions internal/vault/folders.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import (
)

// folderFrom builds the folder row fd describes: id and sortOrder from the
// caller, every other column straight off fd. The one place that field list
// lives, shared by insertFolder and updateFolder.
// caller, every other column straight off fd but the hero video, which is
// always empty. The one place that field list lives, shared by insertFolder
// and updateFolder.
func folderFrom(id, collectionID uuid.UUID, sortOrder int, fd FolderData) Folder {
fd.HeroVideoURL = ""
return Folder{
ID: id,
CollectionID: collectionID,
Expand Down
10 changes: 6 additions & 4 deletions internal/vault/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ type FolderArt struct {
// it's focused, when FocusGIFEnabled is set.
FocusGIFURL string `json:"focus_gif_url"`
FocusGIFEnabled bool `json:"focus_gif_enabled"`
// HeroBackdropURL, HeroVideoURL and TitleLogoURL are the folder's hero
// media for Nuvio's Modern Home layout.
// HeroBackdropURL and TitleLogoURL are the folder's hero media for
// Nuvio's Modern Home layout.
HeroBackdropURL string `json:"hero_backdrop_url"`
HeroVideoURL string `json:"hero_video_url"`
TitleLogoURL string `json:"title_logo_url"`
// HeroVideoURL is always empty: Uno doesn't set a hero video. It stays so
// every stored snapshot keeps its bytes, and so its content hash.
HeroVideoURL string `json:"hero_video_url"`
TitleLogoURL string `json:"title_logo_url"`
}

// FolderCatalog joins a Folder to one of its member Catalogs, in order.
Expand Down
2 changes: 0 additions & 2 deletions internal/vault/pushpayload.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ type PushFolder struct {
FocusGIFURL string `json:"focusGifUrl,omitempty"`
FocusGIFEnabled bool `json:"focusGifEnabled"`
HeroBackdropURL string `json:"heroBackdropUrl,omitempty"`
HeroVideoURL string `json:"heroVideoUrl,omitempty"`
TitleLogoURL string `json:"titleLogoUrl,omitempty"`
TileShape string `json:"tileShape"`
HideTitle bool `json:"hideTitle"`
Expand Down Expand Up @@ -107,7 +106,6 @@ func pushFolder(f FolderWithCatalogs, catalogs map[uuid.UUID]Catalog) PushFolder
FocusGIFURL: f.FocusGIFURL,
FocusGIFEnabled: f.FocusGIFEnabled,
HeroBackdropURL: f.HeroBackdropURL,
HeroVideoURL: f.HeroVideoURL,
TitleLogoURL: f.TitleLogoURL,
TileShape: f.TileShape,
HideTitle: f.HideTitle,
Expand Down
6 changes: 4 additions & 2 deletions internal/vault/pushpayload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestPushPayloadAppearanceFields(t *testing.T) {
if v, ok := off["focusGifEnabled"]; !ok || v != false {
t.Errorf("off folder focusGifEnabled = %v (present %v), want explicit false: %s", v, ok, raw)
}
for _, key := range []string{"focusGifUrl", "heroBackdropUrl", "heroVideoUrl", "titleLogoUrl"} {
for _, key := range []string{"focusGifUrl", "heroBackdropUrl", "titleLogoUrl"} {
if _, ok := off[key]; ok {
t.Errorf("off folder carries empty %s: %s", key, raw)
}
Expand All @@ -97,14 +97,16 @@ func TestPushPayloadAppearanceFields(t *testing.T) {
"focusGifEnabled": true,
"focusGifUrl": "https://example.com/f.gif",
"heroBackdropUrl": "https://example.com/b.jpg",
"heroVideoUrl": "https://example.com/v.mp4",
"titleLogoUrl": "https://example.com/l.png",
}
for key, v := range want {
if on[key] != v {
t.Errorf("on folder %s = %v, want %v: %s", key, on[key], v, raw)
}
}
if _, ok := on["heroVideoUrl"]; ok {
t.Errorf("on folder carries heroVideoUrl, which Uno never sends: %s", raw)
}
}

// A collection's folders and a folder's catalogSources go out as JSON arrays,
Expand Down
3 changes: 1 addition & 2 deletions internal/vault/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (in CollectionForm) normalized() CollectionForm {
func (fd FolderData) normalized() FolderData {
for _, s := range []*string{
&fd.Title, &fd.CoverEmoji, &fd.CoverImageURL, &fd.FocusGIFURL,
&fd.HeroBackdropURL, &fd.HeroVideoURL, &fd.TitleLogoURL,
&fd.HeroBackdropURL, &fd.TitleLogoURL,
} {
*s = strings.TrimSpace(*s)
}
Expand Down Expand Up @@ -289,7 +289,6 @@ func folderProblems(index int, fd FolderData) []string {
{"cover image url", fd.CoverImageURL},
{"focus gif url", fd.FocusGIFURL},
{"hero backdrop url", fd.HeroBackdropURL},
{"hero video url", fd.HeroVideoURL},
{"title logo url", fd.TitleLogoURL},
} {
problems = appendProblem(problems, mediaURLProblem(fmt.Sprintf("folder %d: %s", index, f.name), f.value))
Expand Down
2 changes: 0 additions & 2 deletions web/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export interface FolderLook {
focus_gif_enabled: boolean
/** Hero media for Nuvio's Modern Home layout. */
hero_backdrop_url: string
hero_video_url: string
title_logo_url: string
}

Expand Down Expand Up @@ -286,7 +285,6 @@ export interface WithheldPicture {
| 'cover_image_url'
| 'focus_gif_url'
| 'hero_backdrop_url'
| 'hero_video_url'
| 'title_logo_url'
url: string
site: string
Expand Down
12 changes: 2 additions & 10 deletions web/src/features/collections/FolderDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function appearanceSummary(folder: FolderFormState): string {
if (folder.coverImageURL.trim()) parts.push('cover image')
else if (folder.coverEmoji.trim()) parts.push(`${folder.coverEmoji.trim()} cover`)
if (folder.focusGIFEnabled && folder.focusGIFURL.trim()) parts.push('focus GIF')
if (folder.heroBackdropURL.trim() || folder.heroVideoURL.trim() || folder.titleLogoURL.trim()) {
if (folder.heroBackdropURL.trim() || folder.titleLogoURL.trim()) {
parts.push('Modern Home hero')
}
return parts.join(' · ')
Expand Down Expand Up @@ -208,15 +208,7 @@ export function FolderDetail({
onChange={(heroBackdropURL) => onChange({ heroBackdropURL })}
placeholder="Image URL, https://…"
ariaLabel={`Modern Home hero backdrop URL for ${label}`}
note="Hero backdrop, hero video and title logo are used only by Nuvio TV's Modern Home layout."
/>
<HeroURLRow
id={`${idBase}-hero-video`}
role="Hero video"
value={folder.heroVideoURL}
onChange={(heroVideoURL) => onChange({ heroVideoURL })}
placeholder="Video URL, https://…"
ariaLabel={`Modern Home hero video URL for ${label}`}
note="Hero backdrop and title logo are used only by Nuvio TV's Modern Home layout."
/>
<HeroURLRow
id={`${idBase}-title-logo`}
Expand Down
4 changes: 2 additions & 2 deletions web/src/features/collections/collectionForm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ describe('validateCollectionForm', () => {
const form = { ...emptyCollectionForm(), title: 'C', folders: [{ ...newFolder(), title: 'F', ...update }] }
return Object.values(validateCollectionForm(form, accessible).folders)[0]?.media
}
expect(media({ coverImageURL: 'https://x.test/a.png', heroVideoURL: ' https://x.test/v.mp4 ' })).toBeUndefined()
expect(media({ heroVideoURL: 'http://x.test/v.mp4' })).toBe('Hero video must be a web address starting with https://.')
expect(media({ coverImageURL: 'https://x.test/a.png', titleLogoURL: ' https://x.test/l.png ' })).toBeUndefined()
expect(media({ titleLogoURL: 'http://x.test/l.png' })).toBe('Title logo must be a web address starting with https://.')
expect(media({ coverImageURL: 'javascript:alert(1)' })).toBe(
'Cover image must be a web address starting with https://.',
)
Expand Down
Loading
Loading