Site Gallery: Default to friends only

This commit is contained in:
Noah Petherbridge 2023-10-22 19:17:49 -07:00
parent 81da502f17
commit 61c47c032d
3 changed files with 38 additions and 10 deletions

View File

@ -25,6 +25,7 @@ func SiteGallery() http.HandlerFunc {
viewStyle = r.FormValue("view") // cards (default), full
// Search filters.
who = r.FormValue("who")
filterExplicit = r.FormValue("explicit")
filterVisibility = r.FormValue("visibility")
adminView = r.FormValue("admin_view") == "true"
@ -47,6 +48,9 @@ func SiteGallery() http.HandlerFunc {
if viewStyle != "full" {
viewStyle = "cards"
}
if who != "friends" && who != "everybody" {
who = "friends"
}
// Load the current user.
currentUser, err := session.CurrentUser(r)
@ -73,7 +77,7 @@ func SiteGallery() http.HandlerFunc {
Explicit: filterExplicit,
Visibility: filterVisibility,
AdminView: adminView,
ShyView: isShy,
FriendsOnly: isShy || who == "friends",
}, pager)
// Bulk load the users associated with these photos.
@ -105,6 +109,7 @@ func SiteGallery() http.HandlerFunc {
// Search filters
"Sort": sort,
"FilterWho": who,
"FilterExplicit": filterExplicit,
"FilterVisibility": filterVisibility,
"AdminView": adminView,

View File

@ -399,7 +399,7 @@ type Gallery struct {
Explicit string // Explicit filter
Visibility string // Visibility filter
AdminView bool // Show all images
ShyView bool // Current user is shy (self/friends only)
FriendsOnly bool // Only show self/friends instead of everybody's pics
}
/*
@ -412,7 +412,7 @@ func PaginateGalleryPhotos(user *User, conf Gallery, pager *Pagination) ([]*Phot
filterExplicit = conf.Explicit
filterVisibility = conf.Visibility
adminView = conf.AdminView
isShy = conf.ShyView
friendsOnly = conf.FriendsOnly
p = []*Photo{}
query *gorm.DB
@ -451,7 +451,7 @@ func PaginateGalleryPhotos(user *User, conf Gallery, pager *Pagination) ([]*Phot
friendIDs = append(friendIDs, userID)
// Whose photos can you see on the Site Gallery?
if isShy {
if friendsOnly {
// Shy users can only see their Friends photos (public or friends visibility)
// and any Private photos to whom they were granted access.
wheres = append(wheres,

View File

@ -223,6 +223,14 @@
</div>
</div>
<!-- Indicator if friends-only is selected. -->
{{if eq .FilterWho "friends"}}
<div class="notification is-success is-light">
Showing you all recent photos from <strong>your friends.</strong>
<a href="{{.Request.URL.Path}}?who=everybody">See all certified members' gallery photos?</a>
</div>
{{end}}
<!-- Filters -->
<div class="block">
<form action="{{.Request.URL.Path}}" method="GET">
@ -241,6 +249,21 @@
<div class="card-content">
<div class="columns is-multiline mb-0">
<!-- Site Gallery: friends-only filter -->
{{if .IsSiteGallery}}
<div class="column">
<div class="field">
<label class="label" for="who">Whose photos:</label>
<div class="select is-fullwidth">
<select id="who" name="who">
<option value="friends"{{if eq .FilterWho "friends"}} selected{{end}}>My friends only</option>
<option value="everybody"{{if eq .FilterWho "everybody"}} selected{{end}}>All certified members</option>
</select>
</div>
</div>
</div>
{{end}}
{{if or .CurrentUser.Explicit .IsOwnPhotos}}
<div class="column">
<div class="field">