mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 20:59:03 +00:00
* Bump several API dependencies to the latest versions Bump github.com/stretchr/testify from 1.9.0 to 1.10.0 in /api Bump github.com/vektah/gqlparser/v2 from 2.5.19 to 2.5.20 in /api Bump gorm.io/driver/postgres from 1.5.10 to 1.5.11 in /api Bump golang.org/x/image from 0.22.0 to 0.23.0 in /api Bump golang.org/x/crypto from 0.29.0 to 0.30.0 in /api Bump github.com/99designs/gqlgen from 0.17.56 to 0.17.57 in /api * Regenerate GraphQL code --------- Co-authored-by: Konstantin Koval
39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
package resolvers
|
|
|
|
// This file will be automatically regenerated based on the schema, any resolver implementations
|
|
// will be copied through when generating and any unknown code will be moved to the end.
|
|
// Code generated by github.com/99designs/gqlgen version v0.17.57
|
|
|
|
import (
|
|
"context"
|
|
|
|
api "github.com/photoview/photoview/api/graphql"
|
|
"github.com/photoview/photoview/api/graphql/auth"
|
|
"github.com/photoview/photoview/api/graphql/models"
|
|
"github.com/photoview/photoview/api/graphql/notification"
|
|
)
|
|
|
|
// Notification is the resolver for the notification field.
|
|
func (r *subscriptionResolver) Notification(ctx context.Context) (<-chan *models.Notification, error) {
|
|
user := auth.UserFromContext(ctx)
|
|
if user == nil {
|
|
return nil, auth.ErrUnauthorized
|
|
}
|
|
|
|
notificationChannel := make(chan *models.Notification, 1)
|
|
|
|
listenerID := notification.RegisterListener(user, notificationChannel)
|
|
|
|
go func() {
|
|
<-ctx.Done()
|
|
notification.DeregisterListener(listenerID)
|
|
}()
|
|
|
|
return notificationChannel, nil
|
|
}
|
|
|
|
// Subscription returns api.SubscriptionResolver implementation.
|
|
func (r *Resolver) Subscription() api.SubscriptionResolver { return &subscriptionResolver{r} }
|
|
|
|
type subscriptionResolver struct{ *Resolver }
|