docs

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

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

func UpdateGroupPhotoCountsAndVisTokens

func UpdateGroupPhotoCountsAndVisTokens(
	ctx context.Context,
	collection *mongo.Collection,
	oldIDs []string, newIDs []string,
	oldTokens []string, newTokens []string,
	otherUpdateModels []mongo.WriteModel,
	count int,
) error

UpdateGroupPhotoCountsAndVisTokens updates a set of group documents based on the diff of ids. Also updates the visibility token photo counts in each affected group document.

Types

type CategoryEntry

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

	// For category: <category name>
	// For category-value: <category name>:<category value>
	DisplayName *string `bson:"displayName,omitempty" json:"displayName,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 Folder

type Folder struct {
	GroupBase   `bson:",inline" json:",inline"`
	DisplayPath *string `bson:"displayPath,omitempty" json:"displayPath,omitempty"`

	// SelfVisibilityTokens are tokens explicitly put on this folder
	SelfVisibilityTokens []string `bson:"selfVisibilityTokens" json:"selfVisibilityTokens,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"`
	Depth      *int             `bson:"depth,omitempty" json:"depth,omitempty"`
	CoverPhoto *GroupCoverPhoto `bson:"coverPhoto,omitempty" json:"coverPhoto,omitempty"`

	// Visibility tokens should never be nil. At least an empty array.
	VisibilityTokens        []string       `bson:"visibilityTokens" json:"visibilityTokens,omitempty"`
	VisTokenPhotoCounts     map[string]int `bson:"visTokenPhotoCounts" json:"visTokenPhotoCounts,omitempty"`
	DescVisTokenPhotoCounts map[string]int `bson:"descVisTokenPhotoCounts" json:"descVisTokenPhotoCounts,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".

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"`
	DisplayName *string `bson:"displayName,omitempty" json:"displayName,omitempty"`
}

Keyword is the structure of a keyword document

type Location

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

	// Display path is a comma-separated value
	DisplayPath *string `bson:"displayPath,omitempty" json:"displayPath,omitempty"`
}

Location is the structure of a location document

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"`         // for display
	FolderSlug  *string    `bson:"folderSlug" json:"folderSlug,omitempty"` // for lookups
	FolderDepth *int       `bson:"folderDepth" json:"folderDepth,omitempty"`
	Width       *int       `bson:"width" json:"width,omitempty"`
	Height      *int       `bson:"height" json:"height,omitempty"`
	Timestamp   *time.Time `bson:"timestamp" json:"timestamp,omitempty"`

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

	// VisibilityTokens 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).
	VisibilityTokens []string `bson:"visibilityTokens" json:"visibilityTokens,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"`           // for display
	KeywordSlugs  []string   `bson:"keywordSlugs,omitempty" json:"keywordSlugs,omitempty"`   // for lookups
	Categories    []string   `bson:"categories,omitempty" json:"categories,omitempty"`       // for display
	CategorySlugs []string   `bson:"categorySlugs,omitempty" json:"categorySlugs,omitempty"` // for lookups
	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"`

	Location     *string       `bson:"location,omitempty" json:"location,omitempty"`         // for display
	LocationSlug *string       `bson:"locationSlug,omitempty" json:"locationSlug,omitempty"` // for lookups
	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 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 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"`

	Name  *string               `bson:"name,omitempty" json:"name,omitempty"`
	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