Backend: Hide private photos in moments
Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
parent
43ec7e14e3
commit
5c574e3837
3 changed files with 13 additions and 8 deletions
|
@ -159,6 +159,7 @@ func NewMonthAlbum(albumTitle, albumSlug string, year, month int) *Album {
|
|||
f := form.PhotoSearch{
|
||||
Year: year,
|
||||
Month: month,
|
||||
Public: true,
|
||||
}
|
||||
|
||||
now := time.Now().UTC()
|
||||
|
|
|
@ -73,6 +73,7 @@ func (m *Moments) Start() (err error) {
|
|||
for _, mom := range results {
|
||||
f := form.PhotoSearch{
|
||||
Path: mom.Path,
|
||||
Public: true,
|
||||
}
|
||||
|
||||
if a := entity.FindAlbumBySlug(mom.Slug(), entity.TypeFolder); a != nil {
|
||||
|
@ -126,6 +127,7 @@ func (m *Moments) Start() (err error) {
|
|||
f := form.PhotoSearch{
|
||||
Country: mom.Country,
|
||||
Year: mom.Year,
|
||||
Public: true,
|
||||
}
|
||||
|
||||
if a := entity.FindAlbumBySlug(mom.Slug(), entity.TypeMoment); a != nil {
|
||||
|
@ -156,6 +158,7 @@ func (m *Moments) Start() (err error) {
|
|||
f := form.PhotoSearch{
|
||||
Country: mom.Country,
|
||||
State: mom.State,
|
||||
Public: true,
|
||||
}
|
||||
|
||||
if a := entity.FindAlbumBySlug(mom.Slug(), entity.TypeMoment); a != nil {
|
||||
|
@ -184,6 +187,7 @@ func (m *Moments) Start() (err error) {
|
|||
for _, mom := range results {
|
||||
f := form.PhotoSearch{
|
||||
Label: mom.Label,
|
||||
Public: true,
|
||||
}
|
||||
|
||||
if a := entity.FindAlbumBySlug(mom.Slug(), entity.TypeMoment); a != nil {
|
||||
|
|
|
@ -89,7 +89,7 @@ type Moments []Moment
|
|||
func MomentsTime(threshold int) (results Moments, err error) {
|
||||
db := UnscopedDb().Table("photos").
|
||||
Select("photos.photo_year AS year, photos.photo_month AS month, COUNT(*) AS photo_count").
|
||||
Where("photos.photo_quality >= 3 AND deleted_at IS NULL AND photos.photo_year > 0 AND photos.photo_month > 0").
|
||||
Where("photos.photo_quality >= 3 AND deleted_at IS NULL AND photo_private = 0 AND photos.photo_year > 0 AND photos.photo_month > 0").
|
||||
Group("photos.photo_year, photos.photo_month").
|
||||
Order("photos.photo_year DESC, photos.photo_month DESC").
|
||||
Having("photo_count >= ?", threshold)
|
||||
|
@ -105,7 +105,7 @@ func MomentsTime(threshold int) (results Moments, err error) {
|
|||
func MomentsCountries(threshold int) (results Moments, err error) {
|
||||
db := UnscopedDb().Table("photos").
|
||||
Select("photo_country AS country, photo_year AS year, COUNT(*) AS photo_count ").
|
||||
Where("photos.photo_quality >= 3 AND deleted_at IS NULL AND photo_country <> 'zz' AND photo_year > 0").
|
||||
Where("photos.photo_quality >= 3 AND deleted_at IS NULL AND photo_private = 0 AND photo_country <> 'zz' AND photo_year > 0").
|
||||
Group("photo_country, photo_year").
|
||||
Having("photo_count >= ?", threshold)
|
||||
|
||||
|
@ -121,7 +121,7 @@ func MomentsStates(threshold int) (results Moments, err error) {
|
|||
db := UnscopedDb().Table("photos").
|
||||
Select("p.loc_country AS country, p.loc_state AS state, COUNT(*) AS photo_count").
|
||||
Joins("JOIN places p ON p.id = photos.place_id").
|
||||
Where("photos.photo_quality >= 3 AND photos.deleted_at IS NULL AND p.loc_state <> '' AND p.loc_country <> 'zz'").
|
||||
Where("photos.photo_quality >= 3 AND photos.deleted_at IS NULL AND photo_private = 0 AND p.loc_state <> '' AND p.loc_country <> 'zz'").
|
||||
Group("p.loc_country, p.loc_state").
|
||||
Having("photo_count >= ?", threshold)
|
||||
|
||||
|
@ -144,7 +144,7 @@ func MomentsLabels(threshold int) (results Moments, err error) {
|
|||
Select("l.label_slug AS label, COUNT(*) AS photo_count").
|
||||
Joins("JOIN photos_labels pl ON pl.photo_id = photos.id AND pl.uncertainty < 100").
|
||||
Joins("JOIN labels l ON l.id = pl.label_id").
|
||||
Where("photos.photo_quality >= 3 AND photos.deleted_at IS NULL AND l.label_slug IN (?)", cats).
|
||||
Where("photos.photo_quality >= 3 AND photos.deleted_at IS NULL AND photo_private = 0 AND l.label_slug IN (?)", cats).
|
||||
Group("l.label_slug").
|
||||
Having("photo_count >= ?", threshold)
|
||||
|
||||
|
|
Loading…
Reference in a new issue