api

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefFormExplicitKey   = "explicit"
	PrefFormSongLengthKey = "song-length"
)
View Source
const (
	SongRequestsTitle = "TwitchSongRequests"
)

Variables

This section is empty.

Functions

func DoNothingOnSuccess

func DoNothingOnSuccess(auth *util.AuthConfig,
	userStore db.UserStore,
	event *helix.EventSubChannelPointsCustomRewardRedemptionEvent,
	success bool) error

DoNothingOnSuccess is a no-op to satisfy the function interface. See https://github.com/SaxyPandaBear/TwitchSongRequests/issues/133

func IsRevocationRequest

func IsRevocationRequest(r *http.Request) bool

func IsValidReward

func IsValidReward(e *helix.EventSubChannelPointsCustomRewardRedemptionEvent, p *preferences.Preference) bool

IsValidReward ensures that the redemption event is a valid event that we want to consume. Original implementation relies on the existence of a key word in the reward title. New implementation verifies with the stored CustomRewardID for a user's preference.

func IsVerificationRequest

func IsVerificationRequest(r *http.Request) bool

func UpdateRedemptionStatus

func UpdateRedemptionStatus(auth *util.AuthConfig,
	userStore db.UserStore,
	event *helix.EventSubChannelPointsCustomRewardRedemptionEvent,
	success bool) error

UpdateRedemptionStatus attempts to update the status for the channel point redemption. This is helpful so failed submissions should get refunded.

Types

type EventSubHandler

type EventSubHandler struct {
	// contains filtered or unexported fields
}

func NewEventSubHandler

func NewEventSubHandler(u db.UserStore, p db.PreferenceStore, auth *util.AuthConfig, callbackURL, secret string) *EventSubHandler

func (*EventSubHandler) SubscribeToTopic

func (e *EventSubHandler) SubscribeToTopic(w http.ResponseWriter, r *http.Request)

SubscribeToTopic

type EventSubNotification

type EventSubNotification struct {
	Subscription helix.EventSubSubscription `json:"subscription"`
	Challenge    string                     `json:"challenge"`
	Event        json.RawMessage            `json:"event"`
}

type PreferenceHandler

type PreferenceHandler struct {
	// contains filtered or unexported fields
}

func NewPreferenceHandler

func NewPreferenceHandler(d db.PreferenceStore, redirectURL string) *PreferenceHandler

func (*PreferenceHandler) SavePreferences

func (h *PreferenceHandler) SavePreferences(w http.ResponseWriter, r *http.Request)

type RewardHandler

type RewardHandler struct {

	// OnSuccess is a callback function that executes after successfully
	// publishing to the queue
	OnSuccess func(*util.AuthConfig, db.UserStore, *helix.EventSubChannelPointsCustomRewardRedemptionEvent, bool) error
	// contains filtered or unexported fields
}

func NewRewardHandler

func NewRewardHandler(config *RewardHandlerConfig) *RewardHandler

func (*RewardHandler) ChannelPointRedeem

func (h *RewardHandler) ChannelPointRedeem(w http.ResponseWriter, r *http.Request)

type RewardHandlerConfig

type RewardHandlerConfig struct {
	Secret    string
	Publisher queue.Publisher
	UserStore db.UserStore
	PrefStore db.PreferenceStore
	MsgCount  db.MessageCounter
	Twitch    *util.AuthConfig
	Spotify   *util.AuthConfig
}

type SpotifyAuthZHandler

type SpotifyAuthZHandler struct {
	// contains filtered or unexported fields
}

func NewSpotifyAuthZHandler

func NewSpotifyAuthZHandler(url string, auth *util.AuthConfig, userStore db.UserStore) *SpotifyAuthZHandler

type StatsHandler

type StatsHandler struct {
	NumOnboarded uint
	NumAllowed   uint
	// contains filtered or unexported fields
}

func NewStatsHandler

func NewStatsHandler(counter db.MessageCounter, onboarded, allowed uint) *StatsHandler

func (*StatsHandler) Onboarded added in v1.3.1

func (h *StatsHandler) Onboarded(w http.ResponseWriter, r *http.Request)

func (*StatsHandler) RunningCount

func (h *StatsHandler) RunningCount(w http.ResponseWriter, r *http.Request)

func (*StatsHandler) TotalMessages

func (h *StatsHandler) TotalMessages(w http.ResponseWriter, r *http.Request)

type SubscribeRequest

type SubscribeRequest struct {
	UserID string `json:"user_id"`
}

type SvgData

type SvgData struct {
	SchemaVersion int    `json:"schemaVersion"`
	Label         string `json:"label"`
	Message       string `json:"message"`
	Color         string `json:"color"`
	Style         string `json:"style"`
	CacheSeconds  int    `json:"cacheSeconds"`
}

https://shields.io/endpoint schema

type TwitchAuthZHandler

type TwitchAuthZHandler struct {
	// contains filtered or unexported fields
}

func NewTwitchAuthZHandler

func NewTwitchAuthZHandler(url string, auth *util.AuthConfig, userStore db.UserStore, prefStore db.PreferenceStore) *TwitchAuthZHandler

func (*TwitchAuthZHandler) Authorize

func (h *TwitchAuthZHandler) Authorize(w http.ResponseWriter, r *http.Request)

Authorize handles the callback from the OAuth authorization

type UserHandler

type UserHandler struct {
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(d db.UserStore, p db.PreferenceStore, redirectURL string, twitch, spotify *util.AuthConfig) *UserHandler

func (*UserHandler) RevokeUserAccesses

func (h *UserHandler) RevokeUserAccesses(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL