Replace database, resolve all build-time errors
This commit is contained in:
parent
d3ebecc3b5
commit
e42ac2436b
|
@ -36,3 +36,5 @@ models:
|
||||||
model: github.com/viktorstrate/photoview/api/graphql/models.Album
|
model: github.com/viktorstrate/photoview/api/graphql/models.Album
|
||||||
ShareToken:
|
ShareToken:
|
||||||
model: github.com/viktorstrate/photoview/api/graphql/models.ShareToken
|
model: github.com/viktorstrate/photoview/api/graphql/models.ShareToken
|
||||||
|
SiteInfo:
|
||||||
|
model: github.com/viktorstrate/photoview/api/graphql/models.SiteInfo
|
||||||
|
|
|
@ -40,13 +40,10 @@ type Config struct {
|
||||||
type ResolverRoot interface {
|
type ResolverRoot interface {
|
||||||
Album() AlbumResolver
|
Album() AlbumResolver
|
||||||
Media() MediaResolver
|
Media() MediaResolver
|
||||||
MediaEXIF() MediaEXIFResolver
|
|
||||||
Mutation() MutationResolver
|
Mutation() MutationResolver
|
||||||
Query() QueryResolver
|
Query() QueryResolver
|
||||||
ShareToken() ShareTokenResolver
|
ShareToken() ShareTokenResolver
|
||||||
Subscription() SubscriptionResolver
|
Subscription() SubscriptionResolver
|
||||||
User() UserResolver
|
|
||||||
VideoMetadata() VideoMetadataResolver
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type DirectiveRoot struct {
|
type DirectiveRoot struct {
|
||||||
|
@ -216,8 +213,6 @@ type ComplexityRoot struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type AlbumResolver interface {
|
type AlbumResolver interface {
|
||||||
ID(ctx context.Context, obj *models.Album) (int, error)
|
|
||||||
|
|
||||||
Media(ctx context.Context, obj *models.Album, filter *models.Filter, onlyFavorites *bool) ([]*models.Media, error)
|
Media(ctx context.Context, obj *models.Album, filter *models.Filter, onlyFavorites *bool) ([]*models.Media, error)
|
||||||
SubAlbums(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Album, error)
|
SubAlbums(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Album, error)
|
||||||
|
|
||||||
|
@ -226,8 +221,6 @@ type AlbumResolver interface {
|
||||||
Shares(ctx context.Context, obj *models.Album) ([]*models.ShareToken, error)
|
Shares(ctx context.Context, obj *models.Album) ([]*models.ShareToken, error)
|
||||||
}
|
}
|
||||||
type MediaResolver interface {
|
type MediaResolver interface {
|
||||||
ID(ctx context.Context, obj *models.Media) (int, error)
|
|
||||||
|
|
||||||
Thumbnail(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
Thumbnail(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
||||||
HighRes(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
HighRes(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
||||||
VideoWeb(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
VideoWeb(ctx context.Context, obj *models.Media) (*models.MediaURL, error)
|
||||||
|
@ -235,10 +228,6 @@ type MediaResolver interface {
|
||||||
Shares(ctx context.Context, obj *models.Media) ([]*models.ShareToken, error)
|
Shares(ctx context.Context, obj *models.Media) ([]*models.ShareToken, error)
|
||||||
Downloads(ctx context.Context, obj *models.Media) ([]*models.MediaDownload, error)
|
Downloads(ctx context.Context, obj *models.Media) ([]*models.MediaDownload, error)
|
||||||
}
|
}
|
||||||
type MediaEXIFResolver interface {
|
|
||||||
ID(ctx context.Context, obj *models.MediaEXIF) (int, error)
|
|
||||||
Media(ctx context.Context, obj *models.MediaEXIF) (*models.Media, error)
|
|
||||||
}
|
|
||||||
type MutationResolver interface {
|
type MutationResolver interface {
|
||||||
AuthorizeUser(ctx context.Context, username string, password string) (*models.AuthorizeResult, error)
|
AuthorizeUser(ctx context.Context, username string, password string) (*models.AuthorizeResult, error)
|
||||||
RegisterUser(ctx context.Context, username string, password string, rootPath string) (*models.AuthorizeResult, error)
|
RegisterUser(ctx context.Context, username string, password string, rootPath string) (*models.AuthorizeResult, error)
|
||||||
|
@ -272,22 +261,11 @@ type QueryResolver interface {
|
||||||
Search(ctx context.Context, query string, limitMedia *int, limitAlbums *int) (*models.SearchResult, error)
|
Search(ctx context.Context, query string, limitMedia *int, limitAlbums *int) (*models.SearchResult, error)
|
||||||
}
|
}
|
||||||
type ShareTokenResolver interface {
|
type ShareTokenResolver interface {
|
||||||
ID(ctx context.Context, obj *models.ShareToken) (int, error)
|
|
||||||
|
|
||||||
HasPassword(ctx context.Context, obj *models.ShareToken) (bool, error)
|
HasPassword(ctx context.Context, obj *models.ShareToken) (bool, error)
|
||||||
}
|
}
|
||||||
type SubscriptionResolver interface {
|
type SubscriptionResolver interface {
|
||||||
Notification(ctx context.Context) (<-chan *models.Notification, error)
|
Notification(ctx context.Context) (<-chan *models.Notification, error)
|
||||||
}
|
}
|
||||||
type UserResolver interface {
|
|
||||||
ID(ctx context.Context, obj *models.User) (int, error)
|
|
||||||
}
|
|
||||||
type VideoMetadataResolver interface {
|
|
||||||
ID(ctx context.Context, obj *models.VideoMetadata) (int, error)
|
|
||||||
Media(ctx context.Context, obj *models.VideoMetadata) (*models.Media, error)
|
|
||||||
|
|
||||||
Bitrate(ctx context.Context, obj *models.VideoMetadata) (*int, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type executableSchema struct {
|
type executableSchema struct {
|
||||||
resolvers ResolverRoot
|
resolvers ResolverRoot
|
||||||
|
@ -1330,15 +1308,15 @@ type Query {
|
||||||
onlyWithFavorites: Boolean
|
onlyWithFavorites: Boolean
|
||||||
): [Album!]!
|
): [Album!]!
|
||||||
"Get album by id, user must own the album or be admin"
|
"Get album by id, user must own the album or be admin"
|
||||||
album(id: Int!): Album!
|
album(id: ID!): Album!
|
||||||
|
|
||||||
"List of media owned by the logged in user"
|
"List of media owned by the logged in user"
|
||||||
myMedia(filter: Filter): [Media!]!
|
myMedia(filter: Filter): [Media!]!
|
||||||
"Get media by id, user must own the media or be admin"
|
"Get media by id, user must own the media or be admin"
|
||||||
media(id: Int!): Media!
|
media(id: ID!): Media!
|
||||||
|
|
||||||
"Get a list of media by their ids, user must own the media or be admin"
|
"Get a list of media by their ids, user must own the media or be admin"
|
||||||
mediaList(ids: [Int!]!): [Media!]!
|
mediaList(ids: [ID!]!): [Media!]!
|
||||||
|
|
||||||
"Get media owned by the logged in user, returned in GeoJson format"
|
"Get media owned by the logged in user, returned in GeoJson format"
|
||||||
myMediaGeoJson: Any!
|
myMediaGeoJson: Any!
|
||||||
|
@ -1371,22 +1349,22 @@ type Mutation {
|
||||||
"Scan all users for new media"
|
"Scan all users for new media"
|
||||||
scanAll: ScannerResult! @isAdmin
|
scanAll: ScannerResult! @isAdmin
|
||||||
"Scan a single user for new media"
|
"Scan a single user for new media"
|
||||||
scanUser(userId: Int!): ScannerResult!
|
scanUser(userId: ID!): ScannerResult!
|
||||||
|
|
||||||
"Generate share token for album"
|
"Generate share token for album"
|
||||||
shareAlbum(albumId: Int!, expire: Time, password: String): ShareToken
|
shareAlbum(albumId: ID!, expire: Time, password: String): ShareToken
|
||||||
"Generate share token for media"
|
"Generate share token for media"
|
||||||
shareMedia(mediaId: Int!, expire: Time, password: String): ShareToken
|
shareMedia(mediaId: ID!, expire: Time, password: String): ShareToken
|
||||||
"Delete a share token by it's token value"
|
"Delete a share token by it's token value"
|
||||||
deleteShareToken(token: String!): ShareToken
|
deleteShareToken(token: String!): ShareToken
|
||||||
"Set a password for a token, if null is passed for the password argument, the password will be cleared"
|
"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
|
protectShareToken(token: String!, password: String): ShareToken
|
||||||
|
|
||||||
"Mark or unmark a media as being a favorite"
|
"Mark or unmark a media as being a favorite"
|
||||||
favoriteMedia(mediaId: Int!, favorite: Boolean!): Media
|
favoriteMedia(mediaId: ID!, favorite: Boolean!): Media
|
||||||
|
|
||||||
updateUser(
|
updateUser(
|
||||||
id: Int!
|
id: ID!
|
||||||
username: String
|
username: String
|
||||||
rootPath: String
|
rootPath: String
|
||||||
password: String
|
password: String
|
||||||
|
@ -1398,7 +1376,7 @@ type Mutation {
|
||||||
password: String
|
password: String
|
||||||
admin: Boolean!
|
admin: Boolean!
|
||||||
): User @isAdmin
|
): User @isAdmin
|
||||||
deleteUser(id: Int!): User @isAdmin
|
deleteUser(id: ID!): User @isAdmin
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Set how often, in seconds, the server should automatically scan for new media,
|
Set how often, in seconds, the server should automatically scan for new media,
|
||||||
|
@ -1448,7 +1426,7 @@ type ScannerResult {
|
||||||
|
|
||||||
"A token used to publicly access an album or media"
|
"A token used to publicly access an album or media"
|
||||||
type ShareToken {
|
type ShareToken {
|
||||||
id: Int!
|
id: ID!
|
||||||
token: String!
|
token: String!
|
||||||
"The user who created the token"
|
"The user who created the token"
|
||||||
owner: User!
|
owner: User!
|
||||||
|
@ -1473,7 +1451,7 @@ type SiteInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
id: Int!
|
id: ID!
|
||||||
username: String!
|
username: String!
|
||||||
#albums: [Album]
|
#albums: [Album]
|
||||||
"Local filepath for the user's photos"
|
"Local filepath for the user's photos"
|
||||||
|
@ -1483,7 +1461,7 @@ type User {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Album {
|
type Album {
|
||||||
id: Int!
|
id: ID!
|
||||||
title: String!
|
title: String!
|
||||||
"The media inside this album"
|
"The media inside this album"
|
||||||
media(
|
media(
|
||||||
|
@ -1528,7 +1506,7 @@ enum MediaType {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Media {
|
type Media {
|
||||||
id: Int!
|
id: ID!
|
||||||
title: String!
|
title: String!
|
||||||
"Local filepath for the media"
|
"Local filepath for the media"
|
||||||
path: String!
|
path: String!
|
||||||
|
@ -1551,7 +1529,7 @@ type Media {
|
||||||
|
|
||||||
"EXIF metadata from the camera"
|
"EXIF metadata from the camera"
|
||||||
type MediaEXIF {
|
type MediaEXIF {
|
||||||
id: Int!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
"The model name of the camera"
|
"The model name of the camera"
|
||||||
camera: String
|
camera: String
|
||||||
|
@ -1575,14 +1553,14 @@ type MediaEXIF {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VideoMetadata {
|
type VideoMetadata {
|
||||||
id: Int!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
width: Int!
|
width: Int!
|
||||||
height: Int!
|
height: Int!
|
||||||
duration: Float!
|
duration: Float!
|
||||||
codec: String
|
codec: String
|
||||||
framerate: Float
|
framerate: Float
|
||||||
bitrate: Int
|
bitrate: String
|
||||||
colorProfile: String
|
colorProfile: String
|
||||||
audio: String
|
audio: String
|
||||||
}
|
}
|
||||||
|
@ -1726,7 +1704,7 @@ func (ec *executionContext) field_Mutation_deleteUser_args(ctx context.Context,
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["id"]; ok {
|
if tmp, ok := rawArgs["id"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1741,7 +1719,7 @@ func (ec *executionContext) field_Mutation_favoriteMedia_args(ctx context.Contex
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["mediaId"]; ok {
|
if tmp, ok := rawArgs["mediaId"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mediaId"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mediaId"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1855,7 +1833,7 @@ func (ec *executionContext) field_Mutation_scanUser_args(ctx context.Context, ra
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["userId"]; ok {
|
if tmp, ok := rawArgs["userId"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("userId"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1900,7 +1878,7 @@ func (ec *executionContext) field_Mutation_shareAlbum_args(ctx context.Context,
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["albumId"]; ok {
|
if tmp, ok := rawArgs["albumId"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("albumId"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("albumId"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1933,7 +1911,7 @@ func (ec *executionContext) field_Mutation_shareMedia_args(ctx context.Context,
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["mediaId"]; ok {
|
if tmp, ok := rawArgs["mediaId"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mediaId"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("mediaId"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -1966,7 +1944,7 @@ func (ec *executionContext) field_Mutation_updateUser_args(ctx context.Context,
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["id"]; ok {
|
if tmp, ok := rawArgs["id"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2032,7 +2010,7 @@ func (ec *executionContext) field_Query_album_args(ctx context.Context, rawArgs
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["id"]; ok {
|
if tmp, ok := rawArgs["id"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2047,7 +2025,7 @@ func (ec *executionContext) field_Query_mediaList_args(ctx context.Context, rawA
|
||||||
var arg0 []int
|
var arg0 []int
|
||||||
if tmp, ok := rawArgs["ids"]; ok {
|
if tmp, ok := rawArgs["ids"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids"))
|
||||||
arg0, err = ec.unmarshalNInt2ᚕintᚄ(ctx, tmp)
|
arg0, err = ec.unmarshalNID2ᚕintᚄ(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2062,7 +2040,7 @@ func (ec *executionContext) field_Query_media_args(ctx context.Context, rawArgs
|
||||||
var arg0 int
|
var arg0 int
|
||||||
if tmp, ok := rawArgs["id"]; ok {
|
if tmp, ok := rawArgs["id"]; ok {
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("id"))
|
||||||
arg0, err = ec.unmarshalNInt2int(ctx, tmp)
|
arg0, err = ec.unmarshalNID2int(ctx, tmp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -2273,14 +2251,14 @@ func (ec *executionContext) _Album_id(ctx context.Context, field graphql.Collect
|
||||||
Object: "Album",
|
Object: "Album",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.Album().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -2294,7 +2272,7 @@ func (ec *executionContext) _Album_id(ctx context.Context, field graphql.Collect
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Album_title(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Album_title(ctx context.Context, field graphql.CollectedField, obj *models.Album) (ret graphql.Marshaler) {
|
||||||
|
@ -2730,14 +2708,14 @@ func (ec *executionContext) _Media_id(ctx context.Context, field graphql.Collect
|
||||||
Object: "Media",
|
Object: "Media",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.Media().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -2751,7 +2729,7 @@ func (ec *executionContext) _Media_id(ctx context.Context, field graphql.Collect
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _Media_title(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) {
|
func (ec *executionContext) _Media_title(ctx context.Context, field graphql.CollectedField, obj *models.Media) (ret graphql.Marshaler) {
|
||||||
|
@ -3243,14 +3221,14 @@ func (ec *executionContext) _MediaEXIF_id(ctx context.Context, field graphql.Col
|
||||||
Object: "MediaEXIF",
|
Object: "MediaEXIF",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.MediaEXIF().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -3264,7 +3242,7 @@ func (ec *executionContext) _MediaEXIF_id(ctx context.Context, field graphql.Col
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _MediaEXIF_media(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) {
|
func (ec *executionContext) _MediaEXIF_media(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) {
|
||||||
|
@ -3279,13 +3257,13 @@ func (ec *executionContext) _MediaEXIF_media(ctx context.Context, field graphql.
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: true,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.MediaEXIF().Media(rctx, obj)
|
return obj.Media(), nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -5568,14 +5546,14 @@ func (ec *executionContext) _ShareToken_id(ctx context.Context, field graphql.Co
|
||||||
Object: "ShareToken",
|
Object: "ShareToken",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.ShareToken().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -5589,7 +5567,7 @@ func (ec *executionContext) _ShareToken_id(ctx context.Context, field graphql.Co
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _ShareToken_token(ctx context.Context, field graphql.CollectedField, obj *models.ShareToken) (ret graphql.Marshaler) {
|
func (ec *executionContext) _ShareToken_token(ctx context.Context, field graphql.CollectedField, obj *models.ShareToken) (ret graphql.Marshaler) {
|
||||||
|
@ -5994,14 +5972,14 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte
|
||||||
Object: "User",
|
Object: "User",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.User().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -6015,7 +5993,7 @@ func (ec *executionContext) _User_id(ctx context.Context, field graphql.Collecte
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) {
|
func (ec *executionContext) _User_username(ctx context.Context, field graphql.CollectedField, obj *models.User) (ret graphql.Marshaler) {
|
||||||
|
@ -6154,14 +6132,14 @@ func (ec *executionContext) _VideoMetadata_id(ctx context.Context, field graphql
|
||||||
Object: "VideoMetadata",
|
Object: "VideoMetadata",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.VideoMetadata().ID(rctx, obj)
|
return obj.ID, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -6175,7 +6153,7 @@ func (ec *executionContext) _VideoMetadata_id(ctx context.Context, field graphql
|
||||||
}
|
}
|
||||||
res := resTmp.(int)
|
res := resTmp.(int)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalNInt2int(ctx, field.Selections, res)
|
return ec.marshalNID2int(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _VideoMetadata_media(ctx context.Context, field graphql.CollectedField, obj *models.VideoMetadata) (ret graphql.Marshaler) {
|
func (ec *executionContext) _VideoMetadata_media(ctx context.Context, field graphql.CollectedField, obj *models.VideoMetadata) (ret graphql.Marshaler) {
|
||||||
|
@ -6190,13 +6168,13 @@ func (ec *executionContext) _VideoMetadata_media(ctx context.Context, field grap
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: true,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.VideoMetadata().Media(rctx, obj)
|
return obj.Media(), nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -6393,14 +6371,14 @@ func (ec *executionContext) _VideoMetadata_bitrate(ctx context.Context, field gr
|
||||||
Object: "VideoMetadata",
|
Object: "VideoMetadata",
|
||||||
Field: field,
|
Field: field,
|
||||||
Args: nil,
|
Args: nil,
|
||||||
IsMethod: true,
|
IsMethod: false,
|
||||||
IsResolver: true,
|
IsResolver: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx = graphql.WithFieldContext(ctx, fc)
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
ctx = rctx // use context from middleware stack in children
|
ctx = rctx // use context from middleware stack in children
|
||||||
return ec.resolvers.VideoMetadata().Bitrate(rctx, obj)
|
return obj.Bitrate, nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ec.Error(ctx, err)
|
ec.Error(ctx, err)
|
||||||
|
@ -6409,9 +6387,9 @@ func (ec *executionContext) _VideoMetadata_bitrate(ctx context.Context, field gr
|
||||||
if resTmp == nil {
|
if resTmp == nil {
|
||||||
return graphql.Null
|
return graphql.Null
|
||||||
}
|
}
|
||||||
res := resTmp.(*int)
|
res := resTmp.(*string)
|
||||||
fc.Result = res
|
fc.Result = res
|
||||||
return ec.marshalOInt2ᚖint(ctx, field.Selections, res)
|
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _VideoMetadata_colorProfile(ctx context.Context, field graphql.CollectedField, obj *models.VideoMetadata) (ret graphql.Marshaler) {
|
func (ec *executionContext) _VideoMetadata_colorProfile(ctx context.Context, field graphql.CollectedField, obj *models.VideoMetadata) (ret graphql.Marshaler) {
|
||||||
|
@ -7629,19 +7607,10 @@ func (ec *executionContext) _Album(ctx context.Context, sel ast.SelectionSet, ob
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("Album")
|
out.Values[i] = graphql.MarshalString("Album")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._Album_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._Album_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
atomic.AddUint32(&invalids, 1)
|
||||||
}
|
}
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "title":
|
case "title":
|
||||||
out.Values[i] = ec._Album_title(ctx, field, obj)
|
out.Values[i] = ec._Album_title(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
|
@ -7780,19 +7749,10 @@ func (ec *executionContext) _Media(ctx context.Context, sel ast.SelectionSet, ob
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("Media")
|
out.Values[i] = graphql.MarshalString("Media")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._Media_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._Media_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
atomic.AddUint32(&invalids, 1)
|
||||||
}
|
}
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "title":
|
case "title":
|
||||||
out.Values[i] = ec._Media_title(ctx, field, obj)
|
out.Values[i] = ec._Media_title(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
|
@ -7941,33 +7901,15 @@ func (ec *executionContext) _MediaEXIF(ctx context.Context, sel ast.SelectionSet
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("MediaEXIF")
|
out.Values[i] = graphql.MarshalString("MediaEXIF")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._MediaEXIF_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
invalids++
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
res = ec._MediaEXIF_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "media":
|
case "media":
|
||||||
field := field
|
out.Values[i] = ec._MediaEXIF_media(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
invalids++
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
res = ec._MediaEXIF_media(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "camera":
|
case "camera":
|
||||||
out.Values[i] = ec._MediaEXIF_camera(ctx, field, obj)
|
out.Values[i] = ec._MediaEXIF_camera(ctx, field, obj)
|
||||||
case "maker":
|
case "maker":
|
||||||
|
@ -8465,19 +8407,10 @@ func (ec *executionContext) _ShareToken(ctx context.Context, sel ast.SelectionSe
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("ShareToken")
|
out.Values[i] = graphql.MarshalString("ShareToken")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._ShareToken_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._ShareToken_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
atomic.AddUint32(&invalids, 1)
|
||||||
}
|
}
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "token":
|
case "token":
|
||||||
out.Values[i] = ec._ShareToken_token(ctx, field, obj)
|
out.Values[i] = ec._ShareToken_token(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
|
@ -8588,33 +8521,24 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("User")
|
out.Values[i] = graphql.MarshalString("User")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._User_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
invalids++
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
res = ec._User_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "username":
|
case "username":
|
||||||
out.Values[i] = ec._User_username(ctx, field, obj)
|
out.Values[i] = ec._User_username(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
case "rootPath":
|
case "rootPath":
|
||||||
out.Values[i] = ec._User_rootPath(ctx, field, obj)
|
out.Values[i] = ec._User_rootPath(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
case "admin":
|
case "admin":
|
||||||
out.Values[i] = ec._User_admin(ctx, field, obj)
|
out.Values[i] = ec._User_admin(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("unknown field " + strconv.Quote(field.Name))
|
panic("unknown field " + strconv.Quote(field.Name))
|
||||||
|
@ -8639,63 +8563,36 @@ func (ec *executionContext) _VideoMetadata(ctx context.Context, sel ast.Selectio
|
||||||
case "__typename":
|
case "__typename":
|
||||||
out.Values[i] = graphql.MarshalString("VideoMetadata")
|
out.Values[i] = graphql.MarshalString("VideoMetadata")
|
||||||
case "id":
|
case "id":
|
||||||
field := field
|
out.Values[i] = ec._VideoMetadata_id(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
invalids++
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
res = ec._VideoMetadata_id(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "media":
|
case "media":
|
||||||
field := field
|
out.Values[i] = ec._VideoMetadata_media(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
if out.Values[i] == graphql.Null {
|
||||||
defer func() {
|
invalids++
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
}
|
||||||
}()
|
|
||||||
res = ec._VideoMetadata_media(ctx, field, obj)
|
|
||||||
if res == graphql.Null {
|
|
||||||
atomic.AddUint32(&invalids, 1)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "width":
|
case "width":
|
||||||
out.Values[i] = ec._VideoMetadata_width(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_width(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
case "height":
|
case "height":
|
||||||
out.Values[i] = ec._VideoMetadata_height(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_height(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
case "duration":
|
case "duration":
|
||||||
out.Values[i] = ec._VideoMetadata_duration(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_duration(ctx, field, obj)
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
atomic.AddUint32(&invalids, 1)
|
invalids++
|
||||||
}
|
}
|
||||||
case "codec":
|
case "codec":
|
||||||
out.Values[i] = ec._VideoMetadata_codec(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_codec(ctx, field, obj)
|
||||||
case "framerate":
|
case "framerate":
|
||||||
out.Values[i] = ec._VideoMetadata_framerate(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_framerate(ctx, field, obj)
|
||||||
case "bitrate":
|
case "bitrate":
|
||||||
field := field
|
out.Values[i] = ec._VideoMetadata_bitrate(ctx, field, obj)
|
||||||
out.Concurrently(i, func() (res graphql.Marshaler) {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
ec.Error(ctx, ec.Recover(ctx, r))
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
res = ec._VideoMetadata_bitrate(ctx, field, obj)
|
|
||||||
return res
|
|
||||||
})
|
|
||||||
case "colorProfile":
|
case "colorProfile":
|
||||||
out.Values[i] = ec._VideoMetadata_colorProfile(ctx, field, obj)
|
out.Values[i] = ec._VideoMetadata_colorProfile(ctx, field, obj)
|
||||||
case "audio":
|
case "audio":
|
||||||
|
@ -9072,6 +8969,51 @@ func (ec *executionContext) marshalNFloat2float64(ctx context.Context, sel ast.S
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalNID2int(ctx context.Context, v interface{}) (int, error) {
|
||||||
|
res, err := graphql.UnmarshalIntID(v)
|
||||||
|
return res, graphql.ErrorOnPath(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNID2int(ctx context.Context, sel ast.SelectionSet, v int) graphql.Marshaler {
|
||||||
|
res := graphql.MarshalIntID(v)
|
||||||
|
if res == graphql.Null {
|
||||||
|
if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
|
||||||
|
ec.Errorf(ctx, "must not be null")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) unmarshalNID2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) {
|
||||||
|
var vSlice []interface{}
|
||||||
|
if v != nil {
|
||||||
|
if tmp1, ok := v.([]interface{}); ok {
|
||||||
|
vSlice = tmp1
|
||||||
|
} else {
|
||||||
|
vSlice = []interface{}{v}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var err error
|
||||||
|
res := make([]int, len(vSlice))
|
||||||
|
for i := range vSlice {
|
||||||
|
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
|
||||||
|
res[i], err = ec.unmarshalNID2int(ctx, vSlice[i])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) marshalNID2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler {
|
||||||
|
ret := make(graphql.Array, len(v))
|
||||||
|
for i := range v {
|
||||||
|
ret[i] = ec.marshalNID2int(ctx, sel, v[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
|
func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
|
||||||
res, err := graphql.UnmarshalInt(v)
|
res, err := graphql.UnmarshalInt(v)
|
||||||
return res, graphql.ErrorOnPath(ctx, err)
|
return res, graphql.ErrorOnPath(ctx, err)
|
||||||
|
@ -9102,36 +9044,6 @@ func (ec *executionContext) marshalNInt2int64(ctx context.Context, sel ast.Selec
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ec *executionContext) unmarshalNInt2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) {
|
|
||||||
var vSlice []interface{}
|
|
||||||
if v != nil {
|
|
||||||
if tmp1, ok := v.([]interface{}); ok {
|
|
||||||
vSlice = tmp1
|
|
||||||
} else {
|
|
||||||
vSlice = []interface{}{v}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
res := make([]int, len(vSlice))
|
|
||||||
for i := range vSlice {
|
|
||||||
ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i))
|
|
||||||
res[i], err = ec.unmarshalNInt2int(ctx, vSlice[i])
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.SelectionSet, v []int) graphql.Marshaler {
|
|
||||||
ret := make(graphql.Array, len(v))
|
|
||||||
for i := range v {
|
|
||||||
ret[i] = ec.marshalNInt2int(ctx, sel, v[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ec *executionContext) marshalNMedia2githubᚗcomᚋviktorstrateᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx context.Context, sel ast.SelectionSet, v models.Media) graphql.Marshaler {
|
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)
|
return ec._Media(ctx, sel, &v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Album struct {
|
type Album struct {
|
||||||
gorm.Model
|
Model
|
||||||
Title string
|
Title string
|
||||||
ParentAlbumID *uint
|
ParentAlbumID *int
|
||||||
ParentAlbum *Album
|
ParentAlbum *Album
|
||||||
OwnerID uint
|
OwnerID int
|
||||||
Owner User
|
Owner User
|
||||||
Path string
|
Path string
|
||||||
PathHash string `gorm:"unique"`
|
PathHash string `gorm:"unique"`
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package models
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Model struct {
|
||||||
|
ID int `gorm:"primarykey"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
}
|
|
@ -51,15 +51,6 @@ type SearchResult struct {
|
||||||
Media []*Media `json:"media"`
|
Media []*Media `json:"media"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// General information about the site
|
|
||||||
type SiteInfo struct {
|
|
||||||
InitialSetup bool `json:"initialSetup"`
|
|
||||||
// How often automatic scans should be initiated in seconds
|
|
||||||
PeriodicScanInterval int `json:"periodicScanInterval"`
|
|
||||||
// How many max concurrent scanner jobs that should run at once
|
|
||||||
ConcurrentWorkers int `json:"concurrentWorkers"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type MediaType string
|
type MediaType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -6,24 +6,23 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/viktorstrate/photoview/api/utils"
|
"github.com/viktorstrate/photoview/api/utils"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Media struct {
|
type Media struct {
|
||||||
gorm.Model
|
Model
|
||||||
Title string
|
Title string
|
||||||
Path string
|
Path string
|
||||||
PathHash string
|
PathHash string
|
||||||
AlbumID uint
|
AlbumID int
|
||||||
Album Album
|
Album Album
|
||||||
ExifID *uint
|
ExifID *int
|
||||||
Exif *MediaEXIF
|
Exif *MediaEXIF
|
||||||
MediaURL []MediaURL
|
MediaURL []MediaURL
|
||||||
DateShot time.Time
|
DateShot time.Time
|
||||||
DateImported time.Time
|
DateImported time.Time
|
||||||
Favorite bool
|
Favorite bool
|
||||||
Type MediaType
|
Type MediaType
|
||||||
VideoMetadataID *uint
|
VideoMetadataID *int
|
||||||
VideoMetadata *VideoMetadata
|
VideoMetadata *VideoMetadata
|
||||||
SideCarPath *string
|
SideCarPath *string
|
||||||
SideCarHash *string
|
SideCarHash *string
|
||||||
|
@ -44,8 +43,8 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type MediaURL struct {
|
type MediaURL struct {
|
||||||
gorm.Model
|
Model
|
||||||
MediaID uint
|
MediaID int
|
||||||
Media Media
|
Media Media
|
||||||
MediaName string
|
MediaName string
|
||||||
Width int
|
Width int
|
||||||
|
|
|
@ -2,12 +2,10 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MediaEXIF struct {
|
type MediaEXIF struct {
|
||||||
gorm.Model
|
Model
|
||||||
Camera *string
|
Camera *string
|
||||||
Maker *string
|
Maker *string
|
||||||
Lens *string
|
Lens *string
|
||||||
|
@ -22,3 +20,7 @@ type MediaEXIF struct {
|
||||||
GPSLatitude *float64
|
GPSLatitude *float64
|
||||||
GPSLonitude *float64
|
GPSLonitude *float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (exif *MediaEXIF) Media() *Media {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
|
@ -2,20 +2,18 @@ package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ShareToken struct {
|
type ShareToken struct {
|
||||||
gorm.Model
|
Model
|
||||||
Value string
|
Value string
|
||||||
OwnerID uint
|
OwnerID int
|
||||||
Owner User
|
Owner User
|
||||||
Expire *time.Time
|
Expire *time.Time
|
||||||
Password *string
|
Password *string
|
||||||
AlbumID *uint
|
AlbumID *int
|
||||||
Album Album
|
Album Album
|
||||||
MediaID *uint
|
MediaID *int
|
||||||
Media *Media
|
Media *Media
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type SiteInfo struct {
|
type SiteInfo struct {
|
||||||
gorm.Model
|
Model
|
||||||
InitialSetup bool
|
InitialSetup bool
|
||||||
PeriodicScanInterval int
|
PeriodicScanInterval int
|
||||||
ConcurrentWorkers int
|
ConcurrentWorkers int
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
gorm.Model
|
Model
|
||||||
Username string `gorm:"unique,size:128"`
|
Username string `gorm:"unique,size:128"`
|
||||||
Password *string `gorm:"size:256`
|
Password *string `gorm:"size:256`
|
||||||
RootPath string `gorm:"size:512`
|
RootPath string `gorm:"size:512`
|
||||||
|
@ -25,8 +25,8 @@ type User struct {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
type AccessToken struct {
|
type AccessToken struct {
|
||||||
gorm.Model
|
Model
|
||||||
UserID uint
|
UserID int
|
||||||
User User `gorm:"constraint:OnDelete:CASCADE;"`
|
User User `gorm:"constraint:OnDelete:CASCADE;"`
|
||||||
Value string `gorm:"size:24`
|
Value string `gorm:"size:24`
|
||||||
Expire time.Time
|
Expire time.Time
|
||||||
|
|
|
@ -6,6 +6,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (filter *Filter) FormatSQL(context string) (string, error) {
|
func (filter *Filter) FormatSQL(context string) (string, error) {
|
||||||
|
// TODO: Migrate method to gorm
|
||||||
|
|
||||||
if filter == nil {
|
if filter == nil {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
type VideoMetadata struct {
|
type VideoMetadata struct {
|
||||||
gorm.Model
|
Model
|
||||||
Width int
|
Width int
|
||||||
Height int
|
Height int
|
||||||
Duration float64
|
Duration float64
|
||||||
|
@ -15,3 +11,7 @@ type VideoMetadata struct {
|
||||||
ColorProfile *string
|
ColorProfile *string
|
||||||
Audio *string
|
Audio *string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (metadata *VideoMetadata) Media() *Media {
|
||||||
|
panic("not implemented")
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@ package resolvers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
api "github.com/viktorstrate/photoview/api/graphql"
|
api "github.com/viktorstrate/photoview/api/graphql"
|
||||||
"github.com/viktorstrate/photoview/api/graphql/auth"
|
"github.com/viktorstrate/photoview/api/graphql/auth"
|
||||||
|
@ -15,41 +16,26 @@ func (r *queryResolver) MyAlbums(ctx context.Context, filter *models.Filter, onl
|
||||||
return nil, auth.ErrUnauthorized
|
return nil, auth.ErrUnauthorized
|
||||||
}
|
}
|
||||||
|
|
||||||
filterSQL, err := filter.FormatSQL("album")
|
query := r.Database.Where("owner_id = ?", user.ID)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
if onlyRoot != nil && *onlyRoot == true {
|
||||||
|
query = query.Where("parent_album = ()", query.Model(&models.Album{})).Select("id").Where("parent_album IS NULL AND owner_id = ?", user.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
var rows *sql.Rows
|
if showEmpty == nil || *showEmpty == false {
|
||||||
|
subQuery := r.Database.Model(&models.Media{}).Where("album_id = album.album_id")
|
||||||
|
|
||||||
filterFavorites := " AND favorite = 1"
|
if onlyWithFavorites != nil && *onlyWithFavorites == true {
|
||||||
if onlyWithFavorites == nil || *onlyWithFavorites == false {
|
subQuery = subQuery.Where("favorite = 1")
|
||||||
filterFavorites = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filterEmpty := " AND EXISTS (SELECT * FROM media WHERE album_id = album.album_id" + filterFavorites + ") "
|
query = query.Where("EXISTS (?)", subQuery)
|
||||||
if showEmpty != nil && *showEmpty == true && (onlyWithFavorites == nil || *onlyWithFavorites == false) {
|
|
||||||
filterEmpty = ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if onlyRoot == nil || *onlyRoot == false {
|
// TODO: Incorporate models.FormatSQL
|
||||||
rows, err = r.Database.Query("SELECT * FROM album WHERE owner_id = ?"+filterEmpty+filterSQL, user.UserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rows, err = r.Database.Query(`
|
|
||||||
SELECT * FROM album WHERE owner_id = ? AND parent_album = (
|
|
||||||
SELECT album_id FROM album WHERE parent_album IS NULL AND owner_id = ?
|
|
||||||
)
|
|
||||||
`+filterEmpty+filterSQL, user.UserID, user.UserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
albums, err := models.NewAlbumsFromRows(rows)
|
var albums []*models.Album
|
||||||
if err != nil {
|
if err := query.Find(albums).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,13 +48,12 @@ func (r *queryResolver) Album(ctx context.Context, id int) (*models.Album, error
|
||||||
return nil, auth.ErrUnauthorized
|
return nil, auth.ErrUnauthorized
|
||||||
}
|
}
|
||||||
|
|
||||||
row := r.Database.QueryRow("SELECT * FROM album WHERE album_id = ? AND owner_id = ?", id, user.UserID)
|
var album models.Album
|
||||||
album, err := models.NewAlbumFromRow(row)
|
if err := r.Database.Where("owner_id = ?", user.ID).First(&album, id).Error; err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return album, nil
|
return &album, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resolver) Album() api.AlbumResolver {
|
func (r *Resolver) Album() api.AlbumResolver {
|
||||||
|
@ -77,32 +62,21 @@ func (r *Resolver) Album() api.AlbumResolver {
|
||||||
|
|
||||||
type albumResolver struct{ *Resolver }
|
type albumResolver struct{ *Resolver }
|
||||||
|
|
||||||
func (r *albumResolver) Media(ctx context.Context, obj *models.Album, filter *models.Filter, onlyFavorites *bool) ([]*models.Media, error) {
|
func (r *albumResolver) Media(ctx context.Context, album *models.Album, filter *models.Filter, onlyFavorites *bool) ([]*models.Media, error) {
|
||||||
|
|
||||||
filterSQL, err := filter.FormatSQL("media")
|
query := r.Database.
|
||||||
if err != nil {
|
Joins("Album").
|
||||||
return nil, err
|
Where("Album.id = ?", album.ID).
|
||||||
|
Where("media.id IN (?)", r.Database.Model(&models.MediaURL{})).Select("media_id").Where("media_url.media_id = media.id")
|
||||||
|
|
||||||
|
if onlyFavorites != nil && *onlyFavorites == true {
|
||||||
|
query = query.Where("media.favorite = 1")
|
||||||
}
|
}
|
||||||
|
|
||||||
filterFavorites := " AND media.favorite = 1 "
|
// TODO: Incorporate filter.FormatSQL
|
||||||
if onlyFavorites == nil || *onlyFavorites == false {
|
|
||||||
filterFavorites = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
mediaRows, err := r.Database.Query(`
|
var media []*models.Media
|
||||||
SELECT media.* FROM album, media
|
if err := query.Find(&media).Error; err != nil {
|
||||||
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
|
|
||||||
)
|
|
||||||
`+filterFavorites+filterSQL, obj.AlbumID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
defer mediaRows.Close()
|
|
||||||
|
|
||||||
media, err := models.NewMediaFromRows(mediaRows)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,47 +85,44 @@ func (r *albumResolver) Media(ctx context.Context, obj *models.Album, filter *mo
|
||||||
|
|
||||||
func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*models.Media, error) {
|
func (r *albumResolver) Thumbnail(ctx context.Context, obj *models.Album) (*models.Media, error) {
|
||||||
|
|
||||||
row := r.Database.QueryRow(`
|
log.Println("TODO: Album thumbnail migrated yet")
|
||||||
WITH recursive sub_albums AS (
|
|
||||||
SELECT * FROM album AS root WHERE album_id = ?
|
|
||||||
UNION ALL
|
|
||||||
SELECT child.* FROM album AS child JOIN sub_albums ON child.parent_album = sub_albums.album_id
|
|
||||||
)
|
|
||||||
|
|
||||||
SELECT * FROM media WHERE media.album_id IN (
|
|
||||||
SELECT album_id FROM sub_albums
|
|
||||||
) AND media.media_id IN (
|
|
||||||
SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id
|
|
||||||
) LIMIT 1
|
|
||||||
`, obj.AlbumID)
|
|
||||||
|
|
||||||
media, err := models.NewMediaFromRow(row)
|
|
||||||
if err != nil {
|
|
||||||
if err == sql.ErrNoRows {
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
} else {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return media, nil
|
// row := r.Database.QueryRow(`
|
||||||
|
// WITH recursive sub_albums AS (
|
||||||
|
// SELECT * FROM album AS root WHERE album_id = ?
|
||||||
|
// UNION ALL
|
||||||
|
// SELECT child.* FROM album AS child JOIN sub_albums ON child.parent_album = sub_albums.album_id
|
||||||
|
// )
|
||||||
|
|
||||||
|
// SELECT * FROM media WHERE media.album_id IN (
|
||||||
|
// SELECT album_id FROM sub_albums
|
||||||
|
// ) AND media.media_id IN (
|
||||||
|
// SELECT media_id FROM media_url WHERE media_url.media_id = media.media_id
|
||||||
|
// ) LIMIT 1
|
||||||
|
// `, obj.AlbumID)
|
||||||
|
|
||||||
|
// media, err := models.NewMediaFromRow(row)
|
||||||
|
// if err != nil {
|
||||||
|
// if err == sql.ErrNoRows {
|
||||||
|
// return nil, nil
|
||||||
|
// } else {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return media, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *albumResolver) SubAlbums(ctx context.Context, obj *models.Album, filter *models.Filter) ([]*models.Album, error) {
|
func (r *albumResolver) SubAlbums(ctx context.Context, parent *models.Album, filter *models.Filter) ([]*models.Album, error) {
|
||||||
filterSQL, err := filter.FormatSQL("album")
|
|
||||||
if err != nil {
|
var albums []*models.Album
|
||||||
|
if err := r.Database.Where("parent_album = ?", parent.ID).Find(albums).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rows, err := r.Database.Query("SELECT * FROM album WHERE parent_album = ?"+filterSQL, obj.AlbumID)
|
// TODO: Incorporate filter.FormatSQL
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
albums, err := models.NewAlbumsFromRows(rows)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return albums, nil
|
return albums, nil
|
||||||
}
|
}
|
||||||
|
@ -164,34 +135,38 @@ func (r *albumResolver) Owner(ctx context.Context, obj *models.Album) (*models.U
|
||||||
panic("not implemented")
|
panic("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *albumResolver) Shares(ctx context.Context, obj *models.Album) ([]*models.ShareToken, error) {
|
func (r *albumResolver) Shares(ctx context.Context, album *models.Album) ([]*models.ShareToken, error) {
|
||||||
rows, err := r.Database.Query("SELECT * FROM share_token WHERE album_id = ?", obj.ID())
|
|
||||||
if err != nil {
|
var shareTokens []*models.ShareToken
|
||||||
|
if err := r.Database.Where("album_id = ?", album.ID).Find(shareTokens).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
return models.NewShareTokensFromRows(rows)
|
return shareTokens, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *albumResolver) Path(ctx context.Context, obj *models.Album) ([]*models.Album, error) {
|
func (r *albumResolver) Path(ctx context.Context, obj *models.Album) ([]*models.Album, error) {
|
||||||
user := auth.UserFromContext(ctx)
|
|
||||||
if user == nil {
|
|
||||||
empty := make([]*models.Album, 0)
|
|
||||||
return empty, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
rows, err := r.Database.Query(`
|
fmt.Println("TODO: Album path not migrated yet")
|
||||||
WITH recursive path_albums AS (
|
|
||||||
SELECT * FROM album anchor WHERE anchor.album_id = ?
|
|
||||||
UNION
|
|
||||||
SELECT parent.* FROM path_albums child JOIN album parent ON parent.album_id = child.parent_album
|
|
||||||
)
|
|
||||||
SELECT * FROM path_albums WHERE album_id != ? AND owner_id = ?
|
|
||||||
`, obj.AlbumID, obj.AlbumID, user.UserID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return models.NewAlbumsFromRows(rows)
|
return make([]*models.Album, 0), nil
|
||||||
|
// user := auth.UserFromContext(ctx)
|
||||||
|
// if user == nil {
|
||||||
|
// empty := make([]*models.Album, 0)
|
||||||
|
// return empty, nil
|
||||||
|
// }
|
||||||
|
|
||||||
|
// rows, err := r.Database.Query(`
|
||||||
|
// WITH recursive path_albums AS (
|
||||||
|
// SELECT * FROM album anchor WHERE anchor.album_id = ?
|
||||||
|
// UNION
|
||||||
|
// SELECT parent.* FROM path_albums child JOIN album parent ON parent.album_id = child.parent_album
|
||||||
|
// )
|
||||||
|
// SELECT * FROM path_albums WHERE album_id != ? AND owner_id = ?
|
||||||
|
// `, obj.AlbumID, obj.AlbumID, user.UserID)
|
||||||
|
// if err != nil {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return models.NewAlbumsFromRows(rows)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,7 @@ package resolvers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
|
||||||
|
|
||||||
"github.com/viktorstrate/photoview/api/graphql/auth"
|
|
||||||
"github.com/viktorstrate/photoview/api/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type geoJSONFeatureCollection struct {
|
type geoJSONFeatureCollection struct {
|
||||||
|
@ -62,69 +57,71 @@ func makeGeoJSONFeatureGeometryPoint(lat float64, long float64) geoJSONFeatureGe
|
||||||
|
|
||||||
func (r *queryResolver) MyMediaGeoJSON(ctx context.Context) (interface{}, error) {
|
func (r *queryResolver) MyMediaGeoJSON(ctx context.Context) (interface{}, error) {
|
||||||
|
|
||||||
user := auth.UserFromContext(ctx)
|
// user := auth.UserFromContext(ctx)
|
||||||
if user == nil {
|
// if user == nil {
|
||||||
return nil, errors.New("unauthorized")
|
// return nil, errors.New("unauthorized")
|
||||||
}
|
// }
|
||||||
|
|
||||||
rows, err := r.Database.Query(`
|
// rows, err := r.Database.Query(`
|
||||||
SELECT media.media_id, media.title,
|
// SELECT media.media_id, media.title,
|
||||||
url.media_name AS thumbnail_name, url.width AS thumbnail_width, url.height AS thumbnail_height,
|
// url.media_name AS thumbnail_name, url.width AS thumbnail_width, url.height AS thumbnail_height,
|
||||||
exif.gps_latitude, exif.gps_longitude FROM media_exif exif
|
// exif.gps_latitude, exif.gps_longitude FROM media_exif exif
|
||||||
INNER JOIN media ON exif.exif_id = media.exif_id
|
// INNER JOIN media ON exif.exif_id = media.exif_id
|
||||||
INNER JOIN media_url url ON media.media_id = url.media_id
|
// INNER JOIN media_url url ON media.media_id = url.media_id
|
||||||
INNER JOIN album ON media.album_id = album.album_id
|
// INNER JOIN album ON media.album_id = album.album_id
|
||||||
WHERE exif.gps_latitude IS NOT NULL
|
// WHERE exif.gps_latitude IS NOT NULL
|
||||||
AND exif.gps_longitude IS NOT NULL
|
// AND exif.gps_longitude IS NOT NULL
|
||||||
AND url.purpose = 'thumbnail'
|
// AND url.purpose = 'thumbnail'
|
||||||
AND album.owner_id = ?;
|
// AND album.owner_id = ?;
|
||||||
`, user.UserID)
|
// `, user.UserID)
|
||||||
defer rows.Close()
|
// defer rows.Close()
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
features := make([]geoJSONFeature, 0)
|
// features := make([]geoJSONFeature, 0)
|
||||||
|
|
||||||
for rows.Next() {
|
// for rows.Next() {
|
||||||
|
|
||||||
var mediaID int
|
// var mediaID int
|
||||||
var mediaTitle string
|
// var mediaTitle string
|
||||||
var thumbnailName string
|
// var thumbnailName string
|
||||||
var thumbnailWidth int
|
// var thumbnailWidth int
|
||||||
var thumbnailHeight int
|
// var thumbnailHeight int
|
||||||
var latitude float64
|
// var latitude float64
|
||||||
var longitude float64
|
// var longitude float64
|
||||||
|
|
||||||
if err := rows.Scan(&mediaID, &mediaTitle, &thumbnailName, &thumbnailWidth, &thumbnailHeight, &latitude, &longitude); err != nil {
|
// if err := rows.Scan(&mediaID, &mediaTitle, &thumbnailName, &thumbnailWidth, &thumbnailHeight, &latitude, &longitude); err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
geoPoint := makeGeoJSONFeatureGeometryPoint(latitude, longitude)
|
// geoPoint := makeGeoJSONFeatureGeometryPoint(latitude, longitude)
|
||||||
|
|
||||||
thumbnailURL := utils.ApiEndpointUrl()
|
// thumbnailURL := utils.ApiEndpointUrl()
|
||||||
thumbnailURL.Path = path.Join(thumbnailURL.Path, "photo", thumbnailName)
|
// thumbnailURL.Path = path.Join(thumbnailURL.Path, "photo", thumbnailName)
|
||||||
|
|
||||||
properties := geoJSONMediaProperties{
|
// properties := geoJSONMediaProperties{
|
||||||
MediaID: mediaID,
|
// MediaID: mediaID,
|
||||||
MediaTitle: mediaTitle,
|
// MediaTitle: mediaTitle,
|
||||||
Thumbnail: struct {
|
// Thumbnail: struct {
|
||||||
URL string `json:"url"`
|
// URL string `json:"url"`
|
||||||
Width int `json:"width"`
|
// Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
// Height int `json:"height"`
|
||||||
}{
|
// }{
|
||||||
URL: thumbnailURL.String(),
|
// URL: thumbnailURL.String(),
|
||||||
Width: thumbnailWidth,
|
// Width: thumbnailWidth,
|
||||||
Height: thumbnailHeight,
|
// Height: thumbnailHeight,
|
||||||
},
|
// },
|
||||||
}
|
// }
|
||||||
|
|
||||||
features = append(features, makeGeoJSONFeature(properties, geoPoint))
|
// features = append(features, makeGeoJSONFeature(properties, geoPoint))
|
||||||
}
|
// }
|
||||||
|
|
||||||
featureCollection := makeGeoJSONFeatureCollection(features)
|
// featureCollection := makeGeoJSONFeatureCollection(features)
|
||||||
|
|
||||||
return featureCollection, nil
|
// return featureCollection, nil
|
||||||
|
|
||||||
|
panic("to be migrated")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *queryResolver) MapboxToken(ctx context.Context) (*string, error) {
|
func (r *queryResolver) MapboxToken(ctx context.Context) (*string, error) {
|
||||||
|
|
|
@ -3,71 +3,70 @@ package resolvers
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/viktorstrate/photoview/api/graphql/auth"
|
|
||||||
"github.com/viktorstrate/photoview/api/graphql/models"
|
"github.com/viktorstrate/photoview/api/graphql/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (r *Resolver) Search(ctx context.Context, query string, _limitMedia *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)
|
// user := auth.UserFromContext(ctx)
|
||||||
if user == nil {
|
// if user == nil {
|
||||||
return nil, auth.ErrUnauthorized
|
// return nil, auth.ErrUnauthorized
|
||||||
}
|
// }
|
||||||
|
|
||||||
limitMedia := 10
|
// limitMedia := 10
|
||||||
limitAlbums := 10
|
// limitAlbums := 10
|
||||||
|
|
||||||
if _limitMedia != nil {
|
// if _limitMedia != nil {
|
||||||
limitMedia = *_limitMedia
|
// limitMedia = *_limitMedia
|
||||||
}
|
// }
|
||||||
|
|
||||||
if _limitAlbums != nil {
|
// if _limitAlbums != nil {
|
||||||
limitAlbums = *_limitAlbums
|
// limitAlbums = *_limitAlbums
|
||||||
}
|
// }
|
||||||
|
|
||||||
wildQuery := "%" + query + "%"
|
// wildQuery := "%" + query + "%"
|
||||||
|
|
||||||
photoRows, err := r.Database.Query(`
|
// photoRows, err := r.Database.Query(`
|
||||||
SELECT media.* FROM media JOIN album ON media.album_id = album.album_id
|
// 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 ? )
|
// WHERE album.owner_id = ? AND ( media.title LIKE ? OR media.path LIKE ? )
|
||||||
ORDER BY (
|
// ORDER BY (
|
||||||
case when media.title LIKE ? then 2
|
// case when media.title LIKE ? then 2
|
||||||
when media.path LIKE ? then 1
|
// when media.path LIKE ? then 1
|
||||||
end ) DESC
|
// end ) DESC
|
||||||
LIMIT ?
|
// LIMIT ?
|
||||||
`, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitMedia)
|
// `, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitMedia)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, errors.Wrapf(err, "searching media")
|
// return nil, errors.Wrapf(err, "searching media")
|
||||||
}
|
// }
|
||||||
|
|
||||||
photos, err := models.NewMediaFromRows(photoRows)
|
// photos, err := models.NewMediaFromRows(photoRows)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
albumRows, err := r.Database.Query(`
|
// albumRows, err := r.Database.Query(`
|
||||||
SELECT * FROM album
|
// SELECT * FROM album
|
||||||
WHERE owner_id = ? AND ( title LIKE ? OR path LIKE ? )
|
// WHERE owner_id = ? AND ( title LIKE ? OR path LIKE ? )
|
||||||
ORDER BY (
|
// ORDER BY (
|
||||||
case when title LIKE ? then 2
|
// case when title LIKE ? then 2
|
||||||
when path LIKE ? then 1
|
// when path LIKE ? then 1
|
||||||
end ) DESC
|
// end ) DESC
|
||||||
LIMIT ?
|
// LIMIT ?
|
||||||
`, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitAlbums)
|
// `, user.UserID, wildQuery, wildQuery, wildQuery, wildQuery, limitAlbums)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, errors.Wrapf(err, "searching albums")
|
// return nil, errors.Wrapf(err, "searching albums")
|
||||||
}
|
// }
|
||||||
|
|
||||||
albums, err := models.NewAlbumsFromRows(albumRows)
|
// albums, err := models.NewAlbumsFromRows(albumRows)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return nil, err
|
// return nil, err
|
||||||
}
|
// }
|
||||||
|
|
||||||
result := models.SearchResult{
|
// result := models.SearchResult{
|
||||||
Query: query,
|
// Query: query,
|
||||||
Media: photos,
|
// Media: photos,
|
||||||
Albums: albums,
|
// Albums: albums,
|
||||||
}
|
// }
|
||||||
|
|
||||||
return &result, nil
|
// return &result, nil
|
||||||
|
panic("to be migrated")
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ func (r *queryResolver) ShareTokenValidatePassword(ctx context.Context, tokenVal
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mutationResolver) ShareAlbum(ctx context.Context, albumID uint, expire *time.Time, password *string) (*models.ShareToken, error) {
|
func (r *mutationResolver) ShareAlbum(ctx context.Context, albumID int, expire *time.Time, password *string) (*models.ShareToken, error) {
|
||||||
user := auth.UserFromContext(ctx)
|
user := auth.UserFromContext(ctx)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, auth.ErrUnauthorized
|
return nil, auth.ErrUnauthorized
|
||||||
|
@ -152,7 +152,7 @@ func (r *mutationResolver) ShareAlbum(ctx context.Context, albumID uint, expire
|
||||||
return &shareToken, nil
|
return &shareToken, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mutationResolver) ShareMedia(ctx context.Context, mediaID uint, 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)
|
user := auth.UserFromContext(ctx)
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return nil, auth.ErrUnauthorized
|
return nil, auth.ErrUnauthorized
|
||||||
|
|
|
@ -34,15 +34,15 @@ type Query {
|
||||||
onlyWithFavorites: Boolean
|
onlyWithFavorites: Boolean
|
||||||
): [Album!]!
|
): [Album!]!
|
||||||
"Get album by id, user must own the album or be admin"
|
"Get album by id, user must own the album or be admin"
|
||||||
album(id: Int!): Album!
|
album(id: ID!): Album!
|
||||||
|
|
||||||
"List of media owned by the logged in user"
|
"List of media owned by the logged in user"
|
||||||
myMedia(filter: Filter): [Media!]!
|
myMedia(filter: Filter): [Media!]!
|
||||||
"Get media by id, user must own the media or be admin"
|
"Get media by id, user must own the media or be admin"
|
||||||
media(id: Int!): Media!
|
media(id: ID!): Media!
|
||||||
|
|
||||||
"Get a list of media by their ids, user must own the media or be admin"
|
"Get a list of media by their ids, user must own the media or be admin"
|
||||||
mediaList(ids: [Int!]!): [Media!]!
|
mediaList(ids: [ID!]!): [Media!]!
|
||||||
|
|
||||||
"Get media owned by the logged in user, returned in GeoJson format"
|
"Get media owned by the logged in user, returned in GeoJson format"
|
||||||
myMediaGeoJson: Any!
|
myMediaGeoJson: Any!
|
||||||
|
@ -75,22 +75,22 @@ type Mutation {
|
||||||
"Scan all users for new media"
|
"Scan all users for new media"
|
||||||
scanAll: ScannerResult! @isAdmin
|
scanAll: ScannerResult! @isAdmin
|
||||||
"Scan a single user for new media"
|
"Scan a single user for new media"
|
||||||
scanUser(userId: Int!): ScannerResult!
|
scanUser(userId: ID!): ScannerResult!
|
||||||
|
|
||||||
"Generate share token for album"
|
"Generate share token for album"
|
||||||
shareAlbum(albumId: Int!, expire: Time, password: String): ShareToken
|
shareAlbum(albumId: ID!, expire: Time, password: String): ShareToken
|
||||||
"Generate share token for media"
|
"Generate share token for media"
|
||||||
shareMedia(mediaId: Int!, expire: Time, password: String): ShareToken
|
shareMedia(mediaId: ID!, expire: Time, password: String): ShareToken
|
||||||
"Delete a share token by it's token value"
|
"Delete a share token by it's token value"
|
||||||
deleteShareToken(token: String!): ShareToken
|
deleteShareToken(token: String!): ShareToken
|
||||||
"Set a password for a token, if null is passed for the password argument, the password will be cleared"
|
"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
|
protectShareToken(token: String!, password: String): ShareToken
|
||||||
|
|
||||||
"Mark or unmark a media as being a favorite"
|
"Mark or unmark a media as being a favorite"
|
||||||
favoriteMedia(mediaId: Int!, favorite: Boolean!): Media
|
favoriteMedia(mediaId: ID!, favorite: Boolean!): Media
|
||||||
|
|
||||||
updateUser(
|
updateUser(
|
||||||
id: Int!
|
id: ID!
|
||||||
username: String
|
username: String
|
||||||
rootPath: String
|
rootPath: String
|
||||||
password: String
|
password: String
|
||||||
|
@ -102,7 +102,7 @@ type Mutation {
|
||||||
password: String
|
password: String
|
||||||
admin: Boolean!
|
admin: Boolean!
|
||||||
): User @isAdmin
|
): User @isAdmin
|
||||||
deleteUser(id: Int!): User @isAdmin
|
deleteUser(id: ID!): User @isAdmin
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Set how often, in seconds, the server should automatically scan for new media,
|
Set how often, in seconds, the server should automatically scan for new media,
|
||||||
|
@ -152,7 +152,7 @@ type ScannerResult {
|
||||||
|
|
||||||
"A token used to publicly access an album or media"
|
"A token used to publicly access an album or media"
|
||||||
type ShareToken {
|
type ShareToken {
|
||||||
id: Int!
|
id: ID!
|
||||||
token: String!
|
token: String!
|
||||||
"The user who created the token"
|
"The user who created the token"
|
||||||
owner: User!
|
owner: User!
|
||||||
|
@ -177,7 +177,7 @@ type SiteInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
type User {
|
type User {
|
||||||
id: Int!
|
id: ID!
|
||||||
username: String!
|
username: String!
|
||||||
#albums: [Album]
|
#albums: [Album]
|
||||||
"Local filepath for the user's photos"
|
"Local filepath for the user's photos"
|
||||||
|
@ -187,7 +187,7 @@ type User {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Album {
|
type Album {
|
||||||
id: Int!
|
id: ID!
|
||||||
title: String!
|
title: String!
|
||||||
"The media inside this album"
|
"The media inside this album"
|
||||||
media(
|
media(
|
||||||
|
@ -232,7 +232,7 @@ enum MediaType {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Media {
|
type Media {
|
||||||
id: Int!
|
id: ID!
|
||||||
title: String!
|
title: String!
|
||||||
"Local filepath for the media"
|
"Local filepath for the media"
|
||||||
path: String!
|
path: String!
|
||||||
|
@ -255,7 +255,7 @@ type Media {
|
||||||
|
|
||||||
"EXIF metadata from the camera"
|
"EXIF metadata from the camera"
|
||||||
type MediaEXIF {
|
type MediaEXIF {
|
||||||
id: Int!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
"The model name of the camera"
|
"The model name of the camera"
|
||||||
camera: String
|
camera: String
|
||||||
|
@ -279,14 +279,14 @@ type MediaEXIF {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VideoMetadata {
|
type VideoMetadata {
|
||||||
id: Int!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
width: Int!
|
width: Int!
|
||||||
height: Int!
|
height: Int!
|
||||||
duration: Float!
|
duration: Float!
|
||||||
codec: String
|
codec: String
|
||||||
framerate: Float
|
framerate: Float
|
||||||
bitrate: Int
|
bitrate: String
|
||||||
colorProfile: String
|
colorProfile: String
|
||||||
audio: String
|
audio: String
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CleanupMedia(db *gorm.DB, albumId uint, albumMedia []*models.Media) []error {
|
func CleanupMedia(db *gorm.DB, albumId int, albumMedia []*models.Media) []error {
|
||||||
albumMediaIds := make([]uint, len(albumMedia))
|
albumMediaIds := make([]int, len(albumMedia))
|
||||||
for i, media := range albumMedia {
|
for i, media := range albumMedia {
|
||||||
albumMediaIds[i] = media.ID
|
albumMediaIds[i] = media.ID
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Higher order function used to check if MediaURL for a given MediaPurpose exists
|
// Higher order function used to check if MediaURL for a given MediaPurpose exists
|
||||||
func makePhotoURLChecker(tx *gorm.DB, mediaID uint) (func(purpose models.MediaPurpose) (*models.MediaURL, error), error) {
|
func makePhotoURLChecker(tx *gorm.DB, mediaID int) (func(purpose models.MediaPurpose) (*models.MediaURL, error), error) {
|
||||||
return func(purpose models.MediaPurpose) (*models.MediaURL, error) {
|
return func(purpose models.MediaPurpose) (*models.MediaURL, error) {
|
||||||
var mediaURL models.MediaURL
|
var mediaURL models.MediaURL
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ func hashSideCarFile(path *string) *string {
|
||||||
return &hash
|
return &hash
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScanMedia(tx *gorm.DB, mediaPath string, albumId uint, cache *AlbumScannerCache) (*models.Media, bool, error) {
|
func ScanMedia(tx *gorm.DB, mediaPath string, albumId int, cache *AlbumScannerCache) (*models.Media, bool, error) {
|
||||||
mediaName := path.Base(mediaPath)
|
mediaName := path.Base(mediaPath)
|
||||||
|
|
||||||
// Check if media already exists
|
// Check if media already exists
|
||||||
|
|
|
@ -28,7 +28,7 @@ func findAlbumsForUser(db *gorm.DB, user *models.User, album_cache *AlbumScanner
|
||||||
|
|
||||||
type scanInfo struct {
|
type scanInfo struct {
|
||||||
path string
|
path string
|
||||||
parentID *uint
|
parentID *int
|
||||||
}
|
}
|
||||||
|
|
||||||
scanQueue := list.New()
|
scanQueue := list.New()
|
||||||
|
|
Loading…
Reference in New Issue