diff --git a/api/database/migrations/008_video_support.down.sql b/api/database/migrations/008_video_support.down.sql new file mode 100644 index 00000000..81325de9 --- /dev/null +++ b/api/database/migrations/008_video_support.down.sql @@ -0,0 +1,9 @@ + +ALTER TABLE media RENAME TO photo; +ALTER TABLE media_url RENAME TO photo_url; +ALTER TABLE media_exif RENAME TO photo_exif; + +ALTER TABLE photo CHANGE COLUMN media_id photo_id int NOT NULL AUTO_INCREMENT; +ALTER TABLE photo_url CHANGE COLUMN media_id photo_id int NOT NULL; +ALTER TABLE photo_url CHANGE COLUMN media_name photo_name varchar(512) NOT NULL; +ALTER TABLE share_token CHANGE COLUMN media_id photo_id int; diff --git a/api/database/migrations/008_video_support.up.sql b/api/database/migrations/008_video_support.up.sql new file mode 100644 index 00000000..7ac5bdec --- /dev/null +++ b/api/database/migrations/008_video_support.up.sql @@ -0,0 +1,9 @@ + +ALTER TABLE photo RENAME TO media; +ALTER TABLE photo_url RENAME TO media_url; +ALTER TABLE photo_exif RENAME TO media_exif; + +ALTER TABLE media CHANGE COLUMN photo_id media_id int NOT NULL AUTO_INCREMENT; +ALTER TABLE media_url CHANGE COLUMN photo_id media_id int NOT NULL; +ALTER TABLE media_url CHANGE COLUMN photo_name media_name varchar(512) NOT NULL; +ALTER TABLE share_token CHANGE COLUMN photo_id media_id int; diff --git a/api/gqlgen.yml b/api/gqlgen.yml index d0222856..eb985768 100644 --- a/api/gqlgen.yml +++ b/api/gqlgen.yml @@ -24,12 +24,12 @@ models: model: github.com/99designs/gqlgen/graphql.IntID User: model: github.com/viktorstrate/photoview/api/graphql/models.User - Photo: - model: github.com/viktorstrate/photoview/api/graphql/models.Photo - PhotoURL: - model: github.com/viktorstrate/photoview/api/graphql/models.PhotoURL - PhotoEXIF: - model: github.com/viktorstrate/photoview/api/graphql/models.PhotoEXIF + Media: + model: github.com/viktorstrate/photoview/api/graphql/models.Media + MediaURL: + model: github.com/viktorstrate/photoview/api/graphql/models.MediaURL + MediaEXIF: + model: github.com/viktorstrate/photoview/api/graphql/models.MediaEXIF Album: model: github.com/viktorstrate/photoview/api/graphql/models.Album ShareToken: diff --git a/api/graphql/generated.go b/api/graphql/generated.go index eac92df9..afd012c1 100644 --- a/api/graphql/generated.go +++ b/api/graphql/generated.go @@ -39,8 +39,8 @@ type Config struct { type ResolverRoot interface { Album() AlbumResolver + Media() MediaResolver Mutation() MutationResolver - Photo() PhotoResolver Query() QueryResolver ShareToken() ShareTokenResolver Subscription() SubscriptionResolver @@ -54,10 +54,10 @@ type ComplexityRoot struct { Album struct { FilePath func(childComplexity int) int ID func(childComplexity int) int + Media func(childComplexity int, filter *models.Filter) int Owner func(childComplexity int) int ParentAlbum func(childComplexity int) int Path func(childComplexity int) int - Photos func(childComplexity int, filter *models.Filter) int Shares func(childComplexity int) int SubAlbums func(childComplexity int, filter *models.Filter) int Thumbnail func(childComplexity int) int @@ -70,19 +70,60 @@ type ComplexityRoot struct { Token func(childComplexity int) int } + Media struct { + Album func(childComplexity int) int + Downloads func(childComplexity int) int + Exif func(childComplexity int) int + Favorite func(childComplexity int) int + HighRes func(childComplexity int) int + ID func(childComplexity int) int + Path func(childComplexity int) int + Shares func(childComplexity int) int + Thumbnail func(childComplexity int) int + Title func(childComplexity int) int + } + + MediaDownload struct { + Height func(childComplexity int) int + Title func(childComplexity int) int + URL func(childComplexity int) int + Width func(childComplexity int) int + } + + MediaExif struct { + Aperture func(childComplexity int) int + Camera func(childComplexity int) int + DateShot func(childComplexity int) int + Exposure func(childComplexity int) int + ExposureProgram func(childComplexity int) int + Flash func(childComplexity int) int + FocalLength func(childComplexity int) int + ID func(childComplexity int) int + Iso func(childComplexity int) int + Lens func(childComplexity int) int + Maker func(childComplexity int) int + Media func(childComplexity int) int + } + + MediaURL struct { + Height func(childComplexity int) int + URL func(childComplexity int) int + Width func(childComplexity int) int + } + Mutation struct { AuthorizeUser func(childComplexity int, username string, password string) int CreateUser func(childComplexity int, username string, rootPath string, password *string, admin bool) int DeleteShareToken func(childComplexity int, token string) int DeleteUser func(childComplexity int, id int) int - FavoritePhoto func(childComplexity int, photoID int, favorite bool) int + FavoriteMedia func(childComplexity int, mediaID int, favorite bool) int InitialSetupWizard func(childComplexity int, username string, password string, rootPath string) int ProtectShareToken func(childComplexity int, token string, password *string) int RegisterUser func(childComplexity int, username string, password string, rootPath string) int ScanAll func(childComplexity int) int ScanUser func(childComplexity int, userID int) int ShareAlbum func(childComplexity int, albumID int, expire *time.Time, password *string) int - SharePhoto func(childComplexity int, photoID int, expire *time.Time, password *string) int + ShareMedia func(childComplexity int, mediaID int, expire *time.Time, password *string) int UpdateUser func(childComplexity int, id int, username *string, rootPath *string, password *string, admin *bool) int } @@ -97,54 +138,13 @@ type ComplexityRoot struct { Type func(childComplexity int) int } - Photo struct { - Album func(childComplexity int) int - Downloads func(childComplexity int) int - Exif func(childComplexity int) int - Favorite func(childComplexity int) int - HighRes func(childComplexity int) int - ID func(childComplexity int) int - Path func(childComplexity int) int - Shares func(childComplexity int) int - Thumbnail func(childComplexity int) int - Title func(childComplexity int) int - } - - PhotoDownload struct { - Height func(childComplexity int) int - Title func(childComplexity int) int - URL func(childComplexity int) int - Width func(childComplexity int) int - } - - PhotoExif struct { - Aperture func(childComplexity int) int - Camera func(childComplexity int) int - DateShot func(childComplexity int) int - Exposure func(childComplexity int) int - ExposureProgram func(childComplexity int) int - Flash func(childComplexity int) int - FocalLength func(childComplexity int) int - ID func(childComplexity int) int - Iso func(childComplexity int) int - Lens func(childComplexity int) int - Maker func(childComplexity int) int - Photo func(childComplexity int) int - } - - PhotoURL struct { - Height func(childComplexity int) int - URL func(childComplexity int) int - Width func(childComplexity int) int - } - Query struct { Album func(childComplexity int, id int) int + Media func(childComplexity int, id int) int MyAlbums func(childComplexity int, filter *models.Filter, onlyRoot *bool, showEmpty *bool) int - MyPhotos func(childComplexity int, filter *models.Filter) int + MyMedia func(childComplexity int, filter *models.Filter) int MyUser func(childComplexity int) int - Photo func(childComplexity int, id int) int - Search func(childComplexity int, query string, limitPhotos *int, limitAlbums *int) int + Search func(childComplexity int, query string, limitMedia *int, limitAlbums *int) int ShareToken func(childComplexity int, token string, password *string) int ShareTokenValidatePassword func(childComplexity int, token string, password *string) int SiteInfo func(childComplexity int) int @@ -160,7 +160,7 @@ type ComplexityRoot struct { SearchResult struct { Albums func(childComplexity int) int - Photos func(childComplexity int) int + Media func(childComplexity int) int Query func(childComplexity int) int } @@ -169,8 +169,8 @@ type ComplexityRoot struct { Expire func(childComplexity int) int HasPassword func(childComplexity int) int ID func(childComplexity int) int + Media func(childComplexity int) int Owner func(childComplexity int) int - Photo func(childComplexity int) int Token func(childComplexity int) int } @@ -191,15 +191,24 @@ type ComplexityRoot struct { } type AlbumResolver interface { - Photos(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Photo, error) + Media(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Media, error) SubAlbums(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Album, error) ParentAlbum(ctx context.Context, obj *models.Album) (*models.Album, error) Owner(ctx context.Context, obj *models.Album) (*models.User, error) - Thumbnail(ctx context.Context, obj *models.Album) (*models.Photo, error) + Thumbnail(ctx context.Context, obj *models.Album) (*models.Media, error) Path(ctx context.Context, obj *models.Album) ([]*models.Album, error) Shares(ctx context.Context, obj *models.Album) ([]*models.ShareToken, error) } +type MediaResolver interface { + Thumbnail(ctx context.Context, obj *models.Media) (*models.MediaURL, error) + HighRes(ctx context.Context, obj *models.Media) (*models.MediaURL, error) + Album(ctx context.Context, obj *models.Media) (*models.Album, error) + Exif(ctx context.Context, obj *models.Media) (*models.MediaEXIF, error) + + Shares(ctx context.Context, obj *models.Media) ([]*models.ShareToken, error) + Downloads(ctx context.Context, obj *models.Media) ([]*models.MediaDownload, error) +} type MutationResolver interface { AuthorizeUser(ctx context.Context, username string, password string) (*models.AuthorizeResult, error) RegisterUser(ctx context.Context, username string, password string, rootPath string) (*models.AuthorizeResult, error) @@ -207,41 +216,32 @@ type MutationResolver interface { ScanAll(ctx context.Context) (*models.ScannerResult, error) ScanUser(ctx context.Context, userID int) (*models.ScannerResult, error) ShareAlbum(ctx context.Context, albumID int, expire *time.Time, password *string) (*models.ShareToken, error) - SharePhoto(ctx context.Context, photoID int, expire *time.Time, password *string) (*models.ShareToken, error) + ShareMedia(ctx context.Context, mediaID int, expire *time.Time, password *string) (*models.ShareToken, error) DeleteShareToken(ctx context.Context, token string) (*models.ShareToken, error) ProtectShareToken(ctx context.Context, token string, password *string) (*models.ShareToken, error) - FavoritePhoto(ctx context.Context, photoID int, favorite bool) (*models.Photo, error) + FavoriteMedia(ctx context.Context, mediaID int, favorite bool) (*models.Media, error) UpdateUser(ctx context.Context, id int, username *string, rootPath *string, password *string, admin *bool) (*models.User, error) CreateUser(ctx context.Context, username string, rootPath string, password *string, admin bool) (*models.User, error) DeleteUser(ctx context.Context, id int) (*models.User, error) } -type PhotoResolver interface { - Thumbnail(ctx context.Context, obj *models.Photo) (*models.PhotoURL, error) - HighRes(ctx context.Context, obj *models.Photo) (*models.PhotoURL, error) - Album(ctx context.Context, obj *models.Photo) (*models.Album, error) - Exif(ctx context.Context, obj *models.Photo) (*models.PhotoEXIF, error) - - Shares(ctx context.Context, obj *models.Photo) ([]*models.ShareToken, error) - Downloads(ctx context.Context, obj *models.Photo) ([]*models.PhotoDownload, error) -} type QueryResolver interface { SiteInfo(ctx context.Context) (*models.SiteInfo, error) User(ctx context.Context, filter *models.Filter) ([]*models.User, error) MyUser(ctx context.Context) (*models.User, error) MyAlbums(ctx context.Context, filter *models.Filter, onlyRoot *bool, showEmpty *bool) ([]*models.Album, error) Album(ctx context.Context, id int) (*models.Album, error) - MyPhotos(ctx context.Context, filter *models.Filter) ([]*models.Photo, error) - Photo(ctx context.Context, id int) (*models.Photo, error) + MyMedia(ctx context.Context, filter *models.Filter) ([]*models.Media, error) + Media(ctx context.Context, id int) (*models.Media, error) ShareToken(ctx context.Context, token string, password *string) (*models.ShareToken, error) ShareTokenValidatePassword(ctx context.Context, token string, password *string) (bool, error) - Search(ctx context.Context, query string, limitPhotos *int, limitAlbums *int) (*models.SearchResult, error) + Search(ctx context.Context, query string, limitMedia *int, limitAlbums *int) (*models.SearchResult, error) } type ShareTokenResolver interface { Owner(ctx context.Context, obj *models.ShareToken) (*models.User, error) HasPassword(ctx context.Context, obj *models.ShareToken) (bool, error) Album(ctx context.Context, obj *models.ShareToken) (*models.Album, error) - Photo(ctx context.Context, obj *models.ShareToken) (*models.Photo, error) + Media(ctx context.Context, obj *models.ShareToken) (*models.Media, error) } type SubscriptionResolver interface { Notification(ctx context.Context) (<-chan *models.Notification, error) @@ -276,6 +276,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Album.ID(childComplexity), true + case "Album.media": + if e.complexity.Album.Media == nil { + break + } + + args, err := ec.field_Album_media_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Album.Media(childComplexity, args["filter"].(*models.Filter)), true + case "Album.owner": if e.complexity.Album.Owner == nil { break @@ -297,18 +309,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Album.Path(childComplexity), true - case "Album.photos": - if e.complexity.Album.Photos == nil { - break - } - - args, err := ec.field_Album_photos_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Album.Photos(childComplexity, args["filter"].(*models.Filter)), true - case "Album.shares": if e.complexity.Album.Shares == nil { break @@ -363,6 +363,209 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.AuthorizeResult.Token(childComplexity), true + case "Media.album": + if e.complexity.Media.Album == nil { + break + } + + return e.complexity.Media.Album(childComplexity), true + + case "Media.downloads": + if e.complexity.Media.Downloads == nil { + break + } + + return e.complexity.Media.Downloads(childComplexity), true + + case "Media.exif": + if e.complexity.Media.Exif == nil { + break + } + + return e.complexity.Media.Exif(childComplexity), true + + case "Media.favorite": + if e.complexity.Media.Favorite == nil { + break + } + + return e.complexity.Media.Favorite(childComplexity), true + + case "Media.highRes": + if e.complexity.Media.HighRes == nil { + break + } + + return e.complexity.Media.HighRes(childComplexity), true + + case "Media.id": + if e.complexity.Media.ID == nil { + break + } + + return e.complexity.Media.ID(childComplexity), true + + case "Media.path": + if e.complexity.Media.Path == nil { + break + } + + return e.complexity.Media.Path(childComplexity), true + + case "Media.shares": + if e.complexity.Media.Shares == nil { + break + } + + return e.complexity.Media.Shares(childComplexity), true + + case "Media.thumbnail": + if e.complexity.Media.Thumbnail == nil { + break + } + + return e.complexity.Media.Thumbnail(childComplexity), true + + case "Media.title": + if e.complexity.Media.Title == nil { + break + } + + return e.complexity.Media.Title(childComplexity), true + + case "MediaDownload.height": + if e.complexity.MediaDownload.Height == nil { + break + } + + return e.complexity.MediaDownload.Height(childComplexity), true + + case "MediaDownload.title": + if e.complexity.MediaDownload.Title == nil { + break + } + + return e.complexity.MediaDownload.Title(childComplexity), true + + case "MediaDownload.url": + if e.complexity.MediaDownload.URL == nil { + break + } + + return e.complexity.MediaDownload.URL(childComplexity), true + + case "MediaDownload.width": + if e.complexity.MediaDownload.Width == nil { + break + } + + return e.complexity.MediaDownload.Width(childComplexity), true + + case "MediaEXIF.aperture": + if e.complexity.MediaExif.Aperture == nil { + break + } + + return e.complexity.MediaExif.Aperture(childComplexity), true + + case "MediaEXIF.camera": + if e.complexity.MediaExif.Camera == nil { + break + } + + return e.complexity.MediaExif.Camera(childComplexity), true + + case "MediaEXIF.dateShot": + if e.complexity.MediaExif.DateShot == nil { + break + } + + return e.complexity.MediaExif.DateShot(childComplexity), true + + case "MediaEXIF.exposure": + if e.complexity.MediaExif.Exposure == nil { + break + } + + return e.complexity.MediaExif.Exposure(childComplexity), true + + case "MediaEXIF.exposureProgram": + if e.complexity.MediaExif.ExposureProgram == nil { + break + } + + return e.complexity.MediaExif.ExposureProgram(childComplexity), true + + case "MediaEXIF.flash": + if e.complexity.MediaExif.Flash == nil { + break + } + + return e.complexity.MediaExif.Flash(childComplexity), true + + case "MediaEXIF.focalLength": + if e.complexity.MediaExif.FocalLength == nil { + break + } + + return e.complexity.MediaExif.FocalLength(childComplexity), true + + case "MediaEXIF.id": + if e.complexity.MediaExif.ID == nil { + break + } + + return e.complexity.MediaExif.ID(childComplexity), true + + case "MediaEXIF.iso": + if e.complexity.MediaExif.Iso == nil { + break + } + + return e.complexity.MediaExif.Iso(childComplexity), true + + case "MediaEXIF.lens": + if e.complexity.MediaExif.Lens == nil { + break + } + + return e.complexity.MediaExif.Lens(childComplexity), true + + case "MediaEXIF.maker": + if e.complexity.MediaExif.Maker == nil { + break + } + + return e.complexity.MediaExif.Maker(childComplexity), true + + case "MediaEXIF.media": + if e.complexity.MediaExif.Media == nil { + break + } + + return e.complexity.MediaExif.Media(childComplexity), true + + case "MediaURL.height": + if e.complexity.MediaURL.Height == nil { + break + } + + return e.complexity.MediaURL.Height(childComplexity), true + + case "MediaURL.url": + if e.complexity.MediaURL.URL == nil { + break + } + + return e.complexity.MediaURL.URL(childComplexity), true + + case "MediaURL.width": + if e.complexity.MediaURL.Width == nil { + break + } + + return e.complexity.MediaURL.Width(childComplexity), true + case "Mutation.authorizeUser": if e.complexity.Mutation.AuthorizeUser == nil { break @@ -411,17 +614,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.DeleteUser(childComplexity, args["id"].(int)), true - case "Mutation.favoritePhoto": - if e.complexity.Mutation.FavoritePhoto == nil { + case "Mutation.favoriteMedia": + if e.complexity.Mutation.FavoriteMedia == nil { break } - args, err := ec.field_Mutation_favoritePhoto_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_favoriteMedia_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.FavoritePhoto(childComplexity, args["photoId"].(int), args["favorite"].(bool)), true + return e.complexity.Mutation.FavoriteMedia(childComplexity, args["mediaId"].(int), args["favorite"].(bool)), true case "Mutation.initialSetupWizard": if e.complexity.Mutation.InitialSetupWizard == nil { @@ -490,17 +693,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.ShareAlbum(childComplexity, args["albumId"].(int), args["expire"].(*time.Time), args["password"].(*string)), true - case "Mutation.sharePhoto": - if e.complexity.Mutation.SharePhoto == nil { + case "Mutation.shareMedia": + if e.complexity.Mutation.ShareMedia == nil { break } - args, err := ec.field_Mutation_sharePhoto_args(context.TODO(), rawArgs) + args, err := ec.field_Mutation_shareMedia_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Mutation.SharePhoto(childComplexity, args["photoId"].(int), args["expire"].(*time.Time), args["password"].(*string)), true + return e.complexity.Mutation.ShareMedia(childComplexity, args["mediaId"].(int), args["expire"].(*time.Time), args["password"].(*string)), true case "Mutation.updateUser": if e.complexity.Mutation.UpdateUser == nil { @@ -570,209 +773,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Notification.Type(childComplexity), true - case "Photo.album": - if e.complexity.Photo.Album == nil { - break - } - - return e.complexity.Photo.Album(childComplexity), true - - case "Photo.downloads": - if e.complexity.Photo.Downloads == nil { - break - } - - return e.complexity.Photo.Downloads(childComplexity), true - - case "Photo.exif": - if e.complexity.Photo.Exif == nil { - break - } - - return e.complexity.Photo.Exif(childComplexity), true - - case "Photo.favorite": - if e.complexity.Photo.Favorite == nil { - break - } - - return e.complexity.Photo.Favorite(childComplexity), true - - case "Photo.highRes": - if e.complexity.Photo.HighRes == nil { - break - } - - return e.complexity.Photo.HighRes(childComplexity), true - - case "Photo.id": - if e.complexity.Photo.ID == nil { - break - } - - return e.complexity.Photo.ID(childComplexity), true - - case "Photo.path": - if e.complexity.Photo.Path == nil { - break - } - - return e.complexity.Photo.Path(childComplexity), true - - case "Photo.shares": - if e.complexity.Photo.Shares == nil { - break - } - - return e.complexity.Photo.Shares(childComplexity), true - - case "Photo.thumbnail": - if e.complexity.Photo.Thumbnail == nil { - break - } - - return e.complexity.Photo.Thumbnail(childComplexity), true - - case "Photo.title": - if e.complexity.Photo.Title == nil { - break - } - - return e.complexity.Photo.Title(childComplexity), true - - case "PhotoDownload.height": - if e.complexity.PhotoDownload.Height == nil { - break - } - - return e.complexity.PhotoDownload.Height(childComplexity), true - - case "PhotoDownload.title": - if e.complexity.PhotoDownload.Title == nil { - break - } - - return e.complexity.PhotoDownload.Title(childComplexity), true - - case "PhotoDownload.url": - if e.complexity.PhotoDownload.URL == nil { - break - } - - return e.complexity.PhotoDownload.URL(childComplexity), true - - case "PhotoDownload.width": - if e.complexity.PhotoDownload.Width == nil { - break - } - - return e.complexity.PhotoDownload.Width(childComplexity), true - - case "PhotoEXIF.aperture": - if e.complexity.PhotoExif.Aperture == nil { - break - } - - return e.complexity.PhotoExif.Aperture(childComplexity), true - - case "PhotoEXIF.camera": - if e.complexity.PhotoExif.Camera == nil { - break - } - - return e.complexity.PhotoExif.Camera(childComplexity), true - - case "PhotoEXIF.dateShot": - if e.complexity.PhotoExif.DateShot == nil { - break - } - - return e.complexity.PhotoExif.DateShot(childComplexity), true - - case "PhotoEXIF.exposure": - if e.complexity.PhotoExif.Exposure == nil { - break - } - - return e.complexity.PhotoExif.Exposure(childComplexity), true - - case "PhotoEXIF.exposureProgram": - if e.complexity.PhotoExif.ExposureProgram == nil { - break - } - - return e.complexity.PhotoExif.ExposureProgram(childComplexity), true - - case "PhotoEXIF.flash": - if e.complexity.PhotoExif.Flash == nil { - break - } - - return e.complexity.PhotoExif.Flash(childComplexity), true - - case "PhotoEXIF.focalLength": - if e.complexity.PhotoExif.FocalLength == nil { - break - } - - return e.complexity.PhotoExif.FocalLength(childComplexity), true - - case "PhotoEXIF.id": - if e.complexity.PhotoExif.ID == nil { - break - } - - return e.complexity.PhotoExif.ID(childComplexity), true - - case "PhotoEXIF.iso": - if e.complexity.PhotoExif.Iso == nil { - break - } - - return e.complexity.PhotoExif.Iso(childComplexity), true - - case "PhotoEXIF.lens": - if e.complexity.PhotoExif.Lens == nil { - break - } - - return e.complexity.PhotoExif.Lens(childComplexity), true - - case "PhotoEXIF.maker": - if e.complexity.PhotoExif.Maker == nil { - break - } - - return e.complexity.PhotoExif.Maker(childComplexity), true - - case "PhotoEXIF.photo": - if e.complexity.PhotoExif.Photo == nil { - break - } - - return e.complexity.PhotoExif.Photo(childComplexity), true - - case "PhotoURL.height": - if e.complexity.PhotoURL.Height == nil { - break - } - - return e.complexity.PhotoURL.Height(childComplexity), true - - case "PhotoURL.url": - if e.complexity.PhotoURL.URL == nil { - break - } - - return e.complexity.PhotoURL.URL(childComplexity), true - - case "PhotoURL.width": - if e.complexity.PhotoURL.Width == nil { - break - } - - return e.complexity.PhotoURL.Width(childComplexity), true - case "Query.album": if e.complexity.Query.Album == nil { break @@ -785,6 +785,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.Album(childComplexity, args["id"].(int)), true + case "Query.media": + if e.complexity.Query.Media == nil { + break + } + + args, err := ec.field_Query_media_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.Media(childComplexity, args["id"].(int)), true + case "Query.myAlbums": if e.complexity.Query.MyAlbums == nil { break @@ -797,17 +809,17 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.MyAlbums(childComplexity, args["filter"].(*models.Filter), args["onlyRoot"].(*bool), args["showEmpty"].(*bool)), true - case "Query.myPhotos": - if e.complexity.Query.MyPhotos == nil { + case "Query.myMedia": + if e.complexity.Query.MyMedia == nil { break } - args, err := ec.field_Query_myPhotos_args(context.TODO(), rawArgs) + args, err := ec.field_Query_myMedia_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Query.MyPhotos(childComplexity, args["filter"].(*models.Filter)), true + return e.complexity.Query.MyMedia(childComplexity, args["filter"].(*models.Filter)), true case "Query.myUser": if e.complexity.Query.MyUser == nil { @@ -816,18 +828,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.MyUser(childComplexity), true - case "Query.photo": - if e.complexity.Query.Photo == nil { - break - } - - args, err := ec.field_Query_photo_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } - - return e.complexity.Query.Photo(childComplexity, args["id"].(int)), true - case "Query.search": if e.complexity.Query.Search == nil { break @@ -838,7 +838,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.Search(childComplexity, args["query"].(string), args["limitPhotos"].(*int), args["limitAlbums"].(*int)), true + return e.complexity.Query.Search(childComplexity, args["query"].(string), args["limitMedia"].(*int), args["limitAlbums"].(*int)), true case "Query.shareToken": if e.complexity.Query.ShareToken == nil { @@ -918,12 +918,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.SearchResult.Albums(childComplexity), true - case "SearchResult.photos": - if e.complexity.SearchResult.Photos == nil { + case "SearchResult.media": + if e.complexity.SearchResult.Media == nil { break } - return e.complexity.SearchResult.Photos(childComplexity), true + return e.complexity.SearchResult.Media(childComplexity), true case "SearchResult.query": if e.complexity.SearchResult.Query == nil { @@ -960,6 +960,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ShareToken.ID(childComplexity), true + case "ShareToken.media": + if e.complexity.ShareToken.Media == nil { + break + } + + return e.complexity.ShareToken.Media(childComplexity), true + case "ShareToken.owner": if e.complexity.ShareToken.Owner == nil { break @@ -967,13 +974,6 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ShareToken.Owner(childComplexity), true - case "ShareToken.photo": - if e.complexity.ShareToken.Photo == nil { - break - } - - return e.complexity.ShareToken.Photo(childComplexity), true - case "ShareToken.token": if e.complexity.ShareToken.Token == nil { break @@ -1133,21 +1133,21 @@ type Query { filter: Filter "Return only albums from the root directory of the user" onlyRoot: Boolean - "Return also albums with no photos directly in them" + "Return also albums with no media directly in them" showEmpty: Boolean ): [Album!]! "Get album by id, user must own the album or be admin" album(id: Int!): Album! - "List of photos owned by the logged in user" - myPhotos(filter: Filter): [Photo!]! - "Get photo by id, user must own the photo or be admin" - photo(id: Int!): Photo! + "List of media owned by the logged in user" + myMedia(filter: Filter): [Media!]! + "Get media by id, user must own the media or be admin" + media(id: Int!): Media! shareToken(token: String!, password: String): ShareToken! shareTokenValidatePassword(token: String!, password: String): Boolean! - search(query: String!, limitPhotos: Int, limitAlbums: Int): SearchResult! + search(query: String!, limitMedia: Int, limitAlbums: Int): SearchResult! } type Mutation { @@ -1167,22 +1167,22 @@ type Mutation { rootPath: String! ): AuthorizeResult - "Scan all users for new photos" + "Scan all users for new media" scanAll: ScannerResult! @isAdmin - "Scan a single user for new photos" + "Scan a single user for new media" scanUser(userId: Int!): ScannerResult! "Generate share token for album" shareAlbum(albumId: Int!, expire: Time, password: String): ShareToken - "Generate share token for photo" - sharePhoto(photoId: Int!, expire: Time, password: String): ShareToken + "Generate share token for media" + shareMedia(mediaId: Int!, expire: Time, password: String): ShareToken "Delete a share token by it's token value" deleteShareToken(token: String!): ShareToken "Set a password for a token, if null is passed for the password argument, the password will be cleared" protectShareToken(token: String!, password: String): ShareToken - "Mark or unmark a photo as being a favorite" - favoritePhoto(photoId: Int!, favorite: Boolean!): Photo + "Mark or unmark a media as being a favorite" + favoriteMedia(mediaId: Int!, favorite: Boolean!): Media updateUser( id: Int! @@ -1236,7 +1236,7 @@ type ScannerResult { message: String } -"A token used to publicly access an album or photo" +"A token used to publicly access an album or media" type ShareToken { id: Int! token: String! @@ -1249,8 +1249,8 @@ type ShareToken { "The album this token shares" album: Album - "The photo this token shares" - photo: Photo + "The media this token shares" + media: Media } "General public information about the site" @@ -1271,8 +1271,8 @@ type User { type Album { id: Int! title: String! - "The photos inside this album" - photos(filter: Filter): [Photo!]! + "The media inside this album" + media(filter: Filter): [Media!]! "The albums contained in this album" subAlbums(filter: Filter): [Album!]! "The album witch contains this album" @@ -1282,13 +1282,13 @@ type Album { "The path on the filesystem of the server, where this album is located" filePath: String! "An image in this album used for previewing this album" - thumbnail: Photo + thumbnail: Media path: [Album!]! shares: [ShareToken] } -type PhotoURL { +type MediaURL { "URL for previewing the image" url: String! "Width of the image in pixels" @@ -1297,35 +1297,35 @@ type PhotoURL { height: Int! } -type PhotoDownload { +type MediaDownload { title: String! width: Int! height: Int! url: String! } -type Photo { +type Media { id: Int! title: String! - "Local filepath for the photo" + "Local filepath for the media" path: String! - "URL to display the photo in a smaller resolution" - thumbnail: PhotoURL! - "URL to display the photo in full resolution" - highRes: PhotoURL! - "The album that holds the photo" + "URL to display the media in a smaller resolution" + thumbnail: MediaURL! + "URL to display the photo in full resolution, will be null for videos" + highRes: MediaURL + "The album that holds the media" album: Album! - exif: PhotoEXIF + exif: MediaEXIF favorite: Boolean! shares: [ShareToken!]! - downloads: [PhotoDownload!]! + downloads: [MediaDownload!]! } "EXIF metadata from the camera" -type PhotoEXIF { +type MediaEXIF { id: Int! - photo: Photo + media: Media! "The model name of the camera" camera: String "The maker of the camera" @@ -1350,7 +1350,7 @@ type PhotoEXIF { type SearchResult { query: String! albums: [Album!]! - photos: [Photo!]! + media: [Media!]! } `, BuiltIn: false}, } @@ -1360,7 +1360,7 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // region ***************************** args.gotpl ***************************** -func (ec *executionContext) field_Album_photos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Album_media_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *models.Filter @@ -1476,17 +1476,17 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_favoritePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_favoriteMedia_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int - if tmp, ok := rawArgs["photoId"]; ok { + if tmp, ok := rawArgs["mediaId"]; ok { arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } } - args["photoId"] = arg0 + args["mediaId"] = arg0 var arg1 bool if tmp, ok := rawArgs["favorite"]; ok { arg1, err = ec.unmarshalNBoolean2bool(ctx, tmp) @@ -1624,17 +1624,17 @@ func (ec *executionContext) field_Mutation_shareAlbum_args(ctx context.Context, return args, nil } -func (ec *executionContext) field_Mutation_sharePhoto_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Mutation_shareMedia_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 int - if tmp, ok := rawArgs["photoId"]; ok { + if tmp, ok := rawArgs["mediaId"]; ok { arg0, err = ec.unmarshalNInt2int(ctx, tmp) if err != nil { return nil, err } } - args["photoId"] = arg0 + args["mediaId"] = arg0 var arg1 *time.Time if tmp, ok := rawArgs["expire"]; ok { arg1, err = ec.unmarshalOTime2ᚖtimeᚐTime(ctx, tmp) @@ -1728,6 +1728,20 @@ func (ec *executionContext) field_Query_album_args(ctx context.Context, rawArgs return args, nil } +func (ec *executionContext) field_Query_media_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 int + if tmp, ok := rawArgs["id"]; ok { + arg0, err = ec.unmarshalNInt2int(ctx, tmp) + if err != nil { + return nil, err + } + } + args["id"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_myAlbums_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1758,7 +1772,7 @@ func (ec *executionContext) field_Query_myAlbums_args(ctx context.Context, rawAr return args, nil } -func (ec *executionContext) field_Query_myPhotos_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_myMedia_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 *models.Filter @@ -1772,20 +1786,6 @@ func (ec *executionContext) field_Query_myPhotos_args(ctx context.Context, rawAr return args, nil } -func (ec *executionContext) field_Query_photo_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 int - if tmp, ok := rawArgs["id"]; ok { - arg0, err = ec.unmarshalNInt2int(ctx, tmp) - if err != nil { - return nil, err - } - } - args["id"] = arg0 - return args, nil -} - func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1798,13 +1798,13 @@ func (ec *executionContext) field_Query_search_args(ctx context.Context, rawArgs } args["query"] = arg0 var arg1 *int - if tmp, ok := rawArgs["limitPhotos"]; ok { + if tmp, ok := rawArgs["limitMedia"]; ok { arg1, err = ec.unmarshalOInt2ᚖint(ctx, tmp) if err != nil { return nil, err } } - args["limitPhotos"] = arg1 + args["limitMedia"] = arg1 var arg2 *int if tmp, ok := rawArgs["limitAlbums"]; ok { arg2, err = ec.unmarshalOInt2ᚖint(ctx, tmp) @@ -1978,7 +1978,7 @@ func (ec *executionContext) _Album_title(ctx context.Context, field graphql.Coll return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) _Album_photos(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) { +func (ec *executionContext) _Album_media(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -1994,7 +1994,7 @@ func (ec *executionContext) _Album_photos(ctx context.Context, field graphql.Col ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Album_photos_args(ctx, rawArgs) + args, err := ec.field_Album_media_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2002,7 +2002,7 @@ func (ec *executionContext) _Album_photos(ctx context.Context, field graphql.Col fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Album().Photos(rctx, obj, args["filter"].(*models.Filter)) + return ec.resolvers.Album().Media(rctx, obj, args["filter"].(*models.Filter)) }) if err != nil { ec.Error(ctx, err) @@ -2014,9 +2014,9 @@ func (ec *executionContext) _Album_photos(ctx context.Context, field graphql.Col } return graphql.Null } - res := resTmp.([]*models.Photo) + res := resTmp.([]*models.Media) fc.Result = res - return ec.marshalNPhoto2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoᚄ(ctx, field.Selections, res) + return ec.marshalNMedia2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaᚄ(ctx, field.Selections, res) } func (ec *executionContext) _Album_subAlbums(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) { @@ -2185,9 +2185,9 @@ func (ec *executionContext) _Album_thumbnail(ctx context.Context, field graphql. if resTmp == nil { return graphql.Null } - res := resTmp.(*models.Photo) + res := resTmp.(*models.Media) fc.Result = res - return ec.marshalOPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, field.Selections, res) + return ec.marshalOMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res) } func (ec *executionContext) _Album_path(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) { @@ -2354,6 +2354,956 @@ func (ec *executionContext) _AuthorizeResult_token(ctx context.Context, field gr return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } +func (ec *executionContext) _Media_id(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_title(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_path(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Path, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_thumbnail(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().Thumbnail(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*models.MediaURL) + fc.Result = res + return ec.marshalNMediaURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_highRes(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().HighRes(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.MediaURL) + fc.Result = res + return ec.marshalOMediaURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_album(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().Album(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*models.Album) + fc.Result = res + return ec.marshalNAlbum2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐAlbum(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_exif(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().Exif(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*models.MediaEXIF) + fc.Result = res + return ec.marshalOMediaEXIF2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaEXIF(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_favorite(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Favorite, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_shares(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().Shares(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*models.ShareToken) + fc.Result = res + return ec.marshalNShareToken2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareTokenᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _Media_downloads(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "Media", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Media().Downloads(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*models.MediaDownload) + fc.Result = res + return ec.marshalNMediaDownload2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaDownloadᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaDownload_title(ctx context.Context, field graphql.CollectedField, obj *models.MediaDownload) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaDownload", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Title, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaDownload_width(ctx context.Context, field graphql.CollectedField, obj *models.MediaDownload) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaDownload", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Width, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaDownload_height(ctx context.Context, field graphql.CollectedField, obj *models.MediaDownload) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaDownload", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaDownload_url(ctx context.Context, field graphql.CollectedField, obj *models.MediaDownload) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaDownload", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.URL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_id(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ID(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_media(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Media(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*models.Media) + fc.Result = res + return ec.marshalNMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_camera(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Camera, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_maker(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Maker, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_lens(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Lens, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_dateShot(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DateShot, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*time.Time) + fc.Result = res + return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_exposure(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Exposure, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_aperture(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Aperture, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*float64) + fc.Result = res + return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_iso(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Iso, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int) + fc.Result = res + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_focalLength(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.FocalLength, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*float64) + fc.Result = res + return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_flash(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Flash, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaEXIF_exposureProgram(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaEXIF", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ExposureProgram, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*int) + fc.Result = res + return ec.marshalOInt2ᚖint(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaURL_url(ctx context.Context, field graphql.CollectedField, obj *models.MediaURL) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaURL", + Field: field, + Args: nil, + IsMethod: true, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.URL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaURL_width(ctx context.Context, field graphql.CollectedField, obj *models.MediaURL) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaURL", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Width, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) _MediaURL_height(ctx context.Context, field graphql.CollectedField, obj *models.MediaURL) (ret graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + fc := &graphql.FieldContext{ + Object: "MediaURL", + Field: field, + Args: nil, + IsMethod: false, + } + + ctx = graphql.WithFieldContext(ctx, fc) + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Height, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + func (ec *executionContext) _Mutation_authorizeUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -2607,7 +3557,7 @@ func (ec *executionContext) _Mutation_shareAlbum(ctx context.Context, field grap return ec.marshalOShareToken2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareToken(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_sharePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_shareMedia(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2623,7 +3573,7 @@ func (ec *executionContext) _Mutation_sharePhoto(ctx context.Context, field grap ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_sharePhoto_args(ctx, rawArgs) + args, err := ec.field_Mutation_shareMedia_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2631,7 +3581,7 @@ func (ec *executionContext) _Mutation_sharePhoto(ctx context.Context, field grap fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().SharePhoto(rctx, args["photoId"].(int), args["expire"].(*time.Time), args["password"].(*string)) + return ec.resolvers.Mutation().ShareMedia(rctx, args["mediaId"].(int), args["expire"].(*time.Time), args["password"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -2721,7 +3671,7 @@ func (ec *executionContext) _Mutation_protectShareToken(ctx context.Context, fie return ec.marshalOShareToken2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareToken(ctx, field.Selections, res) } -func (ec *executionContext) _Mutation_favoritePhoto(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Mutation_favoriteMedia(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -2737,7 +3687,7 @@ func (ec *executionContext) _Mutation_favoritePhoto(ctx context.Context, field g ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Mutation_favoritePhoto_args(ctx, rawArgs) + args, err := ec.field_Mutation_favoriteMedia_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -2745,7 +3695,7 @@ func (ec *executionContext) _Mutation_favoritePhoto(ctx context.Context, field g fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().FavoritePhoto(rctx, args["photoId"].(int), args["favorite"].(bool)) + return ec.resolvers.Mutation().FavoriteMedia(rctx, args["mediaId"].(int), args["favorite"].(bool)) }) if err != nil { ec.Error(ctx, err) @@ -2754,9 +3704,9 @@ func (ec *executionContext) _Mutation_favoritePhoto(ctx context.Context, field g if resTmp == nil { return graphql.Null } - res := resTmp.(*models.Photo) + res := resTmp.(*models.Media) fc.Result = res - return ec.marshalOPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, field.Selections, res) + return ec.marshalOMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res) } func (ec *executionContext) _Mutation_updateUser(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -3199,956 +4149,6 @@ func (ec *executionContext) _Notification_timeout(ctx context.Context, field gra return ec.marshalOInt2ᚖint(ctx, field.Selections, res) } -func (ec *executionContext) _Photo_id(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_title(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Title, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_path(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Path, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_thumbnail(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().Thumbnail(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*models.PhotoURL) - fc.Result = res - return ec.marshalNPhotoURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoURL(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_highRes(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().HighRes(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*models.PhotoURL) - fc.Result = res - return ec.marshalNPhotoURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoURL(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_album(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().Album(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(*models.Album) - fc.Result = res - return ec.marshalNAlbum2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐAlbum(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_exif(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().Exif(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*models.PhotoEXIF) - fc.Result = res - return ec.marshalOPhotoEXIF2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoEXIF(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_favorite(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Favorite, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(bool) - fc.Result = res - return ec.marshalNBoolean2bool(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_shares(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().Shares(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*models.ShareToken) - fc.Result = res - return ec.marshalNShareToken2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareTokenᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _Photo_downloads(ctx context.Context, field graphql.CollectedField, obj *models.Photo) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "Photo", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Photo().Downloads(rctx, obj) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.([]*models.PhotoDownload) - fc.Result = res - return ec.marshalNPhotoDownload2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoDownloadᚄ(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoDownload_title(ctx context.Context, field graphql.CollectedField, obj *models.PhotoDownload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoDownload", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Title, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoDownload_width(ctx context.Context, field graphql.CollectedField, obj *models.PhotoDownload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoDownload", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Width, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoDownload_height(ctx context.Context, field graphql.CollectedField, obj *models.PhotoDownload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoDownload", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Height, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoDownload_url(ctx context.Context, field graphql.CollectedField, obj *models.PhotoDownload) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoDownload", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_id(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ID(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_photo(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Photo(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*models.Photo) - fc.Result = res - return ec.marshalOPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_camera(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Camera, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_maker(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Maker, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_lens(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Lens, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_dateShot(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.DateShot, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*time.Time) - fc.Result = res - return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_exposure(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Exposure, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_aperture(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Aperture, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*float64) - fc.Result = res - return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_iso(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Iso, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*int) - fc.Result = res - return ec.marshalOInt2ᚖint(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_focalLength(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.FocalLength, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*float64) - fc.Result = res - return ec.marshalOFloat2ᚖfloat64(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_flash(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Flash, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*string) - fc.Result = res - return ec.marshalOString2ᚖstring(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoEXIF_exposureProgram(ctx context.Context, field graphql.CollectedField, obj *models.PhotoEXIF) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoEXIF", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.ExposureProgram, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*int) - fc.Result = res - return ec.marshalOInt2ᚖint(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoURL_url(ctx context.Context, field graphql.CollectedField, obj *models.PhotoURL) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoURL", - Field: field, - Args: nil, - IsMethod: true, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.URL(), nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoURL_width(ctx context.Context, field graphql.CollectedField, obj *models.PhotoURL) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoURL", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Width, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - -func (ec *executionContext) _PhotoURL_height(ctx context.Context, field graphql.CollectedField, obj *models.PhotoURL) (ret graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - fc := &graphql.FieldContext{ - Object: "PhotoURL", - Field: field, - Args: nil, - IsMethod: false, - } - - ctx = graphql.WithFieldContext(ctx, fc) - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Height, nil - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(int) - fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) -} - func (ec *executionContext) _Query_siteInfo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { @@ -4360,7 +4360,7 @@ func (ec *executionContext) _Query_album(ctx context.Context, field graphql.Coll return ec.marshalNAlbum2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐAlbum(ctx, field.Selections, res) } -func (ec *executionContext) _Query_myPhotos(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_myMedia(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4376,7 +4376,7 @@ func (ec *executionContext) _Query_myPhotos(ctx context.Context, field graphql.C ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_myPhotos_args(ctx, rawArgs) + args, err := ec.field_Query_myMedia_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -4384,7 +4384,7 @@ func (ec *executionContext) _Query_myPhotos(ctx context.Context, field graphql.C fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().MyPhotos(rctx, args["filter"].(*models.Filter)) + return ec.resolvers.Query().MyMedia(rctx, args["filter"].(*models.Filter)) }) if err != nil { ec.Error(ctx, err) @@ -4396,12 +4396,12 @@ func (ec *executionContext) _Query_myPhotos(ctx context.Context, field graphql.C } return graphql.Null } - res := resTmp.([]*models.Photo) + res := resTmp.([]*models.Media) fc.Result = res - return ec.marshalNPhoto2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoᚄ(ctx, field.Selections, res) + return ec.marshalNMedia2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaᚄ(ctx, field.Selections, res) } -func (ec *executionContext) _Query_photo(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Query_media(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4417,7 +4417,7 @@ func (ec *executionContext) _Query_photo(ctx context.Context, field graphql.Coll ctx = graphql.WithFieldContext(ctx, fc) rawArgs := field.ArgumentMap(ec.Variables) - args, err := ec.field_Query_photo_args(ctx, rawArgs) + args, err := ec.field_Query_media_args(ctx, rawArgs) if err != nil { ec.Error(ctx, err) return graphql.Null @@ -4425,7 +4425,7 @@ func (ec *executionContext) _Query_photo(ctx context.Context, field graphql.Coll fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Photo(rctx, args["id"].(int)) + return ec.resolvers.Query().Media(rctx, args["id"].(int)) }) if err != nil { ec.Error(ctx, err) @@ -4437,9 +4437,9 @@ func (ec *executionContext) _Query_photo(ctx context.Context, field graphql.Coll } return graphql.Null } - res := resTmp.(*models.Photo) + res := resTmp.(*models.Media) fc.Result = res - return ec.marshalNPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, field.Selections, res) + return ec.marshalNMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res) } func (ec *executionContext) _Query_shareToken(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { @@ -4548,7 +4548,7 @@ func (ec *executionContext) _Query_search(ctx context.Context, field graphql.Col fc.Args = args resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().Search(rctx, args["query"].(string), args["limitPhotos"].(*int), args["limitAlbums"].(*int)) + return ec.resolvers.Query().Search(rctx, args["query"].(string), args["limitMedia"].(*int), args["limitAlbums"].(*int)) }) if err != nil { ec.Error(ctx, err) @@ -4832,7 +4832,7 @@ func (ec *executionContext) _SearchResult_albums(ctx context.Context, field grap return ec.marshalNAlbum2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐAlbumᚄ(ctx, field.Selections, res) } -func (ec *executionContext) _SearchResult_photos(ctx context.Context, field graphql.CollectedField, obj *models.SearchResult) (ret graphql.Marshaler) { +func (ec *executionContext) _SearchResult_media(ctx context.Context, field graphql.CollectedField, obj *models.SearchResult) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -4849,7 +4849,7 @@ func (ec *executionContext) _SearchResult_photos(ctx context.Context, field grap ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Photos, nil + return obj.Media, nil }) if err != nil { ec.Error(ctx, err) @@ -4861,9 +4861,9 @@ func (ec *executionContext) _SearchResult_photos(ctx context.Context, field grap } return graphql.Null } - res := resTmp.([]*models.Photo) + res := resTmp.([]*models.Media) fc.Result = res - return ec.marshalNPhoto2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoᚄ(ctx, field.Selections, res) + return ec.marshalNMedia2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaᚄ(ctx, field.Selections, res) } func (ec *executionContext) _ShareToken_id(ctx context.Context, field graphql.CollectedField, obj *models.ShareToken) (ret graphql.Marshaler) { @@ -5064,7 +5064,7 @@ func (ec *executionContext) _ShareToken_album(ctx context.Context, field graphql return ec.marshalOAlbum2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐAlbum(ctx, field.Selections, res) } -func (ec *executionContext) _ShareToken_photo(ctx context.Context, field graphql.CollectedField, obj *models.ShareToken) (ret graphql.Marshaler) { +func (ec *executionContext) _ShareToken_media(ctx context.Context, field graphql.CollectedField, obj *models.ShareToken) (ret graphql.Marshaler) { defer func() { if r := recover(); r != nil { ec.Error(ctx, ec.Recover(ctx, r)) @@ -5081,7 +5081,7 @@ func (ec *executionContext) _ShareToken_photo(ctx context.Context, field graphql ctx = graphql.WithFieldContext(ctx, fc) resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.ShareToken().Photo(rctx, obj) + return ec.resolvers.ShareToken().Media(rctx, obj) }) if err != nil { ec.Error(ctx, err) @@ -5090,9 +5090,9 @@ func (ec *executionContext) _ShareToken_photo(ctx context.Context, field graphql if resTmp == nil { return graphql.Null } - res := resTmp.(*models.Photo) + res := resTmp.(*models.Media) fc.Result = res - return ec.marshalOPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, field.Selections, res) + return ec.marshalOMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res) } func (ec *executionContext) _SiteInfo_initialSetup(ctx context.Context, field graphql.CollectedField, obj *models.SiteInfo) (ret graphql.Marshaler) { @@ -6449,7 +6449,7 @@ func (ec *executionContext) _Album(ctx context.Context, sel ast.SelectionSet, ob if out.Values[i] == graphql.Null { atomic.AddUint32(&invalids, 1) } - case "photos": + case "media": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { @@ -6457,7 +6457,7 @@ func (ec *executionContext) _Album(ctx context.Context, sel ast.SelectionSet, ob ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Album_photos(ctx, field, obj) + res = ec._Album_media(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -6588,6 +6588,257 @@ func (ec *executionContext) _AuthorizeResult(ctx context.Context, sel ast.Select return out } +var mediaImplementors = []string{"Media"} + +func (ec *executionContext) _Media(ctx context.Context, sel ast.SelectionSet, obj *models.Media) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mediaImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Media") + case "id": + out.Values[i] = ec._Media_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + case "title": + out.Values[i] = ec._Media_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + case "path": + out.Values[i] = ec._Media_path(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + case "thumbnail": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_thumbnail(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "highRes": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_highRes(ctx, field, obj) + return res + }) + case "album": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_album(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "exif": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_exif(ctx, field, obj) + return res + }) + case "favorite": + out.Values[i] = ec._Media_favorite(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + case "shares": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_shares(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + case "downloads": + field := field + out.Concurrently(i, func() (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Media_downloads(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var mediaDownloadImplementors = []string{"MediaDownload"} + +func (ec *executionContext) _MediaDownload(ctx context.Context, sel ast.SelectionSet, obj *models.MediaDownload) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mediaDownloadImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MediaDownload") + case "title": + out.Values[i] = ec._MediaDownload_title(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "width": + out.Values[i] = ec._MediaDownload_width(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "height": + out.Values[i] = ec._MediaDownload_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "url": + out.Values[i] = ec._MediaDownload_url(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var mediaEXIFImplementors = []string{"MediaEXIF"} + +func (ec *executionContext) _MediaEXIF(ctx context.Context, sel ast.SelectionSet, obj *models.MediaEXIF) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mediaEXIFImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MediaEXIF") + case "id": + out.Values[i] = ec._MediaEXIF_id(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "media": + out.Values[i] = ec._MediaEXIF_media(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "camera": + out.Values[i] = ec._MediaEXIF_camera(ctx, field, obj) + case "maker": + out.Values[i] = ec._MediaEXIF_maker(ctx, field, obj) + case "lens": + out.Values[i] = ec._MediaEXIF_lens(ctx, field, obj) + case "dateShot": + out.Values[i] = ec._MediaEXIF_dateShot(ctx, field, obj) + case "exposure": + out.Values[i] = ec._MediaEXIF_exposure(ctx, field, obj) + case "aperture": + out.Values[i] = ec._MediaEXIF_aperture(ctx, field, obj) + case "iso": + out.Values[i] = ec._MediaEXIF_iso(ctx, field, obj) + case "focalLength": + out.Values[i] = ec._MediaEXIF_focalLength(ctx, field, obj) + case "flash": + out.Values[i] = ec._MediaEXIF_flash(ctx, field, obj) + case "exposureProgram": + out.Values[i] = ec._MediaEXIF_exposureProgram(ctx, field, obj) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var mediaURLImplementors = []string{"MediaURL"} + +func (ec *executionContext) _MediaURL(ctx context.Context, sel ast.SelectionSet, obj *models.MediaURL) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, mediaURLImplementors) + + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("MediaURL") + case "url": + out.Values[i] = ec._MediaURL_url(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "width": + out.Values[i] = ec._MediaURL_width(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + case "height": + out.Values[i] = ec._MediaURL_height(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + var mutationImplementors = []string{"Mutation"} func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -6627,14 +6878,14 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) } case "shareAlbum": out.Values[i] = ec._Mutation_shareAlbum(ctx, field) - case "sharePhoto": - out.Values[i] = ec._Mutation_sharePhoto(ctx, field) + case "shareMedia": + out.Values[i] = ec._Mutation_shareMedia(ctx, field) case "deleteShareToken": out.Values[i] = ec._Mutation_deleteShareToken(ctx, field) case "protectShareToken": out.Values[i] = ec._Mutation_protectShareToken(ctx, field) - case "favoritePhoto": - out.Values[i] = ec._Mutation_favoritePhoto(ctx, field) + case "favoriteMedia": + out.Values[i] = ec._Mutation_favoriteMedia(ctx, field) case "updateUser": out.Values[i] = ec._Mutation_updateUser(ctx, field) case "createUser": @@ -6708,257 +6959,6 @@ func (ec *executionContext) _Notification(ctx context.Context, sel ast.Selection return out } -var photoImplementors = []string{"Photo"} - -func (ec *executionContext) _Photo(ctx context.Context, sel ast.SelectionSet, obj *models.Photo) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, photoImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Photo") - case "id": - out.Values[i] = ec._Photo_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "title": - out.Values[i] = ec._Photo_title(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "path": - out.Values[i] = ec._Photo_path(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "thumbnail": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_thumbnail(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "highRes": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_highRes(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "album": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_album(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "exif": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_exif(ctx, field, obj) - return res - }) - case "favorite": - out.Values[i] = ec._Photo_favorite(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - case "shares": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_shares(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - case "downloads": - field := field - out.Concurrently(i, func() (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Photo_downloads(ctx, field, obj) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var photoDownloadImplementors = []string{"PhotoDownload"} - -func (ec *executionContext) _PhotoDownload(ctx context.Context, sel ast.SelectionSet, obj *models.PhotoDownload) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, photoDownloadImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PhotoDownload") - case "title": - out.Values[i] = ec._PhotoDownload_title(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "width": - out.Values[i] = ec._PhotoDownload_width(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "height": - out.Values[i] = ec._PhotoDownload_height(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "url": - out.Values[i] = ec._PhotoDownload_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var photoEXIFImplementors = []string{"PhotoEXIF"} - -func (ec *executionContext) _PhotoEXIF(ctx context.Context, sel ast.SelectionSet, obj *models.PhotoEXIF) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, photoEXIFImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PhotoEXIF") - case "id": - out.Values[i] = ec._PhotoEXIF_id(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "photo": - out.Values[i] = ec._PhotoEXIF_photo(ctx, field, obj) - case "camera": - out.Values[i] = ec._PhotoEXIF_camera(ctx, field, obj) - case "maker": - out.Values[i] = ec._PhotoEXIF_maker(ctx, field, obj) - case "lens": - out.Values[i] = ec._PhotoEXIF_lens(ctx, field, obj) - case "dateShot": - out.Values[i] = ec._PhotoEXIF_dateShot(ctx, field, obj) - case "exposure": - out.Values[i] = ec._PhotoEXIF_exposure(ctx, field, obj) - case "aperture": - out.Values[i] = ec._PhotoEXIF_aperture(ctx, field, obj) - case "iso": - out.Values[i] = ec._PhotoEXIF_iso(ctx, field, obj) - case "focalLength": - out.Values[i] = ec._PhotoEXIF_focalLength(ctx, field, obj) - case "flash": - out.Values[i] = ec._PhotoEXIF_flash(ctx, field, obj) - case "exposureProgram": - out.Values[i] = ec._PhotoEXIF_exposureProgram(ctx, field, obj) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var photoURLImplementors = []string{"PhotoURL"} - -func (ec *executionContext) _PhotoURL(ctx context.Context, sel ast.SelectionSet, obj *models.PhotoURL) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, photoURLImplementors) - - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("PhotoURL") - case "url": - out.Values[i] = ec._PhotoURL_url(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "width": - out.Values[i] = ec._PhotoURL_width(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - case "height": - out.Values[i] = ec._PhotoURL_height(ctx, field, obj) - if out.Values[i] == graphql.Null { - invalids++ - } - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - var queryImplementors = []string{"Query"} func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { @@ -7044,7 +7044,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr } return res }) - case "myPhotos": + case "myMedia": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { @@ -7052,13 +7052,13 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_myPhotos(ctx, field) + res = ec._Query_myMedia(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } return res }) - case "photo": + case "media": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { @@ -7066,7 +7066,7 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Query_photo(ctx, field) + res = ec._Query_media(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -7186,8 +7186,8 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection if out.Values[i] == graphql.Null { invalids++ } - case "photos": - out.Values[i] = ec._SearchResult_photos(ctx, field, obj) + case "media": + out.Values[i] = ec._SearchResult_media(ctx, field, obj) if out.Values[i] == graphql.Null { invalids++ } @@ -7264,7 +7264,7 @@ func (ec *executionContext) _ShareToken(ctx context.Context, sel ast.SelectionSe res = ec._ShareToken_album(ctx, field, obj) return res }) - case "photo": + case "media": field := field out.Concurrently(i, func() (res graphql.Marshaler) { defer func() { @@ -7272,7 +7272,7 @@ func (ec *executionContext) _ShareToken(ctx context.Context, sel ast.SelectionSe ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._ShareToken_photo(ctx, field, obj) + res = ec._ShareToken_media(ctx, field, obj) return res }) default: @@ -7713,6 +7713,122 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) marshalNMedia2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx context.Context, sel ast.SelectionSet, v models.Media) graphql.Marshaler { + return ec._Media(ctx, sel, &v) +} + +func (ec *executionContext) marshalNMedia2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Media) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalNMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx context.Context, sel ast.SelectionSet, v *models.Media) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._Media(ctx, sel, v) +} + +func (ec *executionContext) marshalNMediaDownload2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaDownload(ctx context.Context, sel ast.SelectionSet, v models.MediaDownload) graphql.Marshaler { + return ec._MediaDownload(ctx, sel, &v) +} + +func (ec *executionContext) marshalNMediaDownload2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaDownloadᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.MediaDownload) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNMediaDownload2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaDownload(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + return ret +} + +func (ec *executionContext) marshalNMediaDownload2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaDownload(ctx context.Context, sel ast.SelectionSet, v *models.MediaDownload) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._MediaDownload(ctx, sel, v) +} + +func (ec *executionContext) marshalNMediaURL2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx context.Context, sel ast.SelectionSet, v models.MediaURL) graphql.Marshaler { + return ec._MediaURL(ctx, sel, &v) +} + +func (ec *executionContext) marshalNMediaURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx context.Context, sel ast.SelectionSet, v *models.MediaURL) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + return ec._MediaURL(ctx, sel, v) +} + func (ec *executionContext) marshalNNotification2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐNotification(ctx context.Context, sel ast.SelectionSet, v models.Notification) graphql.Marshaler { return ec._Notification(ctx, sel, &v) } @@ -7736,122 +7852,6 @@ func (ec *executionContext) marshalNNotificationType2githubᚗcomᚋviktorstrate return v } -func (ec *executionContext) marshalNPhoto2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx context.Context, sel ast.SelectionSet, v models.Photo) graphql.Marshaler { - return ec._Photo(ctx, sel, &v) -} - -func (ec *executionContext) marshalNPhoto2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.Photo) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - -func (ec *executionContext) marshalNPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *models.Photo) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._Photo(ctx, sel, v) -} - -func (ec *executionContext) marshalNPhotoDownload2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoDownload(ctx context.Context, sel ast.SelectionSet, v models.PhotoDownload) graphql.Marshaler { - return ec._PhotoDownload(ctx, sel, &v) -} - -func (ec *executionContext) marshalNPhotoDownload2ᚕᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoDownloadᚄ(ctx context.Context, sel ast.SelectionSet, v []*models.PhotoDownload) graphql.Marshaler { - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - ctx := graphql.WithFieldContext(ctx, fc) - f := func(i int) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = nil - } - }() - if !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalNPhotoDownload2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoDownload(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - return ret -} - -func (ec *executionContext) marshalNPhotoDownload2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoDownload(ctx context.Context, sel ast.SelectionSet, v *models.PhotoDownload) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._PhotoDownload(ctx, sel, v) -} - -func (ec *executionContext) marshalNPhotoURL2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoURL(ctx context.Context, sel ast.SelectionSet, v models.PhotoURL) graphql.Marshaler { - return ec._PhotoURL(ctx, sel, &v) -} - -func (ec *executionContext) marshalNPhotoURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoURL(ctx context.Context, sel ast.SelectionSet, v *models.PhotoURL) graphql.Marshaler { - if v == nil { - if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - return ec._PhotoURL(ctx, sel, v) -} - func (ec *executionContext) marshalNScannerResult2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐScannerResult(ctx context.Context, sel ast.SelectionSet, v models.ScannerResult) graphql.Marshaler { return ec._ScannerResult(ctx, sel, &v) } @@ -8339,6 +8339,39 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return ec.marshalOInt2int(ctx, sel, *v) } +func (ec *executionContext) marshalOMedia2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx context.Context, sel ast.SelectionSet, v models.Media) graphql.Marshaler { + return ec._Media(ctx, sel, &v) +} + +func (ec *executionContext) marshalOMedia2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx context.Context, sel ast.SelectionSet, v *models.Media) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Media(ctx, sel, v) +} + +func (ec *executionContext) marshalOMediaEXIF2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaEXIF(ctx context.Context, sel ast.SelectionSet, v models.MediaEXIF) graphql.Marshaler { + return ec._MediaEXIF(ctx, sel, &v) +} + +func (ec *executionContext) marshalOMediaEXIF2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaEXIF(ctx context.Context, sel ast.SelectionSet, v *models.MediaEXIF) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MediaEXIF(ctx, sel, v) +} + +func (ec *executionContext) marshalOMediaURL2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx context.Context, sel ast.SelectionSet, v models.MediaURL) graphql.Marshaler { + return ec._MediaURL(ctx, sel, &v) +} + +func (ec *executionContext) marshalOMediaURL2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMediaURL(ctx context.Context, sel ast.SelectionSet, v *models.MediaURL) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._MediaURL(ctx, sel, v) +} + func (ec *executionContext) unmarshalOOrderDirection2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐOrderDirection(ctx context.Context, v interface{}) (models.OrderDirection, error) { var res models.OrderDirection return res, res.UnmarshalGQL(v) @@ -8363,28 +8396,6 @@ func (ec *executionContext) marshalOOrderDirection2ᚖgithubᚗcomᚋviktorstrat return v } -func (ec *executionContext) marshalOPhoto2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx context.Context, sel ast.SelectionSet, v models.Photo) graphql.Marshaler { - return ec._Photo(ctx, sel, &v) -} - -func (ec *executionContext) marshalOPhoto2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhoto(ctx context.Context, sel ast.SelectionSet, v *models.Photo) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._Photo(ctx, sel, v) -} - -func (ec *executionContext) marshalOPhotoEXIF2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoEXIF(ctx context.Context, sel ast.SelectionSet, v models.PhotoEXIF) graphql.Marshaler { - return ec._PhotoEXIF(ctx, sel, &v) -} - -func (ec *executionContext) marshalOPhotoEXIF2ᚖgithubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐPhotoEXIF(ctx context.Context, sel ast.SelectionSet, v *models.PhotoEXIF) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._PhotoEXIF(ctx, sel, v) -} - func (ec *executionContext) marshalOShareToken2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐShareToken(ctx context.Context, sel ast.SelectionSet, v models.ShareToken) graphql.Marshaler { return ec._ShareToken(ctx, sel, &v) } diff --git a/api/graphql/models/generated.go b/api/graphql/models/generated.go index e4070c77..166605a6 100644 --- a/api/graphql/models/generated.go +++ b/api/graphql/models/generated.go @@ -21,6 +21,13 @@ type Filter struct { Offset *int `json:"offset"` } +type MediaDownload struct { + Title string `json:"title"` + Width int `json:"width"` + Height int `json:"height"` + URL string `json:"url"` +} + type Notification struct { Key string `json:"key"` Type NotificationType `json:"type"` @@ -33,13 +40,6 @@ type Notification struct { Timeout *int `json:"timeout"` } -type PhotoDownload struct { - Title string `json:"title"` - Width int `json:"width"` - Height int `json:"height"` - URL string `json:"url"` -} - type ScannerResult struct { Finished bool `json:"finished"` Success bool `json:"success"` @@ -50,7 +50,7 @@ type ScannerResult struct { type SearchResult struct { Query string `json:"query"` Albums []*Album `json:"albums"` - Photos []*Photo `json:"photos"` + Media []*Media `json:"media"` } // General public information about the site diff --git a/api/graphql/models/media.go b/api/graphql/models/media.go new file mode 100644 index 00000000..84af0023 --- /dev/null +++ b/api/graphql/models/media.go @@ -0,0 +1,101 @@ +package models + +import ( + "database/sql" + "path" + + "github.com/viktorstrate/photoview/api/utils" +) + +type Media struct { + MediaID int + Title string + Path string + PathHash string + AlbumId int + ExifId *int + Favorite bool +} + +func (p *Media) ID() int { + return p.MediaID +} + +type MediaPurpose string + +const ( + PhotoThumbnail MediaPurpose = "thumbnail" + PhotoHighRes MediaPurpose = "high-res" + MediaOriginal MediaPurpose = "original" + VideoWeb MediaPurpose = "video-web" +) + +type MediaURL struct { + UrlID int + MediaId int + MediaName string + Width int + Height int + Purpose MediaPurpose + ContentType string +} + +func NewMediaFromRow(row *sql.Row) (*Media, error) { + media := Media{} + + if err := row.Scan(&media.MediaID, &media.Title, &media.Path, &media.PathHash, &media.AlbumId, &media.ExifId, &media.Favorite); err != nil { + return nil, err + } + + return &media, nil +} + +func NewMediaFromRows(rows *sql.Rows) ([]*Media, error) { + medias := make([]*Media, 0) + + for rows.Next() { + var media Media + if err := rows.Scan(&media.MediaID, &media.Title, &media.Path, &media.PathHash, &media.AlbumId, &media.ExifId, &media.Favorite); err != nil { + return nil, err + } + medias = append(medias, &media) + } + + rows.Close() + + return medias, nil +} + +func (p *MediaURL) URL() string { + + imageUrl := utils.ApiEndpointUrl() + imageUrl.Path = path.Join(imageUrl.Path, "photo", p.MediaName) + + return imageUrl.String() +} + +func NewMediaURLFromRow(row *sql.Row) (*MediaURL, error) { + url := MediaURL{} + + if err := row.Scan(&url.UrlID, &url.MediaId, &url.MediaName, &url.Width, &url.Height, &url.Purpose, &url.ContentType); err != nil { + return nil, err + } + + return &url, nil +} + +func NewMediaURLFromRows(rows *sql.Rows) ([]*MediaURL, error) { + urls := make([]*MediaURL, 0) + + for rows.Next() { + var url MediaURL + if err := rows.Scan(&url.UrlID, &url.MediaId, &url.MediaName, &url.Width, &url.Height, &url.Purpose, &url.ContentType); err != nil { + return nil, err + } + urls = append(urls, &url) + } + + rows.Close() + + return urls, nil +} diff --git a/api/graphql/models/photo_exif.go b/api/graphql/models/media_exif.go similarity index 78% rename from api/graphql/models/photo_exif.go rename to api/graphql/models/media_exif.go index bd40ffd4..6b1fcf76 100644 --- a/api/graphql/models/photo_exif.go +++ b/api/graphql/models/media_exif.go @@ -5,7 +5,7 @@ import ( "time" ) -type PhotoEXIF struct { +type MediaEXIF struct { ExifID int Camera *string Maker *string @@ -20,16 +20,16 @@ type PhotoEXIF struct { ExposureProgram *int } -func (exif *PhotoEXIF) Photo() *Photo { +func (exif *MediaEXIF) Media() *Media { panic("not implemented") } -func (exif *PhotoEXIF) ID() int { +func (exif *MediaEXIF) ID() int { return exif.ExifID } -func NewPhotoExifFromRow(row *sql.Row) (*PhotoEXIF, error) { - exif := PhotoEXIF{} +func NewMediaExifFromRow(row *sql.Row) (*MediaEXIF, error) { + exif := MediaEXIF{} if err := row.Scan(&exif.ExifID, &exif.Camera, &exif.Maker, &exif.Lens, &exif.DateShot, &exif.Exposure, &exif.Aperture, &exif.Iso, &exif.FocalLength, &exif.Flash, &exif.Orientation, &exif.ExposureProgram); err != nil { return nil, err diff --git a/api/graphql/models/photo.go b/api/graphql/models/photo.go deleted file mode 100644 index 7ec01cbd..00000000 --- a/api/graphql/models/photo.go +++ /dev/null @@ -1,101 +0,0 @@ -package models - -import ( - "database/sql" - "path" - - "github.com/viktorstrate/photoview/api/utils" -) - -type Photo struct { - PhotoID int - Title string - Path string - PathHash string - AlbumId int - ExifId *int - Favorite bool -} - -func (p *Photo) ID() int { - return p.PhotoID -} - -type MediaPurpose string - -const ( - PhotoThumbnail MediaPurpose = "thumbnail" - PhotoHighRes MediaPurpose = "high-res" - MediaOriginal MediaPurpose = "original" - VideoWeb MediaPurpose = "video-web" -) - -type PhotoURL struct { - UrlID int - PhotoId int - PhotoName string - Width int - Height int - Purpose MediaPurpose - ContentType string -} - -func NewPhotoFromRow(row *sql.Row) (*Photo, error) { - photo := Photo{} - - if err := row.Scan(&photo.PhotoID, &photo.Title, &photo.Path, &photo.PathHash, &photo.AlbumId, &photo.ExifId, &photo.Favorite); err != nil { - return nil, err - } - - return &photo, nil -} - -func NewPhotosFromRows(rows *sql.Rows) ([]*Photo, error) { - photos := make([]*Photo, 0) - - for rows.Next() { - var photo Photo - if err := rows.Scan(&photo.PhotoID, &photo.Title, &photo.Path, &photo.PathHash, &photo.AlbumId, &photo.ExifId, &photo.Favorite); err != nil { - return nil, err - } - photos = append(photos, &photo) - } - - rows.Close() - - return photos, nil -} - -func (p *PhotoURL) URL() string { - - imageUrl := utils.ApiEndpointUrl() - imageUrl.Path = path.Join(imageUrl.Path, "photo", p.PhotoName) - - return imageUrl.String() -} - -func NewPhotoURLFromRow(row *sql.Row) (*PhotoURL, error) { - url := PhotoURL{} - - if err := row.Scan(&url.UrlID, &url.PhotoId, &url.PhotoName, &url.Width, &url.Height, &url.Purpose, &url.ContentType); err != nil { - return nil, err - } - - return &url, nil -} - -func NewPhotoURLFromRows(rows *sql.Rows) ([]*PhotoURL, error) { - urls := make([]*PhotoURL, 0) - - for rows.Next() { - var url PhotoURL - if err := rows.Scan(&url.UrlID, &url.PhotoId, &url.PhotoName, &url.Width, &url.Height, &url.Purpose, &url.ContentType); err != nil { - return nil, err - } - urls = append(urls, &url) - } - - rows.Close() - - return urls, nil -} diff --git a/api/graphql/models/share_token.go b/api/graphql/models/share_token.go index 59669b95..4ba0c202 100644 --- a/api/graphql/models/share_token.go +++ b/api/graphql/models/share_token.go @@ -12,7 +12,7 @@ type ShareToken struct { Expire *time.Time Password *string AlbumID *int - PhotoID *int + MediaID *int } func (share *ShareToken) Token() string { @@ -26,7 +26,7 @@ func (share *ShareToken) ID() int { func NewShareTokenFromRow(row *sql.Row) (*ShareToken, error) { token := ShareToken{} - if err := row.Scan(&token.TokenID, &token.Value, &token.OwnerID, &token.Expire, &token.Password, &token.AlbumID, &token.PhotoID); err != nil { + if err := row.Scan(&token.TokenID, &token.Value, &token.OwnerID, &token.Expire, &token.Password, &token.AlbumID, &token.MediaID); err != nil { return nil, err } @@ -38,7 +38,7 @@ func NewShareTokensFromRows(rows *sql.Rows) ([]*ShareToken, error) { for rows.Next() { var token ShareToken - if err := rows.Scan(&token.TokenID, &token.Value, &token.OwnerID, &token.Expire, &token.Password, &token.AlbumID, &token.PhotoID); err != nil { + if err := rows.Scan(&token.TokenID, &token.Value, &token.OwnerID, &token.Expire, &token.Password, &token.AlbumID, &token.MediaID); err != nil { return nil, err } tokens = append(tokens, &token) diff --git a/api/graphql/resolvers/album.go b/api/graphql/resolvers/album.go index 8b96866e..4c02222d 100644 --- a/api/graphql/resolvers/album.go +++ b/api/graphql/resolvers/album.go @@ -22,7 +22,7 @@ func (r *queryResolver) MyAlbums(ctx context.Context, filter *models.Filter, onl var rows *sql.Rows - filterEmpty := " AND EXISTS (SELECT * FROM photo WHERE album_id = album.album_id) " + filterEmpty := " AND EXISTS (SELECT * FROM media WHERE album_id = album.album_id) " if showEmpty != nil && *showEmpty == true { filterEmpty = "" } @@ -72,34 +72,34 @@ func (r *Resolver) Album() api.AlbumResolver { type albumResolver struct{ *Resolver } -func (r *albumResolver) Photos(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Photo, error) { +func (r *albumResolver) Media(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Media, error) { filterSQL, err := filter.FormatSQL() if err != nil { return nil, err } - photoRows, err := r.Database.Query(` - SELECT photo.* FROM album, photo - WHERE album.album_id = ? AND photo.album_id = album.album_id - AND photo.photo_id IN ( - SELECT photo_id FROM photo_url WHERE photo_url.photo_id = photo.photo_id + mediaRows, err := r.Database.Query(` + SELECT media.* FROM album, media + WHERE album.album_id = ? AND media.album_id = album.album_id + AND media.media_id IN ( + SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id ) `+filterSQL, obj.AlbumID) if err != nil { return nil, err } - defer photoRows.Close() + defer mediaRows.Close() - photos, err := models.NewPhotosFromRows(photoRows) + media, err := models.NewMediaFromRows(mediaRows) if err != nil { return nil, err } - return photos, nil + return media, nil } -func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*models.Photo, error) { +func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*models.Media, error) { row := r.Database.QueryRow(` WITH recursive sub_albums AS ( @@ -108,14 +108,14 @@ func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*mode SELECT child.* FROM album AS child JOIN sub_albums ON child.parent_album = sub_albums.album_id ) - SELECT * FROM photo WHERE photo.album_id IN ( + SELECT * FROM media WHERE media.album_id IN ( SELECT album_id FROM sub_albums - ) AND photo.photo_id IN ( - SELECT photo_id FROM photo_url WHERE photo_url.photo_id = photo.photo_id + ) AND media.media_id IN ( + SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id ) LIMIT 1 `, obj.AlbumID) - photo, err := models.NewPhotoFromRow(row) + media, err := models.NewMediaFromRow(row) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -124,7 +124,7 @@ func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*mode } } - return photo, nil + return media, nil } func (r *albumResolver) SubAlbums(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Album, error) { diff --git a/api/graphql/resolvers/photo.go b/api/graphql/resolvers/photo.go index 6af4188f..73636858 100644 --- a/api/graphql/resolvers/photo.go +++ b/api/graphql/resolvers/photo.go @@ -13,7 +13,7 @@ import ( "github.com/viktorstrate/photoview/api/scanner" ) -func (r *queryResolver) MyPhotos(ctx context.Context, filter *models.Filter) ([]*models.Photo, error) { +func (r *queryResolver) MyMedia(ctx context.Context, filter *models.Filter) ([]*models.Media, error) { user := auth.UserFromContext(ctx) if user == nil { return nil, errors.New("unauthorized") @@ -25,52 +25,52 @@ func (r *queryResolver) MyPhotos(ctx context.Context, filter *models.Filter) ([] } rows, err := r.Database.Query(` - SELECT photo.* FROM photo, album - WHERE photo.album_id = album.album_id AND album.owner_id = ? - AND photo.photo_id IN ( - SELECT photo_id FROM photo_url WHERE photo_url.photo_id = photo.photo_id + SELECT media.* FROM media, album + WHERE media.album_id = album.album_id AND album.owner_id = ? + AND media.media_id IN ( + SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id ) `+filterSQL, user.UserID) if err != nil { return nil, err } - return models.NewPhotosFromRows(rows) + return models.NewMediaFromRows(rows) } -func (r *queryResolver) Photo(ctx context.Context, id int) (*models.Photo, error) { +func (r *queryResolver) Media(ctx context.Context, id int) (*models.Media, error) { user := auth.UserFromContext(ctx) if user == nil { return nil, auth.ErrUnauthorized } row := r.Database.QueryRow(` - SELECT photo.* FROM photo - JOIN album ON photo.album_id = album.album_id - WHERE photo.photo_id = ? AND album.owner_id = ? - AND photo.photo_id IN ( - SELECT photo_id FROM photo_url WHERE photo_url.photo_id = photo.photo_id + SELECT media.* FROM media + JOIN album ON media.album_id = album.album_id + WHERE media.media_id = ? AND album.owner_id = ? + AND media.media_id IN ( + SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id ) `, id, user.UserID) - photo, err := models.NewPhotoFromRow(row) + media, err := models.NewMediaFromRow(row) if err != nil { return nil, err } - return photo, nil + return media, nil } -type photoResolver struct { +type mediaResolver struct { *Resolver } -func (r *Resolver) Photo() api.PhotoResolver { - return &photoResolver{r} +func (r *Resolver) Media() api.MediaResolver { + return &mediaResolver{r} } -func (r *photoResolver) Shares(ctx context.Context, obj *models.Photo) ([]*models.ShareToken, error) { - rows, err := r.Database.Query("SELECT * FROM share_token WHERE photo_id = ?", obj.PhotoID) +func (r *mediaResolver) Shares(ctx context.Context, obj *models.Media) ([]*models.ShareToken, error) { + rows, err := r.Database.Query("SELECT * FROM share_token WHERE media_id = ?", obj.MediaID) if err != nil { return nil, err } @@ -78,21 +78,21 @@ func (r *photoResolver) Shares(ctx context.Context, obj *models.Photo) ([]*model return models.NewShareTokensFromRows(rows) } -func (r *photoResolver) Downloads(ctx context.Context, obj *models.Photo) ([]*models.PhotoDownload, error) { +func (r *mediaResolver) Downloads(ctx context.Context, obj *models.Media) ([]*models.MediaDownload, error) { - rows, err := r.Database.Query("SELECT * FROM photo_url WHERE photo_id = ?", obj.PhotoID) + rows, err := r.Database.Query("SELECT * FROM media_url WHERE media_id = ?", obj.MediaID) if err != nil { return nil, err } - photoUrls, err := models.NewPhotoURLFromRows(rows) + mediaUrls, err := models.NewMediaURLFromRows(rows) if err != nil { return nil, err } - downloads := make([]*models.PhotoDownload, 0) + downloads := make([]*models.MediaDownload, 0) - for _, url := range photoUrls { + for _, url := range mediaUrls { var title string switch { @@ -104,7 +104,7 @@ func (r *photoResolver) Downloads(ctx context.Context, obj *models.Photo) ([]*mo title = "Large" } - downloads = append(downloads, &models.PhotoDownload{ + downloads = append(downloads, &models.MediaDownload{ Title: title, Width: url.Width, Height: url.Height, @@ -115,23 +115,23 @@ func (r *photoResolver) Downloads(ctx context.Context, obj *models.Photo) ([]*mo return downloads, nil } -func (r *photoResolver) HighRes(ctx context.Context, obj *models.Photo) (*models.PhotoURL, error) { +func (r *mediaResolver) HighRes(ctx context.Context, obj *models.Media) (*models.MediaURL, error) { // Try high res first, then web_types_questions := strings.Repeat("?,", len(scanner.WebMimetypes))[:len(scanner.WebMimetypes)*2-1] args := make([]interface{}, 0) - args = append(args, obj.PhotoID, models.PhotoHighRes, models.MediaOriginal) + args = append(args, obj.MediaID, models.PhotoHighRes, models.MediaOriginal) for _, webtype := range scanner.WebMimetypes { args = append(args, webtype) } row := r.Database.QueryRow(` - SELECT * FROM photo_url WHERE photo_id = ? AND + SELECT * FROM media_url WHERE media_id = ? AND ( purpose = ? OR (purpose = ? AND content_type IN (`+web_types_questions+`)) ) LIMIT 1 `, args...) - url, err := models.NewPhotoURLFromRow(row) + url, err := models.NewMediaURLFromRow(row) if err != nil { log.Printf("Error: Could not query highres: %s\n", err) return nil, err @@ -140,10 +140,10 @@ func (r *photoResolver) HighRes(ctx context.Context, obj *models.Photo) (*models return url, nil } -func (r *photoResolver) Thumbnail(ctx context.Context, obj *models.Photo) (*models.PhotoURL, error) { - row := r.Database.QueryRow("SELECT * FROM photo_url WHERE photo_id = ? AND purpose = ?", obj.PhotoID, models.PhotoThumbnail) +func (r *mediaResolver) Thumbnail(ctx context.Context, obj *models.Media) (*models.MediaURL, error) { + row := r.Database.QueryRow("SELECT * FROM media_url WHERE media_id = ? AND purpose = ?", obj.MediaID, models.PhotoThumbnail) - url, err := models.NewPhotoURLFromRow(row) + url, err := models.NewMediaURLFromRow(row) if err != nil { log.Printf("Error: Could not query thumbnail: %s\n", err) return nil, err @@ -152,15 +152,15 @@ func (r *photoResolver) Thumbnail(ctx context.Context, obj *models.Photo) (*mode return url, nil } -func (r *photoResolver) Album(ctx context.Context, obj *models.Photo) (*models.Album, error) { - row := r.Database.QueryRow("SELECT album.* from photo JOIN album ON photo.album_id = album.album_id WHERE photo_id = ?", obj.PhotoID) +func (r *mediaResolver) Album(ctx context.Context, obj *models.Media) (*models.Album, error) { + row := r.Database.QueryRow("SELECT album.* from media JOIN album ON media.album_id = album.album_id WHERE media_id = ?", obj.MediaID) return models.NewAlbumFromRow(row) } -func (r *photoResolver) Exif(ctx context.Context, obj *models.Photo) (*models.PhotoEXIF, error) { - row := r.Database.QueryRow("SELECT photo_exif.* FROM photo NATURAL JOIN photo_exif WHERE photo.photo_id = ?", obj.PhotoID) +func (r *mediaResolver) Exif(ctx context.Context, obj *models.Media) (*models.MediaEXIF, error) { + row := r.Database.QueryRow("SELECT media_exif.* FROM media NATURAL JOIN media_exif WHERE media.media_id = ?", obj.MediaID) - exif, err := models.NewPhotoExifFromRow(row) + exif, err := models.NewMediaExifFromRow(row) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -172,23 +172,23 @@ func (r *photoResolver) Exif(ctx context.Context, obj *models.Photo) (*models.Ph return exif, nil } -func (r *mutationResolver) FavoritePhoto(ctx context.Context, photoID int, favorite bool) (*models.Photo, error) { +func (r *mutationResolver) FavoriteMedia(ctx context.Context, mediaID int, favorite bool) (*models.Media, error) { user := auth.UserFromContext(ctx) - row := r.Database.QueryRow("SELECT photo.* FROM photo JOIN album ON photo.album_id = album.album_id WHERE photo.photo_id = ? AND album.owner_id = ?", photoID, user.UserID) + row := r.Database.QueryRow("SELECT media.* FROM media JOIN album ON media.album_id = album.album_id WHERE media.media_id = ? AND album.owner_id = ?", mediaID, user.UserID) - photo, err := models.NewPhotoFromRow(row) + media, err := models.NewMediaFromRow(row) if err != nil { return nil, err } - _, err = r.Database.Exec("UPDATE photo SET favorite = ? WHERE photo_id = ?", favorite, photo.PhotoID) + _, err = r.Database.Exec("UPDATE media SET favorite = ? WHERE media_id = ?", favorite, media.MediaID) if err != nil { return nil, err } - photo.Favorite = favorite + media.Favorite = favorite - return photo, nil + return media, nil } diff --git a/api/graphql/resolvers/search.go b/api/graphql/resolvers/search.go index b43a9b18..47a7d01f 100644 --- a/api/graphql/resolvers/search.go +++ b/api/graphql/resolvers/search.go @@ -2,23 +2,23 @@ package resolvers import ( "context" - "log" + "github.com/pkg/errors" "github.com/viktorstrate/photoview/api/graphql/auth" "github.com/viktorstrate/photoview/api/graphql/models" ) -func (r *Resolver) Search(ctx context.Context, query string, _limitPhotos *int, _limitAlbums *int) (*models.SearchResult, error) { +func (r *Resolver) Search(ctx context.Context, query string, _limitMedia *int, _limitAlbums *int) (*models.SearchResult, error) { user := auth.UserFromContext(ctx) if user == nil { return nil, auth.ErrUnauthorized } - limitPhotos := 10 + limitMedia := 10 limitAlbums := 10 - if _limitPhotos != nil { - limitPhotos = *_limitPhotos + if _limitMedia != nil { + limitMedia = *_limitMedia } if _limitAlbums != nil { @@ -28,20 +28,19 @@ func (r *Resolver) Search(ctx context.Context, query string, _limitPhotos *int, wildQuery := "%" + query + "%" photoRows, err := r.Database.Query(` - SELECT photo.* FROM photo JOIN album ON photo.album_id = album.album_id - WHERE album.owner_id = ? AND ( photo.title LIKE ? OR photo.path LIKE ? ) + SELECT media.* FROM media JOIN album ON media.album_id = album.album_id + WHERE album.owner_id = ? AND ( media.title LIKE ? OR media.path LIKE ? ) ORDER BY ( - case when photo.title LIKE ? then 2 - when photo.path LIKE ? then 1 + case when media.title LIKE ? then 2 + when media.path LIKE ? then 1 end ) DESC LIMIT ? - `, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitPhotos) + `, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitMedia) if err != nil { - log.Printf("ERROR: searching photos %s", err) - return nil, err + return nil, errors.Wrapf(err, "searching media") } - photos, err := models.NewPhotosFromRows(photoRows) + photos, err := models.NewMediaFromRows(photoRows) if err != nil { return nil, err } @@ -56,8 +55,7 @@ func (r *Resolver) Search(ctx context.Context, query string, _limitPhotos *int, LIMIT ? `, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitAlbums) if err != nil { - log.Printf("ERROR: searching albums %s", err) - return nil, err + return nil, errors.Wrapf(err, "searching albums") } albums, err := models.NewAlbumsFromRows(albumRows) @@ -67,7 +65,7 @@ func (r *Resolver) Search(ctx context.Context, query string, _limitPhotos *int, result := models.SearchResult{ Query: query, - Photos: photos, + Media: photos, Albums: albums, } diff --git a/api/graphql/resolvers/share_token.go b/api/graphql/resolvers/share_token.go index 7ace2f32..e6d6573b 100644 --- a/api/graphql/resolvers/share_token.go +++ b/api/graphql/resolvers/share_token.go @@ -41,9 +41,9 @@ func (r *shareTokenResolver) Album(ctx context.Context, obj *models.ShareToken) return album, nil } -func (r *shareTokenResolver) Photo(ctx context.Context, obj *models.ShareToken) (*models.Photo, error) { - row := r.Database.QueryRow("SELECT * FROM photo WHERE photo.photo_id = ?", obj.PhotoID) - photo, err := models.NewPhotoFromRow(row) +func (r *shareTokenResolver) Media(ctx context.Context, obj *models.ShareToken) (*models.Media, error) { + row := r.Database.QueryRow("SELECT * FROM media WHERE media.media_id = ?", obj.MediaID) + media, err := models.NewMediaFromRow(row) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -52,7 +52,7 @@ func (r *shareTokenResolver) Photo(ctx context.Context, obj *models.ShareToken) } } - return photo, nil + return media, nil } func (r *shareTokenResolver) HasPassword(ctx context.Context, obj *models.ShareToken) (bool, error) { @@ -158,17 +158,17 @@ func (r *mutationResolver) ShareAlbum(ctx context.Context, albumID int, expire * Expire: expire, Password: password, AlbumID: &albumID, - PhotoID: nil, + MediaID: nil, }, nil } -func (r *mutationResolver) SharePhoto(ctx context.Context, photoID int, expire *time.Time, password *string) (*models.ShareToken, error) { +func (r *mutationResolver) ShareMedia(ctx context.Context, mediaID int, expire *time.Time, password *string) (*models.ShareToken, error) { user := auth.UserFromContext(ctx) if user == nil { return nil, auth.ErrUnauthorized } - rows, err := r.Database.Query("SELECT owner_id FROM album, photo WHERE photo.photo_id = ? AND photo.album_id = album.album_id AND album.owner_id = ?", photoID, user.UserID) + rows, err := r.Database.Query("SELECT owner_id FROM album, media WHERE media.media_id = ? AND media.album_id = album.album_id AND album.owner_id = ?", mediaID, user.UserID) if err != nil { return nil, err } @@ -183,7 +183,7 @@ func (r *mutationResolver) SharePhoto(ctx context.Context, photoID int, expire * } token := utils.GenerateToken() - res, err := r.Database.Exec("INSERT INTO share_token (value, owner_id, expire, password, photo_id) VALUES (?, ?, ?, ?, ?)", token, user.UserID, expire, hashed_password, photoID) + res, err := r.Database.Exec("INSERT INTO share_token (value, owner_id, expire, password, media_id) VALUES (?, ?, ?, ?, ?)", token, user.UserID, expire, hashed_password, mediaID) if err != nil { return nil, err } @@ -200,7 +200,7 @@ func (r *mutationResolver) SharePhoto(ctx context.Context, photoID int, expire * Expire: expire, Password: password, AlbumID: nil, - PhotoID: &photoID, + MediaID: &mediaID, }, nil } @@ -216,7 +216,7 @@ func (r *mutationResolver) DeleteShareToken(ctx context.Context, tokenValue stri } if _, err := r.Database.Exec("DELETE FROM share_token WHERE token_id = ?", token.TokenID); err != nil { - return nil, errors.Wrapf(err, "Error occurred when trying to delete share token (%s) from database", tokenValue) + return nil, errors.Wrapf(err, "failed to delete share token (%s) from database", tokenValue) } return token, nil @@ -240,7 +240,7 @@ func (r *mutationResolver) ProtectShareToken(ctx context.Context, tokenValue str _, err = r.Database.Exec("UPDATE share_token SET password = ? WHERE token_id = ?", hashed_password, token.TokenID) if err != nil { - return nil, errors.Wrap(err, "Failed to update password for share token") + return nil, errors.Wrap(err, "failed to update password for share token") } updatedToken := r.Database.QueryRow("SELECT * FROM share_token WHERE value = ?", tokenValue) diff --git a/api/graphql/schema-reference.graphql b/api/graphql/schema-reference.graphql deleted file mode 100644 index 00996d7c..00000000 --- a/api/graphql/schema-reference.graphql +++ /dev/null @@ -1,161 +0,0 @@ -scalar Time - -enum Role { - admin - user -} - -type User { - id: ID! - username: String! - albums: [Album] - # Local filepath for the user's photos - rootPath: String! - admin: Boolean - shareTokens: [ShareToken] -} - -type Album { - id: ID! - title: String - photos: [Photo] - subAlbums: [Album] - parentAlbum: Album - owner: User! - path: String - - shares: [ShareToken] -} - -type PhotoURL { - # URL for previewing the image - url: String - # Width of the image in pixels - width: Int - # Height of the image in pixels - height: Int -} - -type PhotoDownload { - title: String - url: String -} - -type PhotoEXIF { - photo: Photo - camera: String - maker: String - lens: String - dateShot: Time - fileSize: String - exposure: String - aperture: Float - iso: Int - focalLength: String - flash: String -} - -type Photo { - id: ID! - title: String - # Local filepath for the photo - path: String - # URL to display the photo in full resolution - original: PhotoURL - # URL to display the photo in a smaller resolution - thumbnail: PhotoURL - # The album that holds the photo - album: Album! - exif: PhotoEXIF - - shares: [ShareToken] - downloads: [PhotoDownload] -} - -type ShareToken { - token: ID! - owner: User! - # Optional expire date - expire: Time! - # Optional password - # password: String - - album: Album - photo: Photo -} - -type SiteInfo { - initialSetup: Boolean! -} - -type AuthorizeResult { - success: Boolean! - status: String - token: String -} - -type ScannerResult { - finished: Boolean! - success: Boolean! - progress: Float - message: String -} - -type Result { - success: Boolean! - errorMessage: String -} - -type Subscription { - scannerStatusUpdate: ScannerResult -} - -type Mutation { - authorizeUser(username: String!, password: String!): AuthorizeResult! - - registerUser( - username: String! - password: String! - rootPath: String! - ): AuthorizeResult! - - shareAlbum(albumId: ID!, expire: Time, password: String): ShareToken - sharePhoto(photoId: ID!, expire: Time, password: String): ShareToken - - deleteShareToken(token: ID!): ShareToken - - setAdmin(userId: ID!, admin: Boolean!): Result! - - scanAll: ScannerResult! - scanUser(userId: ID!): ScannerResult! - - initialSetupWizard( - username: String! - password: String! - rootPath: String! - ): AuthorizeResult - - updateUser(id: ID!, username: String, rootPath: String, admin: Boolean): User - createUser(id: ID, username: String, rootPath: String, admin: Boolean): User - deleteUser(id: ID!): User - - changeUserPassword(id: ID!, newPassword: String!): Result -} - -type Query { - siteInfo: SiteInfo - - myUser: User - user: [User] - - myAlbums: [Album] - album(id: ID): Album - - myPhotos: [Photo] - photo(id: ID!): Photo - - shareToken(token: ID!): ShareToken - - albumShares(id: ID!, password: String): [ShareToken] - photoShares(id: ID!, password: String): [ShareToken] -} diff --git a/api/graphql/schema.graphql b/api/graphql/schema.graphql index 5b3a33b6..c9adf902 100644 --- a/api/graphql/schema.graphql +++ b/api/graphql/schema.graphql @@ -27,21 +27,21 @@ type Query { filter: Filter "Return only albums from the root directory of the user" onlyRoot: Boolean - "Return also albums with no photos directly in them" + "Return also albums with no media directly in them" showEmpty: Boolean ): [Album!]! "Get album by id, user must own the album or be admin" album(id: Int!): Album! - "List of photos owned by the logged in user" - myPhotos(filter: Filter): [Photo!]! - "Get photo by id, user must own the photo or be admin" - photo(id: Int!): Photo! + "List of media owned by the logged in user" + myMedia(filter: Filter): [Media!]! + "Get media by id, user must own the media or be admin" + media(id: Int!): Media! shareToken(token: String!, password: String): ShareToken! shareTokenValidatePassword(token: String!, password: String): Boolean! - search(query: String!, limitPhotos: Int, limitAlbums: Int): SearchResult! + search(query: String!, limitMedia: Int, limitAlbums: Int): SearchResult! } type Mutation { @@ -61,22 +61,22 @@ type Mutation { rootPath: String! ): AuthorizeResult - "Scan all users for new photos" + "Scan all users for new media" scanAll: ScannerResult! @isAdmin - "Scan a single user for new photos" + "Scan a single user for new media" scanUser(userId: Int!): ScannerResult! "Generate share token for album" shareAlbum(albumId: Int!, expire: Time, password: String): ShareToken - "Generate share token for photo" - sharePhoto(photoId: Int!, expire: Time, password: String): ShareToken + "Generate share token for media" + shareMedia(mediaId: Int!, expire: Time, password: String): ShareToken "Delete a share token by it's token value" deleteShareToken(token: String!): ShareToken "Set a password for a token, if null is passed for the password argument, the password will be cleared" protectShareToken(token: String!, password: String): ShareToken - "Mark or unmark a photo as being a favorite" - favoritePhoto(photoId: Int!, favorite: Boolean!): Photo + "Mark or unmark a media as being a favorite" + favoriteMedia(mediaId: Int!, favorite: Boolean!): Media updateUser( id: Int! @@ -130,7 +130,7 @@ type ScannerResult { message: String } -"A token used to publicly access an album or photo" +"A token used to publicly access an album or media" type ShareToken { id: Int! token: String! @@ -143,8 +143,8 @@ type ShareToken { "The album this token shares" album: Album - "The photo this token shares" - photo: Photo + "The media this token shares" + media: Media } "General public information about the site" @@ -165,8 +165,8 @@ type User { type Album { id: Int! title: String! - "The photos inside this album" - photos(filter: Filter): [Photo!]! + "The media inside this album" + media(filter: Filter): [Media!]! "The albums contained in this album" subAlbums(filter: Filter): [Album!]! "The album witch contains this album" @@ -176,13 +176,13 @@ type Album { "The path on the filesystem of the server, where this album is located" filePath: String! "An image in this album used for previewing this album" - thumbnail: Photo + thumbnail: Media path: [Album!]! shares: [ShareToken] } -type PhotoURL { +type MediaURL { "URL for previewing the image" url: String! "Width of the image in pixels" @@ -191,35 +191,35 @@ type PhotoURL { height: Int! } -type PhotoDownload { +type MediaDownload { title: String! width: Int! height: Int! url: String! } -type Photo { +type Media { id: Int! title: String! - "Local filepath for the photo" + "Local filepath for the media" path: String! - "URL to display the photo in a smaller resolution" - thumbnail: PhotoURL! - "URL to display the photo in full resolution" - highRes: PhotoURL! - "The album that holds the photo" + "URL to display the media in a smaller resolution" + thumbnail: MediaURL! + "URL to display the photo in full resolution, will be null for videos" + highRes: MediaURL + "The album that holds the media" album: Album! - exif: PhotoEXIF + exif: MediaEXIF favorite: Boolean! shares: [ShareToken!]! - downloads: [PhotoDownload!]! + downloads: [MediaDownload!]! } "EXIF metadata from the camera" -type PhotoEXIF { +type MediaEXIF { id: Int! - photo: Photo + media: Media! "The model name of the camera" camera: String "The maker of the camera" @@ -244,5 +244,5 @@ type PhotoEXIF { type SearchResult { query: String! albums: [Album!]! - photos: [Photo!]! + media: [Media!]! } diff --git a/api/routes/photos.go b/api/routes/photos.go index 0526e18a..6dd7fc27 100644 --- a/api/routes/photos.go +++ b/api/routes/photos.go @@ -21,22 +21,22 @@ import ( func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { router.HandleFunc("/{name}", func(w http.ResponseWriter, r *http.Request) { - image_name := mux.Vars(r)["name"] + media_name := mux.Vars(r)["name"] - row := db.QueryRow("SELECT photo_url.purpose, photo_url.content_type, photo_url.photo_id FROM photo_url, photo WHERE photo_url.photo_name = ? AND photo_url.photo_id = photo.photo_id", image_name) + row := db.QueryRow("SELECT media_url.purpose, media_url.content_type, media_url.media_id FROM media_url, media WHERE media_url.media_name = ? AND media_url.media_id = media.media_id", media_name) var purpose models.MediaPurpose var content_type string - var photo_id int + var media_id int - if err := row.Scan(&purpose, &content_type, &photo_id); err != nil { + if err := row.Scan(&purpose, &content_type, &media_id); err != nil { w.WriteHeader(http.StatusNotFound) w.Write([]byte("404")) return } - row = db.QueryRow("SELECT * FROM photo WHERE photo_id = ?", photo_id) - photo, err := models.NewPhotoFromRow(row) + row = db.QueryRow("SELECT * FROM media WHERE media_id = ?", media_id) + media, err := models.NewMediaFromRow(row) if err != nil { log.Printf("WARN: %s", err) w.WriteHeader(http.StatusInternalServerError) @@ -45,7 +45,7 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { user := auth.UserFromContext(r.Context()) if user != nil { - row := db.QueryRow("SELECT owner_id FROM album WHERE album.album_id = ?", photo.AlbumId) + row := db.QueryRow("SELECT owner_id FROM album WHERE album.album_id = ?", media.AlbumId) var owner_id int if err := row.Scan(&owner_id); err != nil { @@ -96,7 +96,7 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { } } - if shareToken.AlbumID != nil && photo.AlbumId != *shareToken.AlbumID { + if shareToken.AlbumID != nil && media.AlbumId != *shareToken.AlbumID { // Check child albums row := db.QueryRow(` WITH recursive child_albums AS ( @@ -105,7 +105,7 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { SELECT child.* FROM album child JOIN child_albums parent ON parent.album_id = child.parent_album ) SELECT * FROM child_albums WHERE album_id = ? - `, *shareToken.AlbumID, photo.AlbumId) + `, *shareToken.AlbumID, media.AlbumId) _, err := models.NewAlbumFromRow(row) if err != nil { @@ -121,7 +121,7 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { } } - if shareToken.PhotoID != nil && photo_id != *shareToken.PhotoID { + if shareToken.MediaID != nil && media_id != *shareToken.MediaID { w.WriteHeader(http.StatusForbidden) w.Write([]byte("unauthorized")) return @@ -133,11 +133,11 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { var file *os.File = nil if purpose == models.PhotoThumbnail || purpose == models.PhotoHighRes { - cachedPath = path.Join(scanner.PhotoCache(), strconv.Itoa(photo.AlbumId), strconv.Itoa(photo_id), image_name) + cachedPath = path.Join(scanner.PhotoCache(), strconv.Itoa(media.AlbumId), strconv.Itoa(media_id), media_name) } if purpose == models.MediaOriginal { - cachedPath = photo.Path + cachedPath = media.Path } file, err = os.Open(cachedPath) @@ -151,7 +151,7 @@ func RegisterPhotoRoutes(db *sql.DB, router *mux.Router) { return } - _, err = scanner.ProcessMedia(tx, photo) + _, err = scanner.ProcessMedia(tx, media) if err != nil { log.Printf("ERROR: processing image not found in cache: %s\n", err) w.WriteHeader(http.StatusInternalServerError) diff --git a/api/scanner/encode_photo.go b/api/scanner/encode_photo.go index 69b8427d..3339d6b6 100644 --- a/api/scanner/encode_photo.go +++ b/api/scanner/encode_photo.go @@ -45,7 +45,7 @@ func (dimensions *PhotoDimensions) ThumbnailScale() PhotoDimensions { // EncodeImageData is used to easily decode image data, with a cache so expensive operations are not repeated type EncodeImageData struct { - photo *models.Photo + media *models.Media _photoImage image.Image _thumbnailImage image.Image _contentType *MediaType @@ -90,7 +90,7 @@ func (img *EncodeImageData) ContentType() (*MediaType, error) { return img._contentType, nil } - imgType, err := getImageType(img.photo.Path) + imgType, err := getImageType(img.media.Path) if err != nil { return nil, err } @@ -111,7 +111,7 @@ func (img *EncodeImageData) EncodeHighRes(tx *sql.Tx, outputPath string) error { if contentType.isRaw() { if DarktableCli.IsInstalled() { - err := DarktableCli.EncodeJpeg(img.photo.Path, outputPath, 70) + err := DarktableCli.EncodeJpeg(img.media.Path, outputPath, 70) if err != nil { return err } @@ -159,7 +159,7 @@ func (img *EncodeImageData) photoImage(tx *sql.Tx) (image.Image, error) { return img._photoImage, nil } - photoFile, err := os.Open(img.photo.Path) + photoFile, err := os.Open(img.media.Path) if err != nil { return nil, err } @@ -171,7 +171,7 @@ func (img *EncodeImageData) photoImage(tx *sql.Tx) (image.Image, error) { } // Get orientation from exif data - row := tx.QueryRow("SELECT photo_exif.orientation FROM photo JOIN photo_exif WHERE photo.exif_id = photo_exif.exif_id AND photo.photo_id = ?", img.photo.PhotoID) + row := tx.QueryRow("SELECT media_exif.orientation FROM media JOIN media_exif WHERE media.exif_id = media_exif.exif_id AND media.media_id = ?", img.media.MediaID) var orientation *int if err = row.Scan(&orientation); err != nil { // If not found use default orientation (not rotate) diff --git a/api/scanner/exif.go b/api/scanner/exif.go index 33adbc04..e4e97b1b 100644 --- a/api/scanner/exif.go +++ b/api/scanner/exif.go @@ -14,19 +14,19 @@ import ( "github.com/xor-gate/goexif2/mknote" ) -func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, returnErr error) { +func ScanEXIF(tx *sql.Tx, media *models.Media) (returnExif *models.MediaEXIF, returnErr error) { log.Printf("Scanning for EXIF") { // Check if EXIF data already exists - if photo.ExifId != nil { - row := tx.QueryRow("SELECT * FROM photo_exif WHERE exif_id = ?", photo.ExifId) - return models.NewPhotoExifFromRow(row) + if media.ExifId != nil { + row := tx.QueryRow("SELECT * FROM media_exif WHERE exif_id = ?", media.ExifId) + return models.NewMediaExifFromRow(row) } - row := tx.QueryRow("SELECT photo_exif.* FROM photo, photo_exif WHERE photo.exif_id = photo_exif.exif_id AND photo.photo_id = ?", photo.PhotoID) - exifData, err := models.NewPhotoExifFromRow(row) + row := tx.QueryRow("SELECT media_exif.* FROM media, media_exif WHERE media.exif_id = media_exif.exif_id AND media.media_id = ?", media.MediaID) + exifData, err := models.NewMediaExifFromRow(row) if err != nil && err != sql.ErrNoRows { return nil, err } else if exifData != nil { @@ -34,7 +34,7 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re } } - photoFile, err := os.Open(photo.Path) + photoFile, err := os.Open(media.Path) if err != nil { return nil, err } @@ -54,24 +54,22 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re return nil, errors.Wrap(err, "Could not decode EXIF") } - // log.Printf("EXIF DATA FOR %s\n%s\n", photo.Title, exifTags.String()) - valueNames := make([]string, 0) exifValues := make([]interface{}, 0) - model, err := readStringTag(exifTags, exif.Model, photo) + model, err := readStringTag(exifTags, exif.Model, media) if err == nil { valueNames = append(valueNames, "camera") exifValues = append(exifValues, model) } - maker, err := readStringTag(exifTags, exif.Make, photo) + maker, err := readStringTag(exifTags, exif.Make, media) if err == nil { valueNames = append(valueNames, "maker") exifValues = append(exifValues, maker) } - lens, err := readStringTag(exifTags, exif.LensModel, photo) + lens, err := readStringTag(exifTags, exif.LensModel, media) if err == nil { valueNames = append(valueNames, "lens") exifValues = append(exifValues, lens) @@ -83,13 +81,13 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re exifValues = append(exifValues, date) } - exposure, err := readRationalTag(exifTags, exif.ExposureTime, photo) + exposure, err := readRationalTag(exifTags, exif.ExposureTime, media) if err == nil { valueNames = append(valueNames, "exposure") exifValues = append(exifValues, exposure.RatString()) } - apertureRat, err := readRationalTag(exifTags, exif.FNumber, photo) + apertureRat, err := readRationalTag(exifTags, exif.FNumber, media) if err == nil { aperture, _ := apertureRat.Float32() valueNames = append(valueNames, "aperture") @@ -98,11 +96,11 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re isoTag, err := exifTags.Get(exif.ISOSpeedRatings) if err != nil { - log.Printf("WARN: Could not read ISOSpeedRatings from EXIF: %s\n", photo.Title) + log.Printf("WARN: Could not read ISOSpeedRatings from EXIF: %s\n", media.Title) } else { iso, err := isoTag.Int(0) if err != nil { - log.Printf("WARN: Could not parse EXIF ISOSpeedRatings as integer: %s\n", photo.Title) + log.Printf("WARN: Could not parse EXIF ISOSpeedRatings as integer: %s\n", media.Title) } else { valueNames = append(valueNames, "iso") exifValues = append(exifValues, iso) @@ -123,7 +121,7 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re if err == nil { focalLength, err := focalLengthTag.Int(1) if err != nil { - log.Printf("WARN: Could not parse EXIF FocalLength as rational or integer: %s\n%s\n", photo.Title, err) + log.Printf("WARN: Could not parse EXIF FocalLength as rational or integer: %s\n%s\n", media.Title, err) } else { valueNames = append(valueNames, "focal_length") exifValues = append(exifValues, focalLength) @@ -138,13 +136,13 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re exifValues = append(exifValues, flash) } - orientation, err := readIntegerTag(exifTags, exif.Orientation, photo) + orientation, err := readIntegerTag(exifTags, exif.Orientation, media) if err == nil { valueNames = append(valueNames, "orientation") exifValues = append(exifValues, *orientation) } - exposureProgram, err := readIntegerTag(exifTags, exif.ExposureProgram, photo) + exposureProgram, err := readIntegerTag(exifTags, exif.ExposureProgram, media) if err == nil { valueNames = append(valueNames, "exposure_program") exifValues = append(exifValues, *exposureProgram) @@ -167,7 +165,7 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re columns = columns[0 : len(columns)-1] // Insert into database - result, err := tx.Exec("INSERT INTO photo_exif ("+columns+") VALUES ("+prepareQuestions+")", exifValues...) + result, err := tx.Exec("INSERT INTO media_exif ("+columns+") VALUES ("+prepareQuestions+")", exifValues...) if err != nil { return nil, err } @@ -177,85 +175,79 @@ func ScanEXIF(tx *sql.Tx, photo *models.Photo) (returnExif *models.PhotoEXIF, re return nil, err } - // Link exif to photo in database - result, err = tx.Exec("UPDATE photo SET exif_id = ? WHERE photo_id = ?", exifID, photo.PhotoID) + // Link exif to media in database + result, err = tx.Exec("UPDATE media SET exif_id = ? WHERE media_id = ?", exifID, media.MediaID) if err != nil { return nil, err } rowsAffected, err := result.RowsAffected() if err != nil { - return nil, err + return nil, errors.Wrap(err, "linking exif to media in database failed") } if rowsAffected == 0 { - return nil, errors.New("Linking exif to photo in database failed: 0 rows affected") + return nil, errors.New("linking exif to media in database failed: 0 rows affected") } // Return newly created exif row - row := tx.QueryRow("SELECT * FROM photo_exif WHERE exif_id = ?", exifID) - return models.NewPhotoExifFromRow(row) + row := tx.QueryRow("SELECT * FROM media_exif WHERE exif_id = ?", exifID) + return models.NewMediaExifFromRow(row) } -func readStringTag(tags *exif.Exif, name exif.FieldName, photo *models.Photo) (*string, error) { +func readStringTag(tags *exif.Exif, name exif.FieldName, media *models.Media) (*string, error) { tag, err := tags.Get(name) if err != nil { - log.Printf("WARN: Could not read %s from EXIF: %s\n", name, photo.Title) - return nil, err + return nil, errors.Wrapf(err, "could not read %s from EXIF: %s", name, media.Title) } if tag != nil { value, err := tag.StringVal() if err != nil { - log.Printf("WARN: Could not parse %s from EXIF as string: %s\n", name, photo.Title) - return nil, err + return nil, errors.Wrapf(err, "could not parse %s from EXIF as string: %s", name, media.Title) } return &value, nil } - log.Printf("WARN: EXIF tag %s returned null: %s\n", name, photo.Title) + log.Printf("WARN: EXIF tag %s returned null: %s\n", name, media.Title) return nil, errors.New("exif tag returned null") } -func readRationalTag(tags *exif.Exif, name exif.FieldName, photo *models.Photo) (*big.Rat, error) { +func readRationalTag(tags *exif.Exif, name exif.FieldName, media *models.Media) (*big.Rat, error) { tag, err := tags.Get(name) if err != nil { - log.Printf("WARN: Could not read %s from EXIF: %s\n", name, photo.Title) - return nil, err + return nil, errors.Wrapf(err, "could not read %s from EXIF: %s", name, media.Title) } if tag != nil { value, err := tag.Rat(0) if err != nil { - log.Printf("WARN: Could not parse %s from EXIF as rational: %s\n%s\n", name, photo.Title, err) - return nil, err + return nil, errors.Wrapf(err, "could not parse %s from EXIF as rational: %s", name, media.Title) } return value, nil } - log.Printf("WARN: EXIF tag %s returned null: %s\n", name, photo.Title) + log.Printf("WARN: EXIF tag %s returned null: %s\n", name, media.Title) return nil, errors.New("exif tag returned null") } -func readIntegerTag(tags *exif.Exif, name exif.FieldName, photo *models.Photo) (*int, error) { +func readIntegerTag(tags *exif.Exif, name exif.FieldName, media *models.Media) (*int, error) { tag, err := tags.Get(name) if err != nil { - log.Printf("WARN: Could not read %s from EXIF: %s\n", name, photo.Title) - return nil, err + return nil, errors.Wrapf(err, "could not read %s from EXIF: %s", name, media.Title) } if tag != nil { value, err := tag.Int(0) if err != nil { - log.Printf("WARN: Could not parse %s from EXIF as integer: %s\n%s\n", name, photo.Title, err) - return nil, err + return nil, errors.Wrapf(err, "Could not parse %s from EXIF as integer: %s", name, media.Title) } return &value, nil } - log.Printf("WARN: EXIF tag %s returned null: %s\n", name, photo.Title) + log.Printf("WARN: EXIF tag %s returned null: %s\n", name, media.Title) return nil, errors.New("exif tag returned null") } diff --git a/api/scanner/process_photo.go b/api/scanner/process_photo.go index 5e928fe5..a7564081 100644 --- a/api/scanner/process_photo.go +++ b/api/scanner/process_photo.go @@ -22,16 +22,16 @@ import ( _ "golang.org/x/image/webp" ) -// Higher order function used to check if PhotoURL for a given PhotoPurpose exists -func makePhotoURLChecker(tx *sql.Tx, photoID int) (func(purpose models.MediaPurpose) (*models.PhotoURL, error), error) { - photoURLExistsStmt, err := tx.Prepare("SELECT * FROM photo_url WHERE photo_id = ? AND purpose = ?") +// Higher order function used to check if MediaURL for a given MediaPurpose exists +func makePhotoURLChecker(tx *sql.Tx, mediaID int) (func(purpose models.MediaPurpose) (*models.MediaURL, error), error) { + mediaURLExistsStmt, err := tx.Prepare("SELECT * FROM media_url WHERE media_id = ? AND purpose = ?") if err != nil { return nil, err } - return func(purpose models.MediaPurpose) (*models.PhotoURL, error) { - row := photoURLExistsStmt.QueryRow(photoID, purpose) - photoURL, err := models.NewPhotoURLFromRow(row) + return func(purpose models.MediaPurpose) (*models.MediaURL, error) { + row := mediaURLExistsStmt.QueryRow(mediaID, purpose) + mediaURL, err := models.NewMediaURLFromRow(row) if err != nil { if err == sql.ErrNoRows { return nil, nil @@ -39,22 +39,22 @@ func makePhotoURLChecker(tx *sql.Tx, photoID int) (func(purpose models.MediaPurp return nil, err } - return photoURL, nil + return mediaURL, nil }, nil } -func ProcessMedia(tx *sql.Tx, photo *models.Photo) (bool, error) { +func ProcessMedia(tx *sql.Tx, media *models.Media) (bool, error) { imageData := EncodeImageData{ - photo: photo, + media: media, } contentType, err := imageData.ContentType() if err != nil { - return false, errors.Wrapf(err, "get content-type of media (%s)", photo.Path) + return false, errors.Wrapf(err, "get content-type of media (%s)", media.Path) } - // Make sure photo cache directory exists - mediaCachePath, err := makeMediaCacheDir(photo) + // Make sure media cache directory exists + mediaCachePath, err := makeMediaCacheDir(media) if err != nil { return false, errors.Wrap(err, "cache directory error") } @@ -68,13 +68,13 @@ func ProcessMedia(tx *sql.Tx, photo *models.Photo) (bool, error) { func processPhoto(tx *sql.Tx, imageData *EncodeImageData, photoCachePath *string) (bool, error) { - photo := imageData.photo + photo := imageData.media log.Printf("Processing photo: %s\n", photo.Path) didProcess := false - photoUrlFromDB, err := makePhotoURLChecker(tx, photo.PhotoID) + photoUrlFromDB, err := makePhotoURLChecker(tx, photo.MediaID) if err != nil { return false, err } @@ -128,19 +128,19 @@ func processPhoto(tx *sql.Tx, imageData *EncodeImageData, photoCachePath *string return false, err } - _, err = tx.Exec("INSERT INTO photo_url (photo_id, photo_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", - photo.PhotoID, highres_name, photoDimensions.Width, photoDimensions.Height, models.PhotoHighRes, "image/jpeg") + _, err = tx.Exec("INSERT INTO media_url (media_id, media_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", + photo.MediaID, highres_name, photoDimensions.Width, photoDimensions.Height, models.PhotoHighRes, "image/jpeg") if err != nil { - log.Printf("Could not insert highres photo url: %d, %s\n", photo.PhotoID, path.Base(photo.Path)) + log.Printf("Could not insert highres media url: %d, %s\n", photo.MediaID, path.Base(photo.Path)) return false, err } } } else { // Verify that highres photo still exists in cache - baseImagePath = path.Join(*photoCachePath, highResURL.PhotoName) + baseImagePath = path.Join(*photoCachePath, highResURL.MediaName) if _, err := os.Stat(baseImagePath); os.IsNotExist(err) { - fmt.Printf("High-res photo found in database but not in cache, re-encoding photo to cache: %s\n", highResURL.PhotoName) + fmt.Printf("High-res photo found in database but not in cache, re-encoding photo to cache: %s\n", highResURL.MediaName) didProcess = true err = imageData.EncodeHighRes(tx, baseImagePath) @@ -188,17 +188,17 @@ func processPhoto(tx *sql.Tx, imageData *EncodeImageData, photoCachePath *string return false, errors.Wrap(err, "could not create thumbnail cached image") } - _, err = tx.Exec("INSERT INTO photo_url (photo_id, photo_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", photo.PhotoID, thumbnail_name, thumbSize.Width, thumbSize.Height, models.PhotoThumbnail, "image/jpeg") + _, err = tx.Exec("INSERT INTO media_url (media_id, media_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", photo.MediaID, thumbnail_name, thumbSize.Width, thumbSize.Height, models.PhotoThumbnail, "image/jpeg") if err != nil { return false, err } } else { // Verify that thumbnail photo still exists in cache - thumbPath := path.Join(*photoCachePath, thumbURL.PhotoName) + thumbPath := path.Join(*photoCachePath, thumbURL.MediaName) if _, err := os.Stat(thumbPath); os.IsNotExist(err) { didProcess = true - fmt.Printf("Thumbnail photo found in database but not in cache, re-encoding photo to cache: %s\n", thumbURL.PhotoName) + fmt.Printf("Thumbnail photo found in database but not in cache, re-encoding photo to cache: %s\n", thumbURL.MediaName) _, err := EncodeThumbnail(baseImagePath, thumbPath) if err != nil { @@ -210,7 +210,7 @@ func processPhoto(tx *sql.Tx, imageData *EncodeImageData, photoCachePath *string return didProcess, nil } -func makeMediaCacheDir(photo *models.Photo) (*string, error) { +func makeMediaCacheDir(photo *models.Media) (*string, error) { // Make root cache dir if not exists if _, err := os.Stat(PhotoCache()); os.IsNotExist(err) { @@ -228,7 +228,7 @@ func makeMediaCacheDir(photo *models.Photo) (*string, error) { } // Make photo cache dir if not exists - photoCachePath := path.Join(albumCachePath, strconv.Itoa(photo.PhotoID)) + photoCachePath := path.Join(albumCachePath, strconv.Itoa(photo.MediaID)) if _, err := os.Stat(photoCachePath); os.IsNotExist(err) { if err := os.Mkdir(photoCachePath, os.ModePerm); err != nil { return nil, errors.Wrap(err, "could not make photo image cache directory") @@ -238,7 +238,7 @@ func makeMediaCacheDir(photo *models.Photo) (*string, error) { return &photoCachePath, nil } -func saveOriginalPhotoToDB(tx *sql.Tx, photo *models.Photo, imageData *EncodeImageData, photoDimensions *PhotoDimensions) error { +func saveOriginalPhotoToDB(tx *sql.Tx, photo *models.Media, imageData *EncodeImageData, photoDimensions *PhotoDimensions) error { photoName := path.Base(photo.Path) photoBaseName := photoName[0 : len(photoName)-len(path.Ext(photoName))] photoBaseExt := path.Ext(photoName) @@ -251,9 +251,9 @@ func saveOriginalPhotoToDB(tx *sql.Tx, photo *models.Photo, imageData *EncodeIma return err } - _, err = tx.Exec("INSERT INTO photo_url (photo_id, photo_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", photo.PhotoID, original_image_name, photoDimensions.Width, photoDimensions.Height, models.MediaOriginal, contentType) + _, err = tx.Exec("INSERT INTO media_url (media_id, media_name, width, height, purpose, content_type) VALUES (?, ?, ?, ?, ?, ?)", photo.MediaID, original_image_name, photoDimensions.Width, photoDimensions.Height, models.MediaOriginal, contentType) if err != nil { - log.Printf("Could not insert original photo url: %d, %s\n", photo.PhotoID, photoName) + log.Printf("Could not insert original photo url: %d, %s\n", photo.MediaID, photoName) return err } diff --git a/api/scanner/process_video.go b/api/scanner/process_video.go index ed38af0d..4820ee40 100644 --- a/api/scanner/process_video.go +++ b/api/scanner/process_video.go @@ -9,12 +9,12 @@ import ( ) func processVideo(tx *sql.Tx, imageData *EncodeImageData, videoCachePath *string) (bool, error) { - video := imageData.photo + video := imageData.media didProcess := false log.Printf("Processing video: %s", video.Path) - mediaUrlFromDB, err := makePhotoURLChecker(tx, video.PhotoID) + mediaUrlFromDB, err := makePhotoURLChecker(tx, video.MediaID) if err != nil { return false, err } diff --git a/api/scanner/scanner_album.go b/api/scanner/scanner_album.go index 00161a8d..d76db3cb 100644 --- a/api/scanner/scanner_album.go +++ b/api/scanner/scanner_album.go @@ -19,7 +19,7 @@ func scanAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB) { notifyThrottle.Trigger(nil) // Scan for photos - albumPhotos, err := findPhotosForAlbum(album, cache, db, func(photo *models.Photo, newPhoto bool) { + albumPhotos, err := findPhotosForAlbum(album, cache, db, func(photo *models.Media, newPhoto bool) { if newPhoto { notifyThrottle.Trigger(func() { notification.BroadcastNotification(&models.Notification{ @@ -80,9 +80,9 @@ func scanAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB) { } } -func findPhotosForAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB, onScanPhoto func(photo *models.Photo, newPhoto bool)) ([]*models.Photo, error) { +func findPhotosForAlbum(album *models.Album, cache *AlbumScannerCache, db *sql.DB, onScanPhoto func(photo *models.Media, newPhoto bool)) ([]*models.Media, error) { - albumPhotos := make([]*models.Photo, 0) + albumPhotos := make([]*models.Media, 0) dirContent, err := ioutil.ReadDir(album.Path) if err != nil { diff --git a/api/scanner/scanner_photo.go b/api/scanner/scanner_photo.go index ddffa92e..8c868cfd 100644 --- a/api/scanner/scanner_photo.go +++ b/api/scanner/scanner_photo.go @@ -8,13 +8,13 @@ import ( "github.com/viktorstrate/photoview/api/graphql/models" ) -func ScanPhoto(tx *sql.Tx, photoPath string, albumId int) (*models.Photo, bool, error) { +func ScanPhoto(tx *sql.Tx, photoPath string, albumId int) (*models.Media, bool, error) { photoName := path.Base(photoPath) // Check if image already exists { row := tx.QueryRow("SELECT * FROM photo WHERE path_hash = MD5(?)", photoPath) - photo, err := models.NewPhotoFromRow(row) + photo, err := models.NewMediaFromRow(row) if err != sql.ErrNoRows { if err == nil { log.Printf("Image already scanned: %s\n", photoPath) @@ -32,13 +32,13 @@ func ScanPhoto(tx *sql.Tx, photoPath string, albumId int) (*models.Photo, bool, log.Printf("ERROR: Could not insert photo into database") return nil, false, err } - photo_id, err := result.LastInsertId() + media_id, err := result.LastInsertId() if err != nil { return nil, false, err } - row := tx.QueryRow("SELECT * FROM photo WHERE photo_id = ?", photo_id) - photo, err := models.NewPhotoFromRow(row) + row := tx.QueryRow("SELECT * FROM photo WHERE media_id = ?", media_id) + photo, err := models.NewMediaFromRow(row) if err != nil { return nil, false, err } diff --git a/api/scanner/scanner_user.go b/api/scanner/scanner_user.go index 1f33008f..43d1046d 100644 --- a/api/scanner/scanner_user.go +++ b/api/scanner/scanner_user.go @@ -209,64 +209,6 @@ func deleteOldUserAlbums(db *sql.DB, scannedAlbums []*models.Album, user *models return deleteErrors } -// func cleanupCache(database *sql.DB, cache *ScannerCache, user *models.User) { - -// // Delete old photos -// photo_args := make([]interface{}, 0) -// photo_args = append(photo_args, user.UserID) -// photo_args = append(photo_args, cache.photo_paths_scanned...) - -// photo_questions := strings.Repeat("MD5(?),", len(cache.photo_paths_scanned))[:len(cache.photo_paths_scanned)*7-1] - -// rows, err = database.Query(` -// SELECT photo.photo_id as photo_id, album.album_id as album_id FROM photo JOIN album ON photo.album_id = album.album_id -// WHERE album.owner_id = ? AND photo.path_hash NOT IN (`+photo_questions+`) -// `, photo_args...) -// if err != nil { -// ScannerError("Could not get deleted photos from database: %s\n", err) -// return -// } -// defer rows.Close() - -// deleted_photo_ids := make([]interface{}, 0) - -// for rows.Next() { -// var photo_id int -// var album_id int - -// if err := rows.Scan(&photo_id, &album_id); err != nil { -// ScannerError("Could not parse photo to be removed (album_id %d, photo_id %d): %s\n", album_id, photo_id, err) -// } - -// deleted_photo_ids = append(deleted_photo_ids, photo_id) -// cache_path := path.Join("./photo_cache", strconv.Itoa(album_id), strconv.Itoa(photo_id)) -// err := os.RemoveAll(cache_path) -// if err != nil { -// ScannerError("Could not delete unused cache photo folder: %s\n%s\n", cache_path, err) -// } -// } - -// if len(deleted_photo_ids) > 0 { -// photo_questions = strings.Repeat("?,", len(deleted_photo_ids))[:len(deleted_photo_ids)*2-1] - -// if _, err := database.Exec("DELETE FROM photo WHERE photo_id IN ("+photo_questions+")", deleted_photo_ids...); err != nil { -// ScannerError("Could not delete old photos from database:\n%s\n", err) -// } -// } - -// if len(deleted_album_ids) > 0 || len(deleted_photo_ids) > 0 { -// timeout := 3000 -// notification.BroadcastNotification(&models.Notification{ -// Key: utils.GenerateToken(), -// Type: models.NotificationTypeMessage, -// Header: "Deleted old photos", -// Content: fmt.Sprintf("Deleted %d albums and %d photos, that was not found on disk", len(deleted_album_ids), len(deleted_photo_ids)), -// Timeout: &timeout, -// }) -// } - -// } - func ScannerError(format string, args ...interface{}) { message := fmt.Sprintf(format, args...) diff --git a/ui/src/Pages/PhotosPage/PhotosPage.js b/ui/src/Pages/PhotosPage/PhotosPage.js index 508b07e1..101146d3 100644 --- a/ui/src/Pages/PhotosPage/PhotosPage.js +++ b/ui/src/Pages/PhotosPage/PhotosPage.js @@ -10,8 +10,8 @@ const photoQuery = gql` myAlbums(filter: { order_by: "title", order_direction: ASC, limit: 100 }) { title id - photos( - filter: { order_by: "photo.title", order_direction: DESC, limit: 12 } + media( + filter: { order_by: "media.title", order_direction: DESC, limit: 12 } ) { id title @@ -66,7 +66,7 @@ class PhotosPage extends Component { } nextImage() { - const albumImageCount = this.albums[this.state.activeAlbumIndex].photos + const albumImageCount = this.albums[this.state.activeAlbumIndex].media .length if (this.state.activePhotoIndex + 1 < albumImageCount) { @@ -115,7 +115,7 @@ class PhotosPage extends Component { this.setPresenting(presenting, index) } loading={loading} - photos={album.photos} + media={album.media} nextImage={this.nextImage} previousImage={this.previousImage} /> @@ -126,7 +126,7 @@ class PhotosPage extends Component { let activeImage = null if (this.state.activeAlbumIndex != -1) { activeImage = - data.myAlbums[this.state.activeAlbumIndex].photos[ + data.myAlbums[this.state.activeAlbumIndex].media[ this.state.activePhotoIndex ].id } diff --git a/ui/src/components/header/Searchbar.js b/ui/src/components/header/Searchbar.js index 0304a1b8..00fb8416 100644 --- a/ui/src/components/header/Searchbar.js +++ b/ui/src/components/header/Searchbar.js @@ -63,7 +63,7 @@ const SEARCH_QUERY = gql` } } } - photos { + media { id title thumbnail { @@ -128,20 +128,20 @@ const SearchResults = ({ result }) => { const { data, loading } = result const query = data && data.search.query - const photos = (data && data.search.photos) || [] + const media = (data && data.search.media) || [] const albums = (data && data.search.albums) || [] let message = null if (loading) message = 'Loading results...' - else if (data && photos.length == 0 && albums.length == 0) + else if (data && media.length == 0 && albums.length == 0) message = 'No results found' const albumElements = albums.map(album => ( )) - const photoElements = photos.map(photo => ( - + const mediaElements = media.map(media => ( + )) return ( @@ -155,8 +155,8 @@ const SearchResults = ({ result }) => { {message} {albumElements.length > 0 && Albums} {albumElements} - {photoElements.length > 0 && Photos} - {photoElements} + {mediaElements.length > 0 && Photos} + {mediaElements} ) } @@ -192,16 +192,16 @@ const RowTitle = styled.span` padding-left: 8px; ` -const PhotoRow = ({ query, photo }) => ( - - - {searchHighlighted(query, photo.title)} +const PhotoRow = ({ query, media }) => ( + + + {searchHighlighted(query, media.title)} ) PhotoRow.propTypes = { query: PropTypes.string.isRequired, - photo: PropTypes.object.isRequired, + media: PropTypes.object.isRequired, } const AlbumRow = ({ query, album }) => ( diff --git a/ui/src/components/photoGallery/Photo.js b/ui/src/components/photoGallery/Photo.js index 77101054..a396945f 100644 --- a/ui/src/components/photoGallery/Photo.js +++ b/ui/src/components/photoGallery/Photo.js @@ -8,8 +8,8 @@ import { Icon } from 'semantic-ui-react' import ProtectedImage from './ProtectedImage' const markFavoriteMutation = gql` - mutation markPhotoFavorite($photoId: Int!, $favorite: Boolean!) { - favoritePhoto(photoId: $photoId, favorite: $favorite) { + mutation markMediaFavorite($mediaId: Int!, $favorite: Boolean!) { + favoriteMedia(mediaId: $mediaId, favorite: $favorite) { id favorite } @@ -136,7 +136,7 @@ export const Photo = ({ event.stopPropagation() markFavorite({ variables: { - photoId: photo.id, + mediaId: photo.id, favorite: !photo.favorite, }, optimisticResponse: { diff --git a/ui/src/components/photoGallery/PhotoGallery.js b/ui/src/components/photoGallery/PhotoGallery.js index 77a54440..06768231 100644 --- a/ui/src/components/photoGallery/PhotoGallery.js +++ b/ui/src/components/photoGallery/PhotoGallery.js @@ -23,7 +23,7 @@ const PhotoFiller = styled.div` const PhotoGallery = ({ activeIndex = -1, - photos, + media, loading, onSelectImage, presenting, @@ -57,14 +57,14 @@ const PhotoGallery = ({ } }) - const activeImage = photos && activeIndex != -1 && photos[activeIndex] + const activeImage = media && activeIndex != -1 && media[activeIndex] const getPhotoElements = updateSidebar => { let photoElements = [] - if (photos) { - photos.filter(photo => photo.thumbnail) + if (media) { + media.filter(media => media.thumbnail) - photoElements = photos.map((photo, index) => { + photoElements = media.map((photo, index) => { const active = activeIndex == index let minWidth = 100 @@ -121,7 +121,7 @@ const PhotoGallery = ({ PhotoGallery.propTypes = { loading: PropTypes.bool, - photos: PropTypes.array, + media: PropTypes.array, activeIndex: PropTypes.number, presenting: PropTypes.bool, onSelectImage: PropTypes.func,