docs

package
v1.22.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LocationOther LocationType = 0
	LocationHike               = 1
	LocationPark               = 2
)
View Source
const (
	EventDay int = iota
	EventMonth
)

EventEntry stores the count of an event in one time period

View Source
const VisTokenAll = "*"

VisTokenAll is the placeholder token value representing "all" tokens. It should exist on all every entity. Its value is picked to specifically to be not a valid slug so that it wouldn't conflict with any created token ids.

View Source
const VisTokenPublic = "#P"

VisTokenPublic is the virtual token id representing public access (there is no actual VisibilityToken corresponding to this id) Its value is picked to specifically to be not a valid slug so that it wouldn't conflict with any created token ids.

Variables

This section is empty.

Functions

func IsValidVisTokenID added in v0.11.0

func IsValidVisTokenID(id string) bool

IsValidVisTokenID checks if the id is a valid visibility token id

Types

type CategoryEntry

type CategoryEntry struct {
	GroupBase `bson:",inline" json:",inline"`

	// Related categories
	Related map[string][]string `bson:"related,omitempty" json:"related,omitempty"`
}

CategoryEntry is the structure of a category document, which includes categories and category values

type Date

type Date struct {
	GroupBase `bson:",inline" json:",inline"`
}

Date is the structure of a date document

type EventEntry added in v1.17.0

type EventEntry struct {
	Event   *string    `bson:"event,omitempty" json:"event,omitempty"`
	Object  *string    `bson:"object,omitempty" json:"object,omitempty"`
	Context *string    `bson:"context,omitempty" json:"context,omitempty"`
	Count   *int       `bson:"count,omitempty" json:"count,omitempty"`
	Date    *time.Time `bson:"date,omitempty" json:"date,omitempty"`
	Extra   *string    `bson:"extra,omitempty" json:"extra,omitempty"`
}

type Folder

type Folder struct {
	GroupBase `bson:",inline" json:",inline"`
	// SelfVisTokens are tokens explicitly put on this folder
	SelfVisTokens []string `bson:"selfVisTokens" json:"selfVisTokens,omitempty"`
}

Folder is the structure of a folder document

type GeoJSONPoint

type GeoJSONPoint struct {
	Type        string    `bson:"type" json:"-"`
	Coordinates []float64 `bson:"coordinates" json:"coordinates"`
}

GeoJSONPoint represents a MongoDB GeoJSON point Designed to be added to MongoDB as a document

func NewGeoJSONPoint

func NewGeoJSONPoint(latitude float64, longitude float64) *GeoJSONPoint

NewGeoJSONPoint creates a new GeoJSONPoint object

func (*GeoJSONPoint) GetLatitude

func (pt *GeoJSONPoint) GetLatitude() float64

GetLatitude returns the latitude component of the point

func (*GeoJSONPoint) GetLongitude

func (pt *GeoJSONPoint) GetLongitude() float64

GetLongitude returns the longitude component of the point

func (*GeoJSONPoint) SetLatitude

func (pt *GeoJSONPoint) SetLatitude(latitude float64)

SetLatitude sets the latitude component of the point

func (*GeoJSONPoint) SetLongitude

func (pt *GeoJSONPoint) SetLongitude(longitude float64)

SetLongitude sets the longitude component of the point

type GroupBase

type GroupBase struct {
	ID         *string          `bson:"_id" json:"id,omitempty"`                        // slug path
	Timestamp  *time.Time       `bson:"timestamp,omitempty" json:"timestamp,omitempty"` // last time something was added or modified belonging to the group
	Display    *string          `bson:"display,omitempty" json:"display,omitempty"`     // display path
	Depth      *int             `bson:"depth,omitempty" json:"depth,omitempty"`
	SortOrder  *interface{}     `bson:"sortOrder,omitempty" json:"sortOrder,omitempty"` // string or integer
	CoverPhoto *GroupCoverPhoto `bson:"coverPhoto,omitempty" json:"coverPhoto,omitempty"`

	// Visibility tokens should never be nil. At least an empty array.
	VisTokens          []string       `bson:"visTokens" json:"visTokens,omitempty"`
	VisTokenCounts     map[string]int `bson:"visTokenCounts" json:"visTokenCounts,omitempty"`
	DescVisTokenCounts map[string]int `bson:"descVisTokenCounts" json:"descVisTokenCounts,omitempty"`

	// Content
	MetaDescription *string `bson:"metaDescription,omitempty" json:"metaDescription,omitempty"`
	RichText        *string `bson:"richText,omitempty" json:"richText,omitempty"`
}

GroupBase defines the base fields for a grouping collection. Should be embedded in the overall group-specific document with bson:",inline" and json:",inline".

func (GroupBase) GetID added in v1.22.8

func (g GroupBase) GetID() string

type GroupCoverPhoto added in v0.11.0

type GroupCoverPhoto struct {
	Photo            *PhotoID   `bson:"photo,omitempty" json:"photo,omitempty"`
	UserSelected     *bool      `bson:"userSelected,omitempty" json:"userSelected,omitempty"`
	LastAutoSelected *time.Time `bson:"lastAutoSelected,omitempty" json:"lastAutoSelected,omitempty"`
}

GroupCoverPhoto describes the current cover photo for a group

type Keyword

type Keyword struct {
	GroupBase `bson:",inline" json:",inline"`
}

Keyword is the structure of a keyword document

type Location

type Location struct {
	GroupBase `bson:",inline" json:",inline"`
	Type      *LocationType `bson:"type" json:"type,omitempty"`
	Park      *string       `bson:"park" json:"park,omitempty"`
	ParkName  *string       `bson:"parkName" json:"parkName,omitempty"`
}

Location is the structure of a location document

type LocationType added in v1.20.0

type LocationType int

type Photo

type Photo struct {
	ID          *PhotoID   `bson:"_id" json:"id,omitempty"`
	SortKey     *string    `bson:"sortKey" json:"sortKey,omitempty"`
	StoreBucket *string    `bson:"storeBucket" json:"storeBucket,omitempty"`
	StoreObject *string    `bson:"storeObject" json:"storeObject,omitempty"`
	StoreGen    *string    `bson:"storeGen" json:"storeGen,omitempty"` // base64 encoded
	FileSize    *int       `bson:"fileSize" json:"fileSize,omitempty"`
	Folder      *string    `bson:"folder" json:"folder,omitempty"` // slug
	Width       *int       `bson:"width" json:"width,omitempty"`
	Height      *int       `bson:"height" json:"height,omitempty"`
	Timestamp   *time.Time `bson:"timestamp" json:"timestamp,omitempty"`
	TsSortKey   *string    `bson:"tsSortKey" json:"tsSortKey,omitempty"`
	Date        *string    `bson:"date" json:"date,omitempty"`

	// A photo either inherits its folder's visibility or has its own visibility tokens
	InheritVisibility *bool `bson:"inheritVisibility,omitempty" json:"inheritVisibility,omitempty"`

	// VisTokens control visibility and account for photo self-visibility and folder visibility.
	// In BSON, don't use omitempty as this field should never be nil (at least an empty array).
	VisTokens []string `bson:"visTokens" json:"visTokens,omitempty"`

	// Optional metadata
	Title       *string    `bson:"title,omitempty" json:"title,omitempty"`
	Description *string    `bson:"description,omitempty" json:"description,omitempty"`
	Keywords    []string   `bson:"keywords,omitempty" json:"keywords,omitempty"`     // slugs
	Categories  []string   `bson:"categories,omitempty" json:"categories,omitempty"` // slugs
	DateTime    *time.Time `bson:"dateTime,omitempty" json:"dateTime,omitempty"`
	Rating      *int32     `bson:"rating,omitempty" json:"rating,omitempty"`

	Copyright   *string `bson:"copyright,omitempty" json:"copyright,omitempty"`
	UsageTerms  *string `bson:"usageTerms,omitempty" json:"usageTerms,omitempty"`
	UsageWebURL *string `bson:"usageWebUrl,omitempty" json:"usageWebUrl,omitempty"`

	Locations   []string      `bson:"locations,omitempty" json:"locations,omitempty"` // slugs
	GPSLocation *GeoJSONPoint `bson:"gpsLocation,omitempty" json:"gpsLocation,omitempty"`
	GPSAltitude *float64      `bson:"gpsAltitude,omitempty" json:"gpsAltitude,omitempty"`

	Make         *string  `bson:"make,omitempty" json:"make,omitempty"`
	Model        *string  `bson:"model,omitempty" json:"model,omitempty"`
	Lens         *string  `bson:"lens,omitempty" json:"lens,omitempty"`
	FNumber      *float64 `bson:"fNumber,omitempty" json:"fNumber,omitempty"`
	FocalLength  *float64 `bson:"focalLength,omitempty" json:"focalLength,omitempty"`
	ISO          *int32   `bson:"iso,omitempty" json:"iso,omitempty"`
	ExposureTime *float64 `bson:"exposureTime,omitempty" json:"exposureTime,omitempty"`
	ExposureBias *float64 `bson:"exposureBias,omitempty" json:"exposureBias,omitempty"`
}

Photo is the structure of a folder document

type PhotoID

type PhotoID string

PhotoID is the id type for a photo document

type PhotoListFilterAspectRatio added in v1.6.0

type PhotoListFilterAspectRatio struct {
	Value float32                 `bson:"value" json:"value"`
	CmpOp list.ComparisonOperator `bson:"cmpOp" json:"cmpOp"`
}

PhotoListFilterAspectRatio filters by aspect ratio (photo width/height)

func (PhotoListFilterAspectRatio) Validate added in v1.6.0

func (ar PhotoListFilterAspectRatio) Validate() error

Validate aspect ratio filter

type PhotoListFilterDate added in v1.6.0

type PhotoListFilterDate struct {
	// yyyy[mm[dd[hh[mm[ss]]]]]
	Value string                  `bson:"value" json:"value"`
	CmpOp list.ComparisonOperator `bson:"cmpOp" json:"cmpOp"`
}

PhotoListFilterDate filters by date (which really filters by sortKey)

func (PhotoListFilterDate) Validate added in v1.6.0

func (date PhotoListFilterDate) Validate() error

Validate date filter

type PhotoListFilterExpr added in v1.6.0

type PhotoListFilterExpr struct {
	// Op defines the logical operation used to join all of the filter clauses
	Op list.LogicalOperator `bson:"op,omitempty" json:"op,omitempty"` // defaults to list.LogicalAnd

	// The filter expression itself can contain nested filter expressions
	Exprs []*PhotoListFilterExpr `bson:"exprs,omitempty" json:"exprs,omitempty"`

	// Property-specific filters
	Folders      []PhotoListFilterFolder      `bson:"folders,omitempty" json:"folders,omitempty"`
	Ratings      []PhotoListFilterRating      `bson:"ratings,omitempty" json:"ratings,omitempty"`
	Keywords     []string                     `bson:"keywords,omitempty" json:"keywords,omitempty"`     // ids
	Locations    []string                     `bson:"locations,omitempty" json:"locations,omitempty"`   // prefix ids
	Categories   []string                     `bson:"categories,omitempty" json:"categories,omitempty"` // ids
	Dates        []PhotoListFilterDate        `bson:"dates,omitempty" json:"dates,omitempty"`
	AspectRatios []PhotoListFilterAspectRatio `bson:"aspectRatios,omitempty" json:"aspectRatios,omitempty"`
}

PhotoListFilterExpr represents a filter expression

func (*PhotoListFilterExpr) AssignDefaults added in v1.6.0

func (expr *PhotoListFilterExpr) AssignDefaults()

AssignDefaults to expression

func (*PhotoListFilterExpr) BuildQueryFilter added in v1.6.0

func (expr *PhotoListFilterExpr) BuildQueryFilter() interface{}

BuildQueryFilter converts a PhotoListFilterExpr into a MongoDB query filter

func (*PhotoListFilterExpr) Clone added in v1.7.0

Clone

func (*PhotoListFilterExpr) IsEmpty added in v1.6.0

func (expr *PhotoListFilterExpr) IsEmpty() bool

IsEmpty returns true if there are no filters inside an expression

func (*PhotoListFilterExpr) Validate added in v1.6.0

func (expr *PhotoListFilterExpr) Validate() error

Validate expression

type PhotoListFilterFolder added in v1.6.0

type PhotoListFilterFolder struct {
	Path     string `bson:"path" json:"path"` // slug path
	FullTree bool   `bson:"fullTree" json:"fullTree"`
}

PhotoListFilterFolder filters by folder path

func (PhotoListFilterFolder) Validate added in v1.6.0

func (folder PhotoListFilterFolder) Validate() error

Validate folder filter

type PhotoListFilterRating added in v1.6.0

type PhotoListFilterRating struct {
	Value int                     `bson:"value" json:"value"` // >= 0
	CmpOp list.ComparisonOperator `bson:"cmpOp" json:"cmpOp"`
}

PhotoListFilterRating filters by photo rating

func (PhotoListFilterRating) Validate added in v1.6.0

func (rating PhotoListFilterRating) Validate() error

Validate rating filter

type PhotoResizeCacheEntry

type PhotoResizeCacheEntry struct {
	PhotoTimestamp time.Time `bson:"photoTimestamp"`
	FileSize       int       `bson:"fileSize"`
	LastAccess     time.Time `bson:"lastAccess"`
	CacheHit       int       `bson:"cacheHit"`
}

PhotoResizeCacheEntry is the embedded document structure for one cache entry

type Session

type Session struct {
	ID     SessionID `bson:"_id"`
	UserID UserID    `bson:"userId"`
	Expiry time.Time `bson:"expiry"`
}

Session stores info about a logged-in session

type SessionID

type SessionID string

SessionID is the type of a session id

type TimelineGroup added in v1.6.0

type TimelineGroup struct {
	GroupBase `bson:",inline" json:",inline"`

	// SelfVisTokens are tokens explicitly put on this group
	SelfVisTokens []string `bson:"selfVisTokens" json:"selfVisTokens,omitempty"`

	Filter    *PhotoListFilterExpr `bson:"filter,omitempty" json:"filter,omitempty"`
	StartDate *time.Time           `bson:"startDate,omitempty" json:"startDate,omitempty"`
	EndDate   *time.Time           `bson:"endDate,omitempty" json:"endDate,omitempty"`
}

TimelineGroup describes a timeline grouping of photos

type User

type User struct {
	ID             *UserID   `bson:"_id" json:"id,omitempty"`
	HashedPassword *string   `bson:"hashedPassword" json:"-"`
	Role           *UserRole `bson:"role" json:"role,omitempty"`
}

User is the document type for a user

type UserID

type UserID string

UserID is the id type for a user document

type UserRole

type UserRole string

UserRole type

const UserRoleAdmin UserRole = "admin"

UserRoleAdmin role

type VisibilityToken

type VisibilityToken struct {
	GroupBase `bson:",inline"`
	Links     []VisibilityTokenLink `bson:"links,omitempty" json:"links,omitempty"`
}

VisibilityToken describes a visibility token

type VisibilityTokenLink struct {
	// Cryptographically-secure activation value
	ActivationValue *string `bson:"activationValue,omitempty" json:"activationValue,omitempty"`
	ActivationCount *int    `bson:"activationCount,omitempty" json:"activationCount,omitempty"`
	Redirect        *string `bson:"redirect,omitempty" json:"redirect,omitempty"`
	Comment         *string `bson:"comment,omitempty" json:"comment,omitempty"`
	Disabled        *bool   `bson:"disabled,omitempty" json:"disabled,omitempty"`
}

VisibilityTokenLink describes a link for a token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL