Documentation
¶
Index ¶
- Constants
- Variables
- func CreateTrackRouteID(title, handle string) string
- func GeneratePlaylistSlugAndCollisionID(ctx context.Context, dbtx db.DBTX, ownerID, playlistID int64, name string) (slug, titleSlug string, collisionID int, err error)
- func GenerateSlugAndCollisionID(ctx context.Context, dbtx db.DBTX, ownerID, trackID int64, title string) (slug, titleSlug string, collisionID int, err error)
- func IsValidationError(err error) bool
- func SanitizeSlug(title string, recordID int64, collisionID int) string
- func ValidateAccessConditions(p *Params) error
- func ValidateBio(bio string) error
- func ValidateDescription(desc string) error
- func ValidateGenre(genre string) error
- func ValidateHandle(handle string) error
- func ValidateSigner(ctx context.Context, params *Params) error
- func ValidateUserName(name string) error
- type Dispatcher
- type Handler
- func AssociatedWalletCreate() Handler
- func AssociatedWalletDelete() Handler
- func CommentCreate() Handler
- func CommentDelete() Handler
- func CommentMute() Handler
- func CommentPin() Handler
- func CommentReact() Handler
- func CommentReport() Handler
- func CommentUnmute() Handler
- func CommentUnpin() Handler
- func CommentUnreact() Handler
- func CommentUpdate() Handler
- func DashboardWalletCreate() Handler
- func DashboardWalletDelete() Handler
- func DeveloperAppCreate() Handler
- func DeveloperAppDelete() Handler
- func DeveloperAppUpdate() Handler
- func EmailAccessUpdate() Handler
- func EncryptedEmailCreate() Handler
- func EventCreate() Handler
- func EventDelete() Handler
- func EventUpdate() Handler
- func Follow() Handler
- func GrantApprove() Handler
- func GrantCreate() Handler
- func GrantDelete() Handler
- func GrantReject() Handler
- func MuteUser() Handler
- func NotificationCreate() Handler
- func NotificationView() Handler
- func PlaylistCreate() Handler
- func PlaylistDelete() Handler
- func PlaylistSeenView() Handler
- func PlaylistUpdate() Handler
- func Repost() Handler
- func Save() Handler
- func Share() Handler
- func Subscribe() Handler
- func TipReaction() Handler
- func TrackCreate() Handler
- func TrackDelete() Handler
- func TrackDownload() Handler
- func TrackMute() Handler
- func TrackUnmute() Handler
- func TrackUpdate() Handler
- func Unfollow() Handler
- func UnmuteUser() Handler
- func Unrepost() Handler
- func Unsave() Handler
- func Unsubscribe() Handler
- func UserCreate() Handler
- func UserUpdate() Handler
- func UserVerify() Handler
- type Params
- func (p *Params) MetadataBool(key string) (bool, bool)
- func (p *Params) MetadataBoolOr(key string, def bool) bool
- func (p *Params) MetadataInt64(key string) (int64, bool)
- func (p *Params) MetadataJSON(key string) (any, bool)
- func (p *Params) MetadataString(key string) string
- func (p *Params) Queries() *db.Queries
- type ValidationError
Constants ¶
const ( CharacterLimitAppName = 50 CharacterLimitAppDescription = 160 )
const ( EntityTypeUser = "User" EntityTypeTrack = "Track" EntityTypePlaylist = "Playlist" EntityTypeDashboardWalletUser = "DashboardWalletUser" EntityTypeUserWallet = "UserWallet" EntityTypeFollow = "Follow" EntityTypeSave = "Save" EntityTypeRepost = "Repost" EntityTypeSubscription = "Subscription" EntityTypeNotificationSeen = "NotificationSeen" EntityTypeNotification = "Notification" EntityTypePlaylistSeen = "PlaylistSeen" EntityTypeDeveloperApp = "DeveloperApp" EntityTypeGrant = "Grant" EntityTypeAssociatedWallet = "AssociatedWallet" EntityTypeUserEvent = "UserEvent" EntityTypeStem = "Stem" EntityTypeRemix = "Remix" EntityTypeTrackRoute = "TrackRoute" EntityTypePlaylistRoute = "PlaylistRoute" EntityTypeTip = "Tip" EntityTypeComment = "Comment" EntityTypeCommentReaction = "CommentReaction" EntityTypeCommentReport = "CommentReport" EntityTypeCommentThread = "CommentThread" EntityTypeCommentMention = "CommentMention" EntityTypeMutedUser = "MutedUser" EntityTypeCommentNotificationSetting = "CommentNotificationSetting" EntityTypeEncryptedEmail = "EncryptedEmail" EntityTypeEmailAccess = "EmailAccess" EntityTypeEvent = "Event" )
Entity type constants.
const ( ActionCreate = "Create" ActionUpdate = "Update" ActionDelete = "Delete" ActionFollow = "Follow" ActionUnfollow = "Unfollow" ActionSave = "Save" ActionUnsave = "Unsave" ActionRepost = "Repost" ActionUnrepost = "Unrepost" ActionVerify = "Verify" ActionSubscribe = "Subscribe" ActionUnsubscribe = "Unsubscribe" ActionView = "View" ActionViewPlaylist = "ViewPlaylist" ActionApprove = "Approve" ActionReject = "Reject" ActionDownload = "Download" ActionReact = "React" ActionUnreact = "Unreact" ActionPin = "Pin" ActionUnpin = "Unpin" ActionMute = "Mute" ActionUnmute = "Unmute" ActionAddEmail = "AddEmail" ActionReport = "Report" )
Action constants.
const ( PlaylistIDOffset = 400_000 TrackIDOffset = 2_000_000 UserIDOffset = 3_000_000 CommentIDOffset = 4_000_000 )
ID offsets.
const ( CharacterLimitUserBio = 256 CharacterLimitUserName = 32 CharacterLimitHandle = 30 CharacterLimitDescription = 2500 CharacterLimitCommentBody = 400 )
Character limit constants.
const EntityTypeAny = "*"
EntityTypeAny is a wildcard entity type for handlers that match any entity type for a given action (e.g., social features: Follow matches entity_type "User", Save matches "Track" or "Playlist").
const MaxRedirectURILength = 2000
MaxRedirectURILength caps each individual URI string length.
const MaxRedirectURIs = 50
MaxRedirectURIs caps how many redirect URIs a single developer app may register.
Variables ¶
var GenreAllowlist = map[string]struct{}{
"Acoustic": {}, "Alternative": {}, "Ambient": {}, "Audiobooks": {}, "Blues": {},
"Classical": {}, "Comedy": {}, "Country": {}, "Dancehall": {}, "Deep House": {},
"Devotional": {}, "Disco": {}, "Downtempo": {}, "Drum & Bass": {}, "Dubstep": {},
"Electro": {}, "Electronic": {}, "Experimental": {}, "Folk": {}, "Funk": {},
"Future Bass": {}, "Future House": {}, "Glitch Hop": {}, "Hardstyle": {},
"Hip-Hop/Rap": {}, "House": {}, "Hyperpop": {}, "Jazz": {}, "Jersey Club": {},
"Jungle": {}, "Kids": {}, "Latin": {}, "Lo-Fi": {}, "Metal": {}, "Moombahton": {},
"Podcasts": {}, "Pop": {}, "Progressive House": {}, "Punk": {}, "R&B/Soul": {},
"Reggae": {}, "Rock": {}, "Soundtrack": {}, "Spoken Word": {}, "Tech House": {},
"Techno": {}, "Trance": {}, "Trap": {}, "Tropical House": {}, "Vaporwave": {}, "World": {},
}
GenreAllowlist is the set of valid genre strings.
var VerifiedAddress = "0xbeef8E42e8B5964fDD2b7ca8efA0d9aef38AA996"
VerifiedAddress is the wallet address authorized to sign User Verify transactions.
Functions ¶
func CreateTrackRouteID ¶
CreateTrackRouteID constructs a track's route_id from an unsanitized title and handle. Resulting route_ids are of the shape `<handle>/<sanitized_title>`.
func GeneratePlaylistSlugAndCollisionID ¶
func GeneratePlaylistSlugAndCollisionID(ctx context.Context, dbtx db.DBTX, ownerID, playlistID int64, name string) (slug, titleSlug string, collisionID int, err error)
GeneratePlaylistSlugAndCollisionID resolves slug collisions for playlist_routes.
func GenerateSlugAndCollisionID ¶
func GenerateSlugAndCollisionID(ctx context.Context, dbtx db.DBTX, ownerID, trackID int64, title string) (slug, titleSlug string, collisionID int, err error)
GenerateSlugAndCollisionID resolves slug collisions for track_routes (task_helpers.generate_slug_and_collision_id).
func IsValidationError ¶
IsValidationError returns true if the error is a ValidationError.
func SanitizeSlug ¶
SanitizeSlug converts a title into a URL-friendly slug.
func ValidateAccessConditions ¶
ValidateAccessConditions checks gating field consistency, matching Only validates when gating fields are present in metadata.
func ValidateDescription ¶
ValidateDescription checks description length (used for tracks, playlists).
func ValidateGenre ¶
ValidateGenre checks genre is in the allowlist.
func ValidateHandle ¶
ValidateHandle checks handle format, length, and reserved words.
func ValidateSigner ¶
ValidateSigner checks that the signer is the user's wallet or holds a valid grant from the user. Grants come from either a developer app (auto-approved at creation) or another user wallet acting in manager mode (must be approved by the grantor).
func ValidateUserName ¶
ValidateUserName checks name length.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher routes ManageEntity transactions to registered handlers.
func NewDispatcher ¶
func NewDispatcher(logger *zap.Logger) *Dispatcher
NewDispatcher creates a Dispatcher with no registered handlers.
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(ctx context.Context, params *Params) error
Dispatch routes a ManageEntity transaction to the appropriate handler. Returns nil if no handler is registered (unhandled entity/action pairs are silently skipped). Returns a ValidationError if the handler rejects the transaction. Returns a non-ValidationError for unexpected failures.
func (*Dispatcher) HandlerCount ¶
func (d *Dispatcher) HandlerCount() int
HandlerCount returns the number of registered handlers.
func (*Dispatcher) HasHandler ¶
func (d *Dispatcher) HasHandler(entityType, action string) bool
HasHandler returns true if a handler is registered for the given entity_type and action.
func (*Dispatcher) Register ¶
func (d *Dispatcher) Register(h Handler)
Register adds a handler for a specific (entity_type, action) pair.
type Handler ¶
type Handler interface {
EntityType() string
Action() string
Handle(ctx context.Context, params *Params) error
}
Handler processes a specific (entity_type, action) pair.
func AssociatedWalletCreate ¶
func AssociatedWalletCreate() Handler
func AssociatedWalletDelete ¶
func AssociatedWalletDelete() Handler
func CommentUnreact ¶
func CommentUnreact() Handler
CommentUnreact returns the Comment Unreact handler.
func DashboardWalletCreate ¶
func DashboardWalletCreate() Handler
func DashboardWalletDelete ¶
func DashboardWalletDelete() Handler
func DeveloperAppCreate ¶
func DeveloperAppCreate() Handler
DeveloperAppCreate returns the DeveloperApp Create handler.
func DeveloperAppDelete ¶
func DeveloperAppDelete() Handler
DeveloperAppDelete returns the DeveloperApp Delete handler.
func DeveloperAppUpdate ¶
func DeveloperAppUpdate() Handler
DeveloperAppUpdate returns the DeveloperApp Update handler.
func EmailAccessUpdate ¶
func EmailAccessUpdate() Handler
func EncryptedEmailCreate ¶
func EncryptedEmailCreate() Handler
func EventCreate ¶
func EventCreate() Handler
func EventDelete ¶
func EventDelete() Handler
func EventUpdate ¶
func EventUpdate() Handler
func GrantDelete ¶
func GrantDelete() Handler
GrantDelete returns the Grant Delete (Revoke) handler.
func NotificationCreate ¶
func NotificationCreate() Handler
NotificationCreate returns the Notification Create handler.
func NotificationView ¶
func NotificationView() Handler
NotificationView returns the Notification View handler.
func PlaylistCreate ¶
func PlaylistCreate() Handler
PlaylistCreate returns the Playlist Create handler.
func PlaylistDelete ¶
func PlaylistDelete() Handler
PlaylistDelete returns the Playlist Delete handler.
func PlaylistSeenView ¶
func PlaylistSeenView() Handler
PlaylistSeenView returns the PlaylistSeen View handler.
func PlaylistUpdate ¶
func PlaylistUpdate() Handler
PlaylistUpdate returns the Playlist Update handler.
func TipReaction ¶
func TipReaction() Handler
func TrackDownload ¶
func TrackDownload() Handler
func TrackMute ¶
func TrackMute() Handler
TrackMute returns the Track Mute handler (comment notification settings).
func TrackUnmute ¶
func TrackUnmute() Handler
TrackUnmute returns the Track Unmute handler (comment notification settings).
func Unsubscribe ¶
func Unsubscribe() Handler
type Params ¶
type Params struct {
TX *corev1.ManageEntityLegacy
UserID int64
EntityID int64
EntityType string
Action string
Signer string
Metadata map[string]any
RawMetadata string
BlockNumber int64
BlockTime time.Time
BlockHash string
TxHash string
DBTX db.DBTX
Logger *zap.Logger
}
Params holds all context for processing a single ManageEntity transaction.
func NewParams ¶
func NewParams(tx *corev1.ManageEntityLegacy, blockNumber int64, blockTime time.Time, blockHash, txHash string, dbtx db.DBTX, logger *zap.Logger) *Params
NewParams creates Params from a ManageEntityLegacy proto and block context.
func (*Params) MetadataBool ¶
MetadataBool returns a bool from parsed metadata.
func (*Params) MetadataBoolOr ¶
MetadataBoolOr returns the bool value or default if the key is absent.
func (*Params) MetadataInt64 ¶
MetadataInt64 returns an int64 from parsed metadata (supports number and string).
func (*Params) MetadataJSON ¶
MetadataJSON returns the raw value for a JSONB column (map, slice, etc.). Caller should json.Marshal for DB insertion.
func (*Params) MetadataString ¶
MetadataString returns a string field from parsed metadata, or empty string.
type ValidationError ¶
type ValidationError struct {
// contains filtered or unexported fields
}
ValidationError indicates a transaction should be skipped (not a fatal indexing error).
func NewValidationError ¶
func NewValidationError(format string, args ...any) *ValidationError
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Source Files
¶
- access_authorities.go
- associated_wallet.go
- comment_create.go
- comment_delete.go
- comment_mute.go
- comment_pin.go
- comment_queries.go
- comment_react.go
- comment_report.go
- comment_update.go
- crypto.go
- dashboard_wallet.go
- developer_app_create.go
- developer_app_delete.go
- developer_app_update.go
- email.go
- event_create.go
- event_delete.go
- event_queries.go
- event_update.go
- genre_allowlist.go
- grant_create.go
- grant_revoke.go
- handler.go
- immutable_fields.go
- muted_user.go
- notification.go
- oauth_redirect_uris.go
- playlist_create.go
- playlist_delete.go
- playlist_queries.go
- playlist_row.go
- playlist_tracks.go
- playlist_update.go
- price_history.go
- slug.go
- social_follow.go
- social_repost.go
- social_save.go
- social_share.go
- social_subscription.go
- tip_reaction.go
- track_create.go
- track_delete.go
- track_download.go
- track_mute.go
- track_queries.go
- track_remixes.go
- track_routes.go
- track_row.go
- track_stems.go
- track_update.go
- user_create.go
- user_update.go
- user_verify.go
- validate.go