Add Steam integration showing online status and recent games
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Some checks failed
Deploy with Docker Compose / deploy (push) Has been cancelled
Fetches player summary and recently played games from Steam API with 5-minute server-side caching. Displays in the home sidebar with online indicator and game artwork. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -450,6 +450,44 @@ func (r *queryResolver) GiteaFeed(ctx context.Context) (*model.GiteaFeedItem, er
|
||||
return mapGiteaFeed(feed), nil
|
||||
}
|
||||
|
||||
// SteamStatus is the resolver for the steamStatus field.
|
||||
func (r *queryResolver) SteamStatus(ctx context.Context) (*model.SteamStatus, error) {
|
||||
if r.Store.SteamAPIKey == "" {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if r.Store.SteamFresh() {
|
||||
return &model.SteamStatus{
|
||||
Online: r.Store.SteamOnline,
|
||||
RecentGames: mapSteamGames(r.Store.SteamRecentGames),
|
||||
}, nil
|
||||
}
|
||||
|
||||
games, err := services.FetchRecentlyPlayedGames(r.Store.SteamAPIKey, r.Store.SteamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
summary, err := services.FetchPlayerSummary(r.Store.SteamAPIKey, r.Store.SteamID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
online := false
|
||||
if summary != nil {
|
||||
online = summary.PersonaState > 0
|
||||
}
|
||||
|
||||
r.Store.SteamRecentGames = games
|
||||
r.Store.SteamOnline = online
|
||||
r.Store.SteamFetchedAt = time.Now()
|
||||
|
||||
return &model.SteamStatus{
|
||||
Online: online,
|
||||
RecentGames: mapSteamGames(games),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Me is the resolver for the me field.
|
||||
func (r *queryResolver) Me(ctx context.Context) (*models.User, error) {
|
||||
userID, ok := UserIDFromCtx(ctx)
|
||||
|
||||
Reference in New Issue
Block a user