精简后的项目:仅保留 api/ui 源码、文档、构建依赖

This commit is contained in:
gallery
2026-09-11 16:11:09 +08:00
commit 490e85634e
457 changed files with 86862 additions and 0 deletions
+224
View File
@@ -0,0 +1,224 @@
// Code generated by github.com/vektah/dataloaden, DO NOT EDIT.
package dataloader
import (
"sync"
"time"
"github.com/photoview/photoview/api/graphql/models"
)
// MediaURLLoaderConfig captures the config to create a new MediaURLLoader
type MediaURLLoaderConfig struct {
// Fetch is a method that provides the data for the loader
Fetch func(keys []int) ([]*models.MediaURL, []error)
// Wait is how long wait before sending a batch
Wait time.Duration
// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
MaxBatch int
}
// NewMediaURLLoader creates a new MediaURLLoader given a fetch, wait, and maxBatch
func NewMediaURLLoader(config MediaURLLoaderConfig) *MediaURLLoader {
return &MediaURLLoader{
fetch: config.Fetch,
wait: config.Wait,
maxBatch: config.MaxBatch,
}
}
// MediaURLLoader batches and caches requests
type MediaURLLoader struct {
// this method provides the data for the loader
fetch func(keys []int) ([]*models.MediaURL, []error)
// how long to done before sending a batch
wait time.Duration
// this will limit the maximum number of keys to send in one batch, 0 = no limit
maxBatch int
// INTERNAL
// lazily created cache
cache map[int]*models.MediaURL
// the current batch. keys will continue to be collected until timeout is hit,
// then everything will be sent to the fetch method and out to the listeners
batch *mediaURLLoaderBatch
// mutex to prevent races
mu sync.Mutex
}
type mediaURLLoaderBatch struct {
keys []int
data []*models.MediaURL
error []error
closing bool
done chan struct{}
}
// Load a MediaURL by key, batching and caching will be applied automatically
func (l *MediaURLLoader) Load(key int) (*models.MediaURL, error) {
return l.LoadThunk(key)()
}
// LoadThunk returns a function that when called will block waiting for a MediaURL.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *MediaURLLoader) LoadThunk(key int) func() (*models.MediaURL, error) {
l.mu.Lock()
if it, ok := l.cache[key]; ok {
l.mu.Unlock()
return func() (*models.MediaURL, error) {
return it, nil
}
}
if l.batch == nil {
l.batch = &mediaURLLoaderBatch{done: make(chan struct{})}
}
batch := l.batch
pos := batch.keyIndex(l, key)
l.mu.Unlock()
return func() (*models.MediaURL, error) {
<-batch.done
var data *models.MediaURL
if pos < len(batch.data) {
data = batch.data[pos]
}
var err error
// its convenient to be able to return a single error for everything
if len(batch.error) == 1 {
err = batch.error[0]
} else if batch.error != nil {
err = batch.error[pos]
}
if err == nil {
l.mu.Lock()
l.unsafeSet(key, data)
l.mu.Unlock()
}
return data, err
}
}
// LoadAll fetches many keys at once. It will be broken into appropriate sized
// sub batches depending on how the loader is configured
func (l *MediaURLLoader) LoadAll(keys []int) ([]*models.MediaURL, []error) {
results := make([]func() (*models.MediaURL, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
mediaURLs := make([]*models.MediaURL, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
mediaURLs[i], errors[i] = thunk()
}
return mediaURLs, errors
}
// LoadAllThunk returns a function that when called will block waiting for a MediaURLs.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *MediaURLLoader) LoadAllThunk(keys []int) func() ([]*models.MediaURL, []error) {
results := make([]func() (*models.MediaURL, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
return func() ([]*models.MediaURL, []error) {
mediaURLs := make([]*models.MediaURL, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
mediaURLs[i], errors[i] = thunk()
}
return mediaURLs, errors
}
}
// Prime the cache with the provided key and value. If the key already exists, no change is made
// and false is returned.
// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)
func (l *MediaURLLoader) Prime(key int, value *models.MediaURL) bool {
l.mu.Lock()
var found bool
if _, found = l.cache[key]; !found {
// make a copy when writing to the cache, its easy to pass a pointer in from a loop var
// and end up with the whole cache pointing to the same value.
cpy := *value
l.unsafeSet(key, &cpy)
}
l.mu.Unlock()
return !found
}
// Clear the value at key from the cache, if it exists
func (l *MediaURLLoader) Clear(key int) {
l.mu.Lock()
delete(l.cache, key)
l.mu.Unlock()
}
func (l *MediaURLLoader) unsafeSet(key int, value *models.MediaURL) {
if l.cache == nil {
l.cache = map[int]*models.MediaURL{}
}
l.cache[key] = value
}
// keyIndex will return the location of the key in the batch, if its not found
// it will add the key to the batch
func (b *mediaURLLoaderBatch) keyIndex(l *MediaURLLoader, key int) int {
for i, existingKey := range b.keys {
if key == existingKey {
return i
}
}
pos := len(b.keys)
b.keys = append(b.keys, key)
if pos == 0 {
go b.startTimer(l)
}
if l.maxBatch != 0 && pos >= l.maxBatch-1 {
if !b.closing {
b.closing = true
l.batch = nil
go b.end(l)
}
}
return pos
}
func (b *mediaURLLoaderBatch) startTimer(l *MediaURLLoader) {
time.Sleep(l.wait)
l.mu.Lock()
// we must have hit a batch limit and are already finalizing this batch
if b.closing {
l.mu.Unlock()
return
}
l.batch = nil
l.mu.Unlock()
b.end(l)
}
func (b *mediaURLLoaderBatch) end(l *MediaURLLoader) {
b.data, b.error = l.fetch(b.keys)
close(b.done)
}
+221
View File
@@ -0,0 +1,221 @@
// Code generated by github.com/vektah/dataloaden, DO NOT EDIT.
package dataloader
import (
"sync"
"time"
"github.com/photoview/photoview/api/graphql/models"
)
// UserFavoritesLoaderConfig captures the config to create a new UserFavoritesLoader
type UserFavoritesLoaderConfig struct {
// Fetch is a method that provides the data for the loader
Fetch func(keys []*models.UserMediaData) ([]bool, []error)
// Wait is how long wait before sending a batch
Wait time.Duration
// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
MaxBatch int
}
// NewUserFavoritesLoader creates a new UserFavoritesLoader given a fetch, wait, and maxBatch
func NewUserFavoritesLoader(config UserFavoritesLoaderConfig) *UserFavoritesLoader {
return &UserFavoritesLoader{
fetch: config.Fetch,
wait: config.Wait,
maxBatch: config.MaxBatch,
}
}
// UserFavoritesLoader batches and caches requests
type UserFavoritesLoader struct {
// this method provides the data for the loader
fetch func(keys []*models.UserMediaData) ([]bool, []error)
// how long to done before sending a batch
wait time.Duration
// this will limit the maximum number of keys to send in one batch, 0 = no limit
maxBatch int
// INTERNAL
// lazily created cache
cache map[*models.UserMediaData]bool
// the current batch. keys will continue to be collected until timeout is hit,
// then everything will be sent to the fetch method and out to the listeners
batch *userFavoritesLoaderBatch
// mutex to prevent races
mu sync.Mutex
}
type userFavoritesLoaderBatch struct {
keys []*models.UserMediaData
data []bool
error []error
closing bool
done chan struct{}
}
// Load a bool by key, batching and caching will be applied automatically
func (l *UserFavoritesLoader) Load(key *models.UserMediaData) (bool, error) {
return l.LoadThunk(key)()
}
// LoadThunk returns a function that when called will block waiting for a bool.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *UserFavoritesLoader) LoadThunk(key *models.UserMediaData) func() (bool, error) {
l.mu.Lock()
if it, ok := l.cache[key]; ok {
l.mu.Unlock()
return func() (bool, error) {
return it, nil
}
}
if l.batch == nil {
l.batch = &userFavoritesLoaderBatch{done: make(chan struct{})}
}
batch := l.batch
pos := batch.keyIndex(l, key)
l.mu.Unlock()
return func() (bool, error) {
<-batch.done
var data bool
if pos < len(batch.data) {
data = batch.data[pos]
}
var err error
// its convenient to be able to return a single error for everything
if len(batch.error) == 1 {
err = batch.error[0]
} else if batch.error != nil {
err = batch.error[pos]
}
if err == nil {
l.mu.Lock()
l.unsafeSet(key, data)
l.mu.Unlock()
}
return data, err
}
}
// LoadAll fetches many keys at once. It will be broken into appropriate sized
// sub batches depending on how the loader is configured
func (l *UserFavoritesLoader) LoadAll(keys []*models.UserMediaData) ([]bool, []error) {
results := make([]func() (bool, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
bools := make([]bool, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
bools[i], errors[i] = thunk()
}
return bools, errors
}
// LoadAllThunk returns a function that when called will block waiting for a bools.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *UserFavoritesLoader) LoadAllThunk(keys []*models.UserMediaData) func() ([]bool, []error) {
results := make([]func() (bool, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
return func() ([]bool, []error) {
bools := make([]bool, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
bools[i], errors[i] = thunk()
}
return bools, errors
}
}
// Prime the cache with the provided key and value. If the key already exists, no change is made
// and false is returned.
// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)
func (l *UserFavoritesLoader) Prime(key *models.UserMediaData, value bool) bool {
l.mu.Lock()
var found bool
if _, found = l.cache[key]; !found {
l.unsafeSet(key, value)
}
l.mu.Unlock()
return !found
}
// Clear the value at key from the cache, if it exists
func (l *UserFavoritesLoader) Clear(key *models.UserMediaData) {
l.mu.Lock()
delete(l.cache, key)
l.mu.Unlock()
}
func (l *UserFavoritesLoader) unsafeSet(key *models.UserMediaData, value bool) {
if l.cache == nil {
l.cache = map[*models.UserMediaData]bool{}
}
l.cache[key] = value
}
// keyIndex will return the location of the key in the batch, if its not found
// it will add the key to the batch
func (b *userFavoritesLoaderBatch) keyIndex(l *UserFavoritesLoader, key *models.UserMediaData) int {
for i, existingKey := range b.keys {
if key == existingKey {
return i
}
}
pos := len(b.keys)
b.keys = append(b.keys, key)
if pos == 0 {
go b.startTimer(l)
}
if l.maxBatch != 0 && pos >= l.maxBatch-1 {
if !b.closing {
b.closing = true
l.batch = nil
go b.end(l)
}
}
return pos
}
func (b *userFavoritesLoaderBatch) startTimer(l *UserFavoritesLoader) {
time.Sleep(l.wait)
l.mu.Lock()
// we must have hit a batch limit and are already finalizing this batch
if b.closing {
l.mu.Unlock()
return
}
l.batch = nil
l.mu.Unlock()
b.end(l)
}
func (b *userFavoritesLoaderBatch) end(l *UserFavoritesLoader) {
b.data, b.error = l.fetch(b.keys)
close(b.done)
}
+224
View File
@@ -0,0 +1,224 @@
// Code generated by github.com/vektah/dataloaden, DO NOT EDIT.
package dataloader
import (
"sync"
"time"
"github.com/photoview/photoview/api/graphql/models"
)
// UserLoaderConfig captures the config to create a new UserLoader
type UserLoaderConfig struct {
// Fetch is a method that provides the data for the loader
Fetch func(keys []string) ([]*models.User, []error)
// Wait is how long wait before sending a batch
Wait time.Duration
// MaxBatch will limit the maximum number of keys to send in one batch, 0 = not limit
MaxBatch int
}
// NewUserLoader creates a new UserLoader given a fetch, wait, and maxBatch
func NewUserLoader(config UserLoaderConfig) *UserLoader {
return &UserLoader{
fetch: config.Fetch,
wait: config.Wait,
maxBatch: config.MaxBatch,
}
}
// UserLoader batches and caches requests
type UserLoader struct {
// this method provides the data for the loader
fetch func(keys []string) ([]*models.User, []error)
// how long to done before sending a batch
wait time.Duration
// this will limit the maximum number of keys to send in one batch, 0 = no limit
maxBatch int
// INTERNAL
// lazily created cache
cache map[string]*models.User
// the current batch. keys will continue to be collected until timeout is hit,
// then everything will be sent to the fetch method and out to the listeners
batch *userLoaderBatch
// mutex to prevent races
mu sync.Mutex
}
type userLoaderBatch struct {
keys []string
data []*models.User
error []error
closing bool
done chan struct{}
}
// Load a User by key, batching and caching will be applied automatically
func (l *UserLoader) Load(key string) (*models.User, error) {
return l.LoadThunk(key)()
}
// LoadThunk returns a function that when called will block waiting for a User.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *UserLoader) LoadThunk(key string) func() (*models.User, error) {
l.mu.Lock()
if it, ok := l.cache[key]; ok {
l.mu.Unlock()
return func() (*models.User, error) {
return it, nil
}
}
if l.batch == nil {
l.batch = &userLoaderBatch{done: make(chan struct{})}
}
batch := l.batch
pos := batch.keyIndex(l, key)
l.mu.Unlock()
return func() (*models.User, error) {
<-batch.done
var data *models.User
if pos < len(batch.data) {
data = batch.data[pos]
}
var err error
// its convenient to be able to return a single error for everything
if len(batch.error) == 1 {
err = batch.error[0]
} else if batch.error != nil {
err = batch.error[pos]
}
if err == nil {
l.mu.Lock()
l.unsafeSet(key, data)
l.mu.Unlock()
}
return data, err
}
}
// LoadAll fetches many keys at once. It will be broken into appropriate sized
// sub batches depending on how the loader is configured
func (l *UserLoader) LoadAll(keys []string) ([]*models.User, []error) {
results := make([]func() (*models.User, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
users := make([]*models.User, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
users[i], errors[i] = thunk()
}
return users, errors
}
// LoadAllThunk returns a function that when called will block waiting for a Users.
// This method should be used if you want one goroutine to make requests to many
// different data loaders without blocking until the thunk is called.
func (l *UserLoader) LoadAllThunk(keys []string) func() ([]*models.User, []error) {
results := make([]func() (*models.User, error), len(keys))
for i, key := range keys {
results[i] = l.LoadThunk(key)
}
return func() ([]*models.User, []error) {
users := make([]*models.User, len(keys))
errors := make([]error, len(keys))
for i, thunk := range results {
users[i], errors[i] = thunk()
}
return users, errors
}
}
// Prime the cache with the provided key and value. If the key already exists, no change is made
// and false is returned.
// (To forcefully prime the cache, clear the key first with loader.clear(key).prime(key, value).)
func (l *UserLoader) Prime(key string, value *models.User) bool {
l.mu.Lock()
var found bool
if _, found = l.cache[key]; !found {
// make a copy when writing to the cache, its easy to pass a pointer in from a loop var
// and end up with the whole cache pointing to the same value.
cpy := *value
l.unsafeSet(key, &cpy)
}
l.mu.Unlock()
return !found
}
// Clear the value at key from the cache, if it exists
func (l *UserLoader) Clear(key string) {
l.mu.Lock()
delete(l.cache, key)
l.mu.Unlock()
}
func (l *UserLoader) unsafeSet(key string, value *models.User) {
if l.cache == nil {
l.cache = map[string]*models.User{}
}
l.cache[key] = value
}
// keyIndex will return the location of the key in the batch, if its not found
// it will add the key to the batch
func (b *userLoaderBatch) keyIndex(l *UserLoader, key string) int {
for i, existingKey := range b.keys {
if key == existingKey {
return i
}
}
pos := len(b.keys)
b.keys = append(b.keys, key)
if pos == 0 {
go b.startTimer(l)
}
if l.maxBatch != 0 && pos >= l.maxBatch-1 {
if !b.closing {
b.closing = true
l.batch = nil
go b.end(l)
}
}
return pos
}
func (b *userLoaderBatch) startTimer(l *UserLoader) {
time.Sleep(l.wait)
l.mu.Lock()
// we must have hit a batch limit and are already finalizing this batch
if b.closing {
l.mu.Unlock()
return
}
l.batch = nil
l.mu.Unlock()
b.end(l)
}
func (b *userLoaderBatch) end(l *UserLoader) {
b.data, b.error = l.fetch(b.keys)
close(b.done)
}
+48
View File
@@ -0,0 +1,48 @@
package dataloader
import (
"context"
"net/http"
"github.com/gorilla/mux"
"gorm.io/gorm"
)
type contextKey string
const loadersKey contextKey = "dataloaders"
type Loaders struct {
MediaThumbnail *MediaURLLoader
MediaHighres *MediaURLLoader
MediaVideoWeb *MediaURLLoader
UserFromAccessToken *UserLoader
UserMediaFavorite *UserFavoritesLoader
}
func Middleware(db *gorm.DB) mux.MiddlewareFunc {
return mux.MiddlewareFunc(func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), loadersKey, &Loaders{
MediaThumbnail: NewThumbnailMediaURLLoader(db),
MediaHighres: NewHighresMediaURLLoader(db),
MediaVideoWeb: NewVideoWebMediaURLLoader(db),
UserFromAccessToken: NewUserLoaderByToken(db),
UserMediaFavorite: NewUserFavoriteLoader(db),
})
r = r.WithContext(ctx)
next.ServeHTTP(w, r)
})
})
}
func For(ctx context.Context) *Loaders {
loaders, ok := ctx.Value(loadersKey).(*Loaders)
if !ok {
return nil
}
return loaders
}
+82
View File
@@ -0,0 +1,82 @@
package dataloader
import (
"time"
"github.com/photoview/photoview/api/graphql/models"
"github.com/photoview/photoview/api/scanner/media_type"
"github.com/pkg/errors"
"gorm.io/gorm"
)
func makeMediaURLLoader(db *gorm.DB, filter func(query *gorm.DB) *gorm.DB) func(keys []int) ([]*models.MediaURL, []error) {
return func(mediaIDs []int) ([]*models.MediaURL, []error) {
var urls []*models.MediaURL
query := db.Where("media_id IN (?)", mediaIDs)
query = filter(query)
if err := query.Find(&urls).Error; err != nil {
return nil, []error{errors.Wrap(err, "media url loader database query")}
}
resultMap := make(map[int]*models.MediaURL, len(mediaIDs))
for _, url := range urls {
resultMap[url.MediaID] = url
}
result := make([]*models.MediaURL, len(mediaIDs))
for i, mediaID := range mediaIDs {
mediaURL, found := resultMap[mediaID]
if found {
result[i] = mediaURL
} else {
result[i] = nil
}
}
return result, nil
}
}
func NewThumbnailMediaURLLoader(db *gorm.DB) *MediaURLLoader {
return &MediaURLLoader{
maxBatch: 100,
wait: 5 * time.Millisecond,
fetch: makeMediaURLLoader(db, func(query *gorm.DB) *gorm.DB {
return query.Where("purpose IN ?", []string{string(models.PhotoThumbnail), string(models.VideoThumbnail)})
}),
}
}
func NewHighresMediaURLLoader(db *gorm.DB) *MediaURLLoader {
return &MediaURLLoader{
maxBatch: 100,
wait: 5 * time.Millisecond,
fetch: makeMediaURLLoader(db, func(query *gorm.DB) *gorm.DB {
return query.
Where("(purpose = ? OR (purpose = ? AND content_type IN ?))", models.PhotoHighRes, models.MediaOriginal, media_type.WebMimetypes).
//PhotoHighRes consistently wins ordering when both exist, which is preferred for web delivery
Order("media_id ASC, CASE purpose WHEN '" +
string(models.MediaOriginal) + "' THEN 0 WHEN '" +
string(models.PhotoHighRes) + "' THEN 1 END ASC")
}),
}
}
func NewVideoWebMediaURLLoader(db *gorm.DB) *MediaURLLoader {
return &MediaURLLoader{
maxBatch: 100,
wait: 5 * time.Millisecond,
fetch: makeMediaURLLoader(db, func(query *gorm.DB) *gorm.DB {
return query.
Where("purpose IN ?", []string{string(models.VideoWeb), string(models.MediaOriginal)}).
//VideoWeb consistently wins ordering when both exist, which is preferred for web delivery
Order("media_id ASC, CASE purpose WHEN '" +
string(models.MediaOriginal) + "' THEN 0 WHEN '" +
string(models.VideoWeb) + "' THEN 1 END ASC")
}),
}
}
+60
View File
@@ -0,0 +1,60 @@
package dataloader
import (
"time"
"github.com/photoview/photoview/api/graphql/models"
"gorm.io/gorm"
)
func NewUserFavoriteLoader(db *gorm.DB) *UserFavoritesLoader {
return &UserFavoritesLoader{
maxBatch: 100,
wait: 5 * time.Millisecond,
fetch: func(keys []*models.UserMediaData) ([]bool, []error) {
userIDMap := make(map[int]struct{}, len(keys))
mediaIDMap := make(map[int]struct{}, len(keys))
for _, key := range keys {
userIDMap[key.UserID] = struct{}{}
mediaIDMap[key.MediaID] = struct{}{}
}
uniqueUserIDs := make([]int, len(userIDMap))
uniqueMediaIDs := make([]int, len(mediaIDMap))
count := 0
for id := range userIDMap {
uniqueUserIDs[count] = id
count++
}
count = 0
for id := range mediaIDMap {
uniqueMediaIDs[count] = id
count++
}
var userMediaFavorites []*models.UserMediaData
err := db.Where("user_id IN (?)", uniqueUserIDs).Where("media_id IN (?)", uniqueMediaIDs).Where("favorite = TRUE").Find(&userMediaFavorites).Error
if err != nil {
return nil, []error{err}
}
result := make([]bool, len(keys))
for i, key := range keys {
favorite := false
for _, fav := range userMediaFavorites {
if fav.UserID == key.UserID && fav.MediaID == key.MediaID {
favorite = true
break
}
}
result[i] = favorite
}
return result, nil
},
}
}
+71
View File
@@ -0,0 +1,71 @@
package dataloader
import (
"time"
"github.com/photoview/photoview/api/graphql/models"
"gorm.io/gorm"
)
func NewUserLoaderByToken(db *gorm.DB) *UserLoader {
return &UserLoader{
maxBatch: 100,
wait: 5 * time.Millisecond,
fetch: func(tokens []string) ([]*models.User, []error) {
var accessTokens []*models.AccessToken
err := db.Where("expire > ?", time.Now()).Where("value IN (?)", tokens).Find(&accessTokens).Error
if err != nil {
return nil, []error{err}
}
rows, err := db.Table("access_tokens").Select("distinct user_id").Where("expire > ?", time.Now()).Where("value IN (?)", tokens).Rows()
if err != nil {
return nil, []error{err}
}
userIDs := make([]int, 0)
for rows.Next() {
var id int
if err := db.ScanRows(rows, &id); err != nil {
return nil, []error{err}
}
userIDs = append(userIDs, id)
}
rows.Close()
var userMap map[int]*models.User
if len(userIDs) > 0 {
var users []*models.User
if err := db.Where("id IN (?)", userIDs).Find(&users).Error; err != nil {
return nil, []error{err}
}
userMap = make(map[int]*models.User, len(users))
for _, user := range users {
userMap[user.ID] = user
}
} else {
userMap = make(map[int]*models.User, 0)
}
tokenMap := make(map[string]*models.AccessToken, len(tokens))
for _, token := range accessTokens {
tokenMap[token.Value] = token
}
result := make([]*models.User, len(tokens))
for i, token := range tokens {
accessToken, tokenFound := tokenMap[token]
if tokenFound {
user, userFound := userMap[accessToken.UserID]
if userFound {
result[i] = user
}
}
}
return result, nil
},
}
}