Documentation
¶
Index ¶
- Constants
- func AddEventParticipationData(app core.App, event *core.RecordEnrichEvent) error
- func AddSeriesState(e *core.RecordEnrichEvent) error
- func AddUserICalLink(e *core.RecordEnrichEvent) error
- func BindDPHooks(app core.App, client bsm.APIClient, pushService PushService)
- func BlockKnownPaths(e *core.RequestEvent) error
- func CreateOrUpdateEventsForSeries(e *core.RecordRequestEvent, mode EventSeriesMode) error
- func DeleteEventsForSeries(e *core.RecordEvent) error
- func FindRecordProxyByID(app core.App, proxy AppRecordProxy, id string) error
- func ForwardErrorToExternalSystem(err error, context *ErrorContext, tags *map[string]string)
- func GetClubCommunityService() func(event *core.RequestEvent) error
- func GetGamesCount(app core.App) func(e *core.RequestEvent) error
- func GetMD5Hash(text string) string
- func GetSHA3Hash(text string) string
- func GetUserCommunityService() func(event *core.RequestEvent) error
- func GetUserStats() func(event *core.RequestEvent) error
- func GetYearStartAndEnd(year int) (start, end types.DateTime, err error)
- func HandleClubPractices() func(e *core.RequestEvent) error
- func HideCommunityServiceAdminFields(e *core.RecordEnrichEvent) error
- func HideTeamSignupKey(e *core.RecordEnrichEvent) error
- func ImportLeagueGroups(app core.App, client bsm.LeagueGroupClient, clubID *string, season *int) (err error)
- func JoinTeam(app core.App) func(e *core.RequestEvent) error
- func LoadAppTimeZone() (*time.Location, error)
- func LogErrorInternalExternal(app core.App, err error, context *ErrorContext, tags *map[string]string)
- func NotifyAdminsUserCreation(e *core.RecordEvent, ps PushService) error
- func NotifyNewAnnouncement(e *core.RecordEvent, ps PushService) error
- func NotifyNewEvent(e *core.RecordEvent, ps PushService) error
- func OAuthUpdateUserData(e *core.RecordAuthWithOAuth2RequestEvent) error
- func PushTeamOrClubAnnouncement(app core.App, coll string, announcement *Announcement, recordID string, ...)
- func RequireClubAdminAccess() *hook.Handler[*core.RequestEvent]
- func RequireUserAccess(record *core.Record) *hook.Handler[*core.RequestEvent]
- func SetDisplayName(e *core.RecordEvent) error
- func SetLastLogin(app core.App, record *core.Record) (err error)
- func StartLeagueGroupsImport(app core.App, client bsm.APIClient) func(event *core.RequestEvent) error
- func TriggerLeagueImport(app core.App, client bsm.APIClient, event *core.RecordsListRequestEvent) error
- func ValidateEvent(e *core.RecordEvent) error
- func ValidateEventTimes(e *core.RecordRequestEvent) error
- func ValidateSignupKey(e *core.RecordRequestEvent) error
- type Announcement
- func (a *Announcement) Author() string
- func (a *Announcement) BodyText() string
- func (a *Announcement) Club() string
- func (a *Announcement) Link() string
- func (a *Announcement) LinkText() string
- func (a *Announcement) Priority() string
- func (a *Announcement) SetAuthor(authorID string)
- func (a *Announcement) SetBodyText(bodyText string)
- func (a *Announcement) SetClub(clubID string)
- func (a *Announcement) SetLink(link string)
- func (a *Announcement) SetLinkText(linkText string)
- func (a *Announcement) SetPriority(priority string)
- func (a *Announcement) SetTeam(teamID string)
- func (a *Announcement) SetTitle(title string)
- func (a *Announcement) Team() string
- func (a *Announcement) Title() string
- type AppRecordProxy
- type AttendanceTotal
- type Club
- func (c *Club) Acronym() string
- func (c *Club) AdminEmail() string
- func (c *Club) Admins() []string
- func (c *Club) BSMAPIKey() string
- func (c *Club) BSMID() int
- func (c *Club) BSMSearchString() string
- func (c *Club) CollectionName() string
- func (c *Club) ID() string
- func (c *Club) Name() string
- func (c *Club) ServiceRequirement() int
- func (c *Club) SetAcronym(acronym string)
- func (c *Club) SetAdminEmail(email string)
- func (c *Club) SetAdmins(adminIDs []string)
- func (c *Club) SetBSMAPIKey(key string)
- func (c *Club) SetBSMID(id int)
- func (c *Club) SetBSMSearchString(searchString string)
- func (c *Club) SetName(name string)
- func (c *Club) SetServiceRequirement(req int)
- func (c *Club) SetTeamName(teamName string)
- func (c *Club) TeamName() string
- type ClubCommunityServiceRow
- type DiamondPlanner
- type ErrorContext
- type Event
- func (e *Event) AddAdditionalTeam(team string)
- func (e *Event) AdditionalTeams() []string
- func (e *Event) Attire() string
- func (e *Event) BSMID() int
- func (e *Event) Club() string
- func (e *Event) CollectionName() string
- func (e *Event) Created() types.DateTime
- func (e *Event) Desc() string
- func (e *Event) EndTime() types.DateTime
- func (e *Event) Guests() string
- func (e *Event) HasAdditionalTeams() bool
- func (e *Event) ID() string
- func (e *Event) IsCancelled() bool
- func (e *Event) Location() string
- func (e *Event) MatchJSON() string
- func (e *Event) MeetingTime() types.DateTime
- func (e *Event) Series() string
- func (e *Event) SetAdditionalTeams(additionalTeams []string)
- func (e *Event) SetAttire(attire string)
- func (e *Event) SetBSMID(bsmID int)
- func (e *Event) SetCancelled(cancelled bool)
- func (e *Event) SetClub(club string)
- func (e *Event) SetDesc(desc string)
- func (e *Event) SetEndTime(endTime types.DateTime)
- func (e *Event) SetGuests(guests string)
- func (e *Event) SetLocation(location string)
- func (e *Event) SetMatchJSON(matchJSON string)
- func (e *Event) SetMeetingTime(meetingTime types.DateTime)
- func (e *Event) SetParticipations(participations ParticipationsByType)
- func (e *Event) SetSeries(series string)
- func (e *Event) SetStartTime(startTime types.DateTime)
- func (e *Event) SetTeam(team string)
- func (e *Event) SetTitle(title string)
- func (e *Event) SetType(eventType string)
- func (e *Event) SetUserParticipation(participation *core.Record)
- func (e *Event) StartTime() types.DateTime
- func (e *Event) Team() string
- func (e *Event) Title() string
- func (e *Event) Type() string
- func (e *Event) Updated() types.DateTime
- type EventCounts
- type EventSeries
- func (s *EventSeries) AddAdditionalTeam(team string)
- func (s *EventSeries) AdditionalTeams() []string
- func (s *EventSeries) CollectionName() string
- func (s *EventSeries) Desc() string
- func (s *EventSeries) DetermineState() SeriesState
- func (s *EventSeries) Duration() int
- func (s *EventSeries) ID() string
- func (s *EventSeries) Interval() int
- func (s *EventSeries) Location() string
- func (s *EventSeries) SeriesEnd() types.DateTime
- func (s *EventSeries) SeriesStart() types.DateTime
- func (s *EventSeries) SetAdditionalTeams(teams []string)
- func (s *EventSeries) SetDesc(desc string)
- func (s *EventSeries) SetDuration(duration int)
- func (s *EventSeries) SetInterval(interval int)
- func (s *EventSeries) SetLocation(location string)
- func (s *EventSeries) SetSeriesEnd(end types.DateTime)
- func (s *EventSeries) SetSeriesStart(start types.DateTime)
- func (s *EventSeries) SetState(state SeriesState)
- func (s *EventSeries) SetTeam(team string)
- func (s *EventSeries) SetTitle(title string)
- func (s *EventSeries) Team() string
- func (s *EventSeries) Title() string
- func (s *EventSeries) ToPracticeDTO(loc *time.Location) *PracticeDTO
- type EventSeriesAction
- type EventSeriesMode
- type EventType
- type GameImportService
- type GameImportServiceApp
- type JoinTeamPayload
- type LeagueGroup
- func (lg *LeagueGroup) Acronym() string
- func (lg *LeagueGroup) BSMID() int
- func (lg *LeagueGroup) Clubs() []string
- func (lg *LeagueGroup) CollectionName() string
- func (lg *LeagueGroup) ID() string
- func (lg *LeagueGroup) Name() string
- func (lg *LeagueGroup) Season() int
- func (lg *LeagueGroup) SetAcronym(acronym string)
- func (lg *LeagueGroup) SetBSMID(bsmID int)
- func (lg *LeagueGroup) SetClubs(clubs []string)
- func (lg *LeagueGroup) SetName(name string)
- func (lg *LeagueGroup) SetSeason(season int)
- type Location
- func (l *Location) AddressAddon() string
- func (l *Location) BSMID() int
- func (l *Location) City() string
- func (l *Location) Club() string
- func (l *Location) CollectionName() string
- func (l *Location) Country() string
- func (l *Location) Description() string
- func (l *Location) GetCalendarFormatted() string
- func (l *Location) GroundRules() string
- func (l *Location) HumanCountry() string
- func (l *Location) ID() string
- func (l *Location) InternalName() string
- func (l *Location) Latitude() float64
- func (l *Location) Longitude() float64
- func (l *Location) Name() string
- func (l *Location) OtherInformation() string
- func (l *Location) PhotoURL() string
- func (l *Location) PostalCode() string
- func (l *Location) SetAddressAddon(addressAddon string)
- func (l *Location) SetBSMID(bsmID int)
- func (l *Location) SetCity(city string)
- func (l *Location) SetClub(club string)
- func (l *Location) SetCountry(country string)
- func (l *Location) SetDescription(description string)
- func (l *Location) SetGroundRules(groundRules string)
- func (l *Location) SetHumanCountry(humanCountry string)
- func (l *Location) SetInternalName(internalName string)
- func (l *Location) SetLatitude(latitude float64)
- func (l *Location) SetLongitude(longitude float64)
- func (l *Location) SetName(name string)
- func (l *Location) SetOtherInformation(otherInformation string)
- func (l *Location) SetPhotoURL(photoURL string)
- func (l *Location) SetPostalCode(postalCode string)
- func (l *Location) SetSpectatorSeats(spectatorSeats int)
- func (l *Location) SetSpectatorTotal(spectatorTotal int)
- func (l *Location) SetStreet(street string)
- func (l *Location) SpectatorSeats() int
- func (l *Location) SpectatorTotal() int
- func (l *Location) Street() string
- func (l *Location) String() string
- func (l *Location) ToDTO() *LocationDTO
- type LocationDTO
- type LogOnlyApp
- type LogicError
- type NamedRecordProxy
- type NotAuthorizedError
- type ParticipationStatsByPerson
- type ParticipationTotal
- type ParticipationType
- type ParticipationsByType
- type PersonalAttendanceStatsItem
- type PracticeDTO
- type PracticeSeason
- type PushActionData
- type PushActionType
- type PushMessage
- type PushService
- type PushServiceImpl
- type PushSubscription
- func (p *PushSubscription) CollectionName() string
- func (p *PushSubscription) Encoding() string
- func (p *PushSubscription) Endpoint() string
- func (p *PushSubscription) ID() string
- func (p *PushSubscription) KeyAuth() string
- func (p *PushSubscription) KeyP256dh() string
- func (p *PushSubscription) SetEncoding(encoding string)
- func (p *PushSubscription) SetEndpoint(endpoint string)
- func (p *PushSubscription) SetKeyAuth(key string)
- func (p *PushSubscription) SetKeyP256dh(key string)
- func (p *PushSubscription) SetUser(userId string)
- func (p *PushSubscription) ToWebPushSubscription() webpush.Subscription
- func (p *PushSubscription) User() string
- type ResponseStatus
- type SeriesState
- type ServiceEntry
- func (s *ServiceEntry) AdminComment() string
- func (s *ServiceEntry) BoardMember() string
- func (s *ServiceEntry) Club() string
- func (s *ServiceEntry) CollectionName() string
- func (s *ServiceEntry) Description() string
- func (s *ServiceEntry) HideAdminFields()
- func (s *ServiceEntry) ID() string
- func (s *ServiceEntry) Member() string
- func (s *ServiceEntry) Minutes() int
- func (s *ServiceEntry) ServiceDate() types.DateTime
- func (s *ServiceEntry) SetAdminComment(comment string)
- func (s *ServiceEntry) SetBoardMember(id string)
- func (s *ServiceEntry) SetClub(id string)
- func (s *ServiceEntry) SetDescription(description string)
- func (s *ServiceEntry) SetMember(id string)
- func (s *ServiceEntry) SetMinutes(minutes int)
- func (s *ServiceEntry) SetServiceDate(dt types.DateTime)
- func (s *ServiceEntry) SetTitle(title string)
- func (s *ServiceEntry) Title() string
- type SimpleCount
- type Team
- func (t *Team) Admins() []string
- func (t *Team) AgeGroup() string
- func (t *Team) BSMLeagueGroup() int
- func (t *Team) Club() string
- func (t *Team) CollectionName() string
- func (t *Team) Description() string
- func (t *Team) HideSignupKey()
- func (t *Team) ID() string
- func (t *Team) Name() string
- func (t *Team) SetAdmins(adminIDs []string)
- func (t *Team) SetAgeGroup(ageGroup string)
- func (t *Team) SetBSMLeagueGroup(id int)
- func (t *Team) SetClub(clubID string)
- func (t *Team) SetDescription(desc string)
- func (t *Team) SetName(name string)
- func (t *Team) SetSignupKey(key string)
- func (t *Team) SignupKey() string
- func (t *Team) UnhideSignupKey()
- type TeamWithSignupKey
- type User
- func (u *User) AddClub(clubID string)
- func (u *User) AddTeam(teamID string)
- func (u *User) Avatar() string
- func (u *User) BSMID() int
- func (u *User) Bats() string
- func (u *User) Birthday() types.DateTime
- func (u *User) Clubs() []string
- func (u *User) CollectionName() string
- func (u *User) DisplayName() string
- func (u *User) DisplayOnWebsite() bool
- func (u *User) Email() string
- func (u *User) EmailVisibility() bool
- func (u *User) FirstName() string
- func (u *User) ID() string
- func (u *User) Image() string
- func (u *User) LastLogin() types.DateTime
- func (u *User) LastName() string
- func (u *User) Number() string
- func (u *User) Position() []string
- func (u *User) Scorer() string
- func (u *User) SetAvatar(filename string)
- func (u *User) SetBSMID(id int)
- func (u *User) SetBats(bats string)
- func (u *User) SetBirthday(dt types.DateTime)
- func (u *User) SetClubs(clubIDs []string)
- func (u *User) SetDisplayName(name string)
- func (u *User) SetDisplayOnWebsite(display bool)
- func (u *User) SetEmail(email string)
- func (u *User) SetEmailVisibility(visible bool)
- func (u *User) SetFirstName(first string)
- func (u *User) SetICalLink(link string)
- func (u *User) SetImage(filename string)
- func (u *User) SetLastLogin(dt types.DateTime)
- func (u *User) SetLastName(last string)
- func (u *User) SetNumber(num string)
- func (u *User) SetPosition(pos []string)
- func (u *User) SetScorer(grade string)
- func (u *User) SetSignupKey(key string)
- func (u *User) SetTeams(teamIDs []string)
- func (u *User) SetThrows(throws string)
- func (u *User) SetUmpire(grade string)
- func (u *User) SetUsername(username string)
- func (u *User) SetVerified(v bool)
- func (u *User) SignupKey() string
- func (u *User) Teams() []string
- func (u *User) Throws() string
- func (u *User) Umpire() string
- func (u *User) Username() string
- func (u *User) Verified() bool
- type UserCommunityServiceData
- type UserCommunityServiceItem
- type UserParticipationDTO
- type UserServiceApp
Constants ¶
const ( TimeZoneEnvKey = "TIME_ZONE" DefaultTimezone = "Europe/Berlin" )
const ( VAPIDSubscriberEnvName = "VAPID_SUBSCRIBER" VAPIDPublicKeyEnvName = "VAPID_PUBLIC_KEY" VAPIDPrivateKeyEnvName = "VAPID_PRIVATE_KEY" PushActionLink PushActionType = "link" )
const (
AnnouncementsCollection = "announcements"
)
const ClubAdminAccessMiddlewareId = "clubAdminAccess"
const (
ClubsCollection = "clubs"
)
const (
EventSeriesCollection = "eventseries"
)
const EventStoreKeyClub = "club"
const (
EventsCollection = "events"
)
const (
LeagueGroupsCollection = "leaguegroups"
)
const (
LocationCollection = "locations"
)
const (
ParticipationsCollection = "participations"
)
const (
PushSubscriptionsCollection = "pushsubscriptions"
)
const (
ServiceEntryCollection = "serviceentries"
)
const (
TeamsCollection = "teams"
)
const UserAccessMiddlewareId = "requireUserAccess"
const (
UserCollection = "users"
)
Variables ¶
This section is empty.
Functions ¶
func AddEventParticipationData ¶
func AddEventParticipationData(app core.App, event *core.RecordEnrichEvent) error
func AddSeriesState ¶
func AddSeriesState(e *core.RecordEnrichEvent) error
AddSeriesState is a hook that sets the state of the event series based on the current date
func AddUserICalLink ¶
func AddUserICalLink(e *core.RecordEnrichEvent) error
AddUserICalLink adds the user's custom iCal link to the JSON response.
func BindDPHooks ¶
func BindDPHooks(app core.App, client bsm.APIClient, pushService PushService)
func BlockKnownPaths ¶
func BlockKnownPaths(e *core.RequestEvent) error
BlockKnownPaths acts as a simple blocker for some scriptkiddie "attacks" (every 404 response creates a log entry). Not intended to be an actual security measure.
func CreateOrUpdateEventsForSeries ¶
func CreateOrUpdateEventsForSeries(e *core.RecordRequestEvent, mode EventSeriesMode) error
CreateOrUpdateEventsForSeries is the main entry point for event series logic. Triggered on all Create and Update requests (regular API endpoints)
func DeleteEventsForSeries ¶
func DeleteEventsForSeries(e *core.RecordEvent) error
DeleteEventsForSeries deletes all events associated with a given event series record.
func FindRecordProxyByID ¶
func FindRecordProxyByID(app core.App, proxy AppRecordProxy, id string) error
FindRecordProxyByID retrieves a record proxy by its ID from the database. Simple Wrapper for `app.FindRecordById()` to prevent having to load the result manually into a proxy object. Caution: `proxy` needs to be a pointer to a struct that implements AppRecordProxy, not a value.
func ForwardErrorToExternalSystem ¶
func ForwardErrorToExternalSystem(err error, context *ErrorContext, tags *map[string]string)
Forwards the error to the external error tracking system (Sentry-compatible, using self-hosted Bugsink instance).
func GetClubCommunityService ¶
func GetClubCommunityService() func(event *core.RequestEvent) error
func GetGamesCount ¶
func GetGamesCount(app core.App) func(e *core.RequestEvent) error
GetGamesCount returns the number of official league games in the database for a given team and season. Requires a valid auth record that belongs to the team queried.
func GetMD5Hash ¶
GetMD5Hash returns the MD5 hash of the given string. MARK: do not use for anything security-related as this algorithm is considered insecure. Only used for request caching mechanism.
func GetSHA3Hash ¶
GetSHA3Hash returns the SHA3 hash of the given string.
func GetUserCommunityService ¶
func GetUserCommunityService() func(event *core.RequestEvent) error
func GetUserStats ¶
func GetUserStats() func(event *core.RequestEvent) error
func HandleClubPractices ¶
func HandleClubPractices() func(e *core.RequestEvent) error
HandleClubPractices is a handler func that returns all event series for a single club in a format suitable for external systems.
Authentication is expected to be handled by a preceding middleware.
func HideCommunityServiceAdminFields ¶
func HideCommunityServiceAdminFields(e *core.RecordEnrichEvent) error
func HideTeamSignupKey ¶
func HideTeamSignupKey(e *core.RecordEnrichEvent) error
HideTeamSignupKey hides the signup key for a team record if the current user is not an admin.
func ImportLeagueGroups ¶
func ImportLeagueGroups(app core.App, client bsm.LeagueGroupClient, clubID *string, season *int) (err error)
ImportLeagueGroups imports league groups concurrently, either for one given club or all clubs in the database.
func LoadAppTimeZone ¶
func LogErrorInternalExternal ¶
func LogErrorInternalExternal(app core.App, err error, context *ErrorContext, tags *map[string]string)
LogErrorInternalExternal logs the error to the internal PocketBase logger and forwards it to the external error tracking system.
func NotifyAdminsUserCreation ¶
func NotifyAdminsUserCreation(e *core.RecordEvent, ps PushService) error
NotifyAdminsUserCreation is a hook that handles push notifications to club admins when a new user is created as well as email notifications to superusers.
func NotifyNewAnnouncement ¶
func NotifyNewAnnouncement(e *core.RecordEvent, ps PushService) error
func NotifyNewEvent ¶
func NotifyNewEvent(e *core.RecordEvent, ps PushService) error
NotifyNewEvent sends a push notification to all subscribed team members when a new event is created.
func OAuthUpdateUserData ¶
func OAuthUpdateUserData(e *core.RecordAuthWithOAuth2RequestEvent) error
OAuthUpdateUserData updates user record with information found in the OAuth2 response.
This could also be used to validate the signup key, but does not do that at the moment (see generic record creation hook that also works for password auth).
func PushTeamOrClubAnnouncement ¶
func PushTeamOrClubAnnouncement(app core.App, coll string, announcement *Announcement, recordID string, ps PushService)
PushTeamOrClubAnnouncement sends a push notification to all subscribed users when a new announcement is created for a team or club.
func RequireClubAdminAccess ¶
func RequireClubAdminAccess() *hook.Handler[*core.RequestEvent]
RequireClubAdminAccess verifies that the current auth is an admin for the club. The club is expected to be provided via the path parameter `club`.
func RequireUserAccess ¶
RequireUserAccess verifies that the current auth can access a record in a request param. In DiamondPlanner context, that is most commonly used for `users` and means one (or more) of 3 things:
- the user is the auth record itself
- the auth record is an admin of one of the requested user's teams
- the auth record is an admin of one of the requested user's clubs
func SetDisplayName ¶
func SetDisplayName(e *core.RecordEvent) error
SetDisplayName sets the display name for the user if it is not already set.
Default display name format: first name + first letter of last name + dot
func StartLeagueGroupsImport ¶
func StartLeagueGroupsImport(app core.App, client bsm.APIClient) func(event *core.RequestEvent) error
StartLeagueGroupsImport runs import cron for league groups exactly once for one specific club.
func TriggerLeagueImport ¶
func TriggerLeagueImport(app core.App, client bsm.APIClient, event *core.RecordsListRequestEvent) error
TriggerLeagueImport called on every league group listing if the result is empty and special query parameters `season` and `club` are sent, an import is automatically triggered.
func ValidateEvent ¶
func ValidateEvent(e *core.RecordEvent) error
func ValidateEventTimes ¶
func ValidateEventTimes(e *core.RecordRequestEvent) error
ValidateEventTimes ensures that event times are valid and within the expected range.
func ValidateSignupKey ¶
func ValidateSignupKey(e *core.RecordRequestEvent) error
ValidateSignupKey checks that a valid signup key is used on user creation. A user is assigned a team and club based on the signup key used.
Superuser auth bypasses this check (so creating users from PocketBase admin panel is always possible).
Types ¶
type Announcement ¶
type Announcement struct {
core.BaseRecordProxy
}
Announcement RecordProxy for collection `announcements`. Provides type-safe struct access to announcement records.
func (*Announcement) Author ¶
func (a *Announcement) Author() string
func (*Announcement) BodyText ¶
func (a *Announcement) BodyText() string
func (*Announcement) Club ¶
func (a *Announcement) Club() string
func (*Announcement) Link ¶
func (a *Announcement) Link() string
func (*Announcement) LinkText ¶
func (a *Announcement) LinkText() string
func (*Announcement) Priority ¶
func (a *Announcement) Priority() string
func (*Announcement) SetAuthor ¶
func (a *Announcement) SetAuthor(authorID string)
func (*Announcement) SetBodyText ¶
func (a *Announcement) SetBodyText(bodyText string)
func (*Announcement) SetClub ¶
func (a *Announcement) SetClub(clubID string)
func (*Announcement) SetLink ¶
func (a *Announcement) SetLink(link string)
func (*Announcement) SetLinkText ¶
func (a *Announcement) SetLinkText(linkText string)
func (*Announcement) SetPriority ¶
func (a *Announcement) SetPriority(priority string)
func (*Announcement) SetTeam ¶
func (a *Announcement) SetTeam(teamID string)
func (*Announcement) SetTitle ¶
func (a *Announcement) SetTitle(title string)
func (*Announcement) Team ¶
func (a *Announcement) Team() string
func (*Announcement) Title ¶
func (a *Announcement) Title() string
type AppRecordProxy ¶
type AppRecordProxy interface {
core.RecordProxy
ID() string
CollectionName() string
}
AppRecordProxy defines the interface for all Diamond Planner Record Proxies used for type-safe access to record model fields.
type AttendanceTotal ¶
type Club ¶
type Club struct {
core.BaseRecordProxy
}
Club RecordProxy for collection `clubs`. Provides type-safe struct access to club records.
func (*Club) AdminEmail ¶
func (*Club) BSMSearchString ¶
func (*Club) CollectionName ¶
func (*Club) ServiceRequirement ¶
func (*Club) SetAcronym ¶
func (*Club) SetAdminEmail ¶
func (*Club) SetBSMAPIKey ¶
func (*Club) SetBSMSearchString ¶
func (*Club) SetServiceRequirement ¶
func (*Club) SetTeamName ¶
type ClubCommunityServiceRow ¶
type DiamondPlanner ¶
type DiamondPlanner struct {
*pocketbase.PocketBase
}
func NewDiamondPlanner ¶
func NewDiamondPlanner(client bsm.APIClient, pushService PushService) *DiamondPlanner
type ErrorContext ¶
type Event ¶
type Event struct {
core.BaseRecordProxy
}
Event RecordProxy for collection `events`. Provides type-safe struct access to event records.
func EventSeriesLinkedListToSlice ¶
EventSeriesLinkedListToSlice adds persistence info to an event series and returns a slice of events.
func (*Event) AddAdditionalTeam ¶
func (*Event) AdditionalTeams ¶
func (*Event) CollectionName ¶
func (*Event) HasAdditionalTeams ¶
func (*Event) IsCancelled ¶
func (*Event) MeetingTime ¶
func (*Event) SetAdditionalTeams ¶
func (*Event) SetCancelled ¶
func (*Event) SetEndTime ¶
func (*Event) SetLocation ¶
func (*Event) SetMatchJSON ¶
func (*Event) SetMeetingTime ¶
func (*Event) SetParticipations ¶
func (e *Event) SetParticipations(participations ParticipationsByType)
SetParticipations sets a virtual (non-DB) field to include participation data (back-relation).
func (*Event) SetStartTime ¶
func (*Event) SetUserParticipation ¶
SetUserParticipation sets a virtual (non-DB) field to include participation data for the currently-logged-in user.
type EventCounts ¶
type EventSeries ¶
type EventSeries struct {
core.BaseRecordProxy
}
EventSeries is a RecordProxy for the `eventseries` collection. It offers type-safe getters and setters for every field.
Pure database model, relations are not resolved automatically.
func (*EventSeries) AddAdditionalTeam ¶
func (s *EventSeries) AddAdditionalTeam(team string)
func (*EventSeries) AdditionalTeams ¶
func (s *EventSeries) AdditionalTeams() []string
AdditionalTeams returns the additional teams associated with the series.
func (*EventSeries) CollectionName ¶
func (s *EventSeries) CollectionName() string
func (*EventSeries) Desc ¶
func (s *EventSeries) Desc() string
Desc returns the optional description.
func (*EventSeries) DetermineState ¶
func (s *EventSeries) DetermineState() SeriesState
func (*EventSeries) Duration ¶
func (s *EventSeries) Duration() int
Duration returns the duration of an event in the series (in minutes).
func (*EventSeries) Interval ¶
func (s *EventSeries) Interval() int
Interval returns the number of days between occurrences of events in the series.
func (*EventSeries) Location ¶
func (s *EventSeries) Location() string
Location returns the location string.
func (*EventSeries) SeriesEnd ¶
func (s *EventSeries) SeriesEnd() types.DateTime
SeriesEnd returns the last day/time of the series.
func (*EventSeries) SeriesStart ¶
func (s *EventSeries) SeriesStart() types.DateTime
SeriesStart returns the first day/time of the series.
func (*EventSeries) SetAdditionalTeams ¶
func (s *EventSeries) SetAdditionalTeams(teams []string)
func (*EventSeries) SetDesc ¶
func (s *EventSeries) SetDesc(desc string)
func (*EventSeries) SetDuration ¶
func (s *EventSeries) SetDuration(duration int)
func (*EventSeries) SetInterval ¶
func (s *EventSeries) SetInterval(interval int)
func (*EventSeries) SetLocation ¶
func (s *EventSeries) SetLocation(location string)
func (*EventSeries) SetSeriesEnd ¶
func (s *EventSeries) SetSeriesEnd(end types.DateTime)
func (*EventSeries) SetSeriesStart ¶
func (s *EventSeries) SetSeriesStart(start types.DateTime)
func (*EventSeries) SetState ¶
func (s *EventSeries) SetState(state SeriesState)
func (*EventSeries) SetTeam ¶
func (s *EventSeries) SetTeam(team string)
func (*EventSeries) SetTitle ¶
func (s *EventSeries) SetTitle(title string)
func (*EventSeries) Team ¶
func (s *EventSeries) Team() string
Team returns the id of the team the series belongs to.
func (*EventSeries) ToPracticeDTO ¶
func (s *EventSeries) ToPracticeDTO(loc *time.Location) *PracticeDTO
ToPracticeDTO converts an event series to a PracticeDTO.
The returned pointer is never nil.
type EventSeriesAction ¶
type EventSeriesAction string
const ( CreateEventsAction EventSeriesAction = "create" UpdateFutureEventsAction EventSeriesAction = "update-future" UpdateAllEventsAction EventSeriesAction = "update-all" )
type EventSeriesMode ¶
type EventSeriesMode string
const ( CreateEventSeriesMode EventSeriesMode = "create" UpdateEventSeriesMode EventSeriesMode = "update" )
type GameImportService ¶
type GameImportService struct {
App GameImportServiceApp
}
func (GameImportService) Client ¶
func (s GameImportService) Client() bsm.APIClient
func (GameImportService) ImportGames ¶
func (s GameImportService) ImportGames()
type GameImportServiceApp ¶
type GameImportServiceApp interface {
FindRecordsByFilter(
collectionModelOrIdentifier any,
filter string,
sort string,
limit int,
offset int,
params ...dbx.Params,
) ([]*core.Record, error)
FindFirstRecordByData(collectionModelOrIdentifier any, key string, value any) (*core.Record, error)
Logger() *slog.Logger
ExpandRecord(record *core.Record, expands []string, optFetchFunc core.ExpandFetchFunc) map[string]error
FindCollectionByNameOrId(nameOrId string) (*core.Collection, error)
Save(model core.Model) error
}
type JoinTeamPayload ¶
type LeagueGroup ¶
type LeagueGroup struct {
core.BaseRecordProxy
}
LeagueGroup RecordProxy for collection `leaguegroups`. Provides type-safe struct access to league group records.
func (*LeagueGroup) Acronym ¶
func (lg *LeagueGroup) Acronym() string
func (*LeagueGroup) BSMID ¶
func (lg *LeagueGroup) BSMID() int
func (*LeagueGroup) Clubs ¶
func (lg *LeagueGroup) Clubs() []string
func (*LeagueGroup) CollectionName ¶
func (lg *LeagueGroup) CollectionName() string
func (*LeagueGroup) ID ¶
func (lg *LeagueGroup) ID() string
func (*LeagueGroup) Name ¶
func (lg *LeagueGroup) Name() string
func (*LeagueGroup) Season ¶
func (lg *LeagueGroup) Season() int
func (*LeagueGroup) SetAcronym ¶
func (lg *LeagueGroup) SetAcronym(acronym string)
func (*LeagueGroup) SetBSMID ¶
func (lg *LeagueGroup) SetBSMID(bsmID int)
func (*LeagueGroup) SetClubs ¶
func (lg *LeagueGroup) SetClubs(clubs []string)
func (*LeagueGroup) SetName ¶
func (lg *LeagueGroup) SetName(name string)
func (*LeagueGroup) SetSeason ¶
func (lg *LeagueGroup) SetSeason(season int)
type Location ¶
type Location struct {
core.BaseRecordProxy
}
Location RecordProxy for collection `locations`.
func (*Location) AddressAddon ¶
AddressAddon for many BSM datasets contains the actual name of the field
func (*Location) CollectionName ¶
func (*Location) Description ¶
func (*Location) GetCalendarFormatted ¶
func (*Location) GroundRules ¶
func (*Location) HumanCountry ¶
func (*Location) InternalName ¶
func (*Location) Name ¶
Name contains mostly useless data like "Baseball" there is also `internal_name` in the record model to have a field that automatic imports do not overwrite
func (*Location) OtherInformation ¶
func (*Location) PostalCode ¶
func (*Location) SetAddressAddon ¶
func (*Location) SetCountry ¶
func (*Location) SetDescription ¶
func (*Location) SetGroundRules ¶
func (*Location) SetHumanCountry ¶
func (*Location) SetInternalName ¶
func (*Location) SetLatitude ¶
func (*Location) SetLongitude ¶
func (*Location) SetOtherInformation ¶
func (*Location) SetPhotoURL ¶
func (*Location) SetPostalCode ¶
func (*Location) SetSpectatorSeats ¶
func (*Location) SetSpectatorTotal ¶
func (*Location) SpectatorSeats ¶
func (*Location) SpectatorTotal ¶
func (*Location) ToDTO ¶
func (l *Location) ToDTO() *LocationDTO
type LocationDTO ¶
type LocationDTO struct {
Name string `json:"name"`
AddressAddon string `json:"address_addon"`
InternalName string `json:"internal_name"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Street string `json:"street"`
PostalCode string `json:"postal_code"`
City string `json:"city"`
Country string `json:"country"`
BSMID int `json:"bsm_id"`
}
type LogOnlyApp ¶
LogOnlyApp is a PocketBase app that only needs to log errors.
type LogicError ¶
type LogicError struct {
Message string
}
func (LogicError) Error ¶
func (e LogicError) Error() string
type NamedRecordProxy ¶
type NamedRecordProxy interface {
core.RecordProxy
Name() string
}
type NotAuthorizedError ¶
type NotAuthorizedError struct {
Message string
}
func (*NotAuthorizedError) Error ¶
func (e *NotAuthorizedError) Error() string
type ParticipationStatsByPerson ¶
type ParticipationStatsByPerson struct {
ID string `db:"id" json:"id"`
LastName string `db:"last_name" json:"lastName"`
FirstName string `db:"first_name" json:"firstName"`
Type string `db:"type" json:"type"`
InCount int `db:"inCount" json:"inCount"`
OutCount int `db:"outCount" json:"outCount"`
MaybeCount int `db:"maybeCount" json:"maybeCount"`
TotalCount int `db:"TotalCount" json:"totalCount"`
}
type ParticipationTotal ¶
type ParticipationTotal struct {
Type ParticipationType `json:"type"`
Amount int `json:"amount"`
}
type ParticipationType ¶
type ParticipationType string
const ( In ParticipationType = "in" Out ParticipationType = "out" Maybe ParticipationType = "maybe" )
func ParseParticipationType ¶
func ParseParticipationType(s string) (ParticipationType, error)
func (ParticipationType) IsValid ¶
func (pt ParticipationType) IsValid() bool
func (ParticipationType) String ¶
func (pt ParticipationType) String() string
type ParticipationsByType ¶
type PersonalAttendanceStatsItem ¶
type PersonalAttendanceStatsItem struct {
Season int `json:"season"`
TotalPossibleEvents int `json:"totalPossibleEvents"`
AttendanceTotals []AttendanceTotal `json:"attendanceTotals"`
ParticipationTotals []ParticipationTotal `json:"participationTotals"`
Type EventType `json:"type"`
Values []ParticipationStatsByPerson `json:"values"`
TeamName string `json:"teamName"`
}
func LoadUserStats ¶
func LoadUserStats(user *core.Record, requestEvent *core.RequestEvent) (PersonalAttendanceStatsItem, error)
LoadUserStats gets participation stats by event type and participation state
type PracticeDTO ¶
type PracticeDTO struct {
ID string `json:"id"`
Teams []string `json:"teams"`
Season PracticeSeason `json:"season"`
HumanSeason string `json:"human_season"`
DayOfWeek time.Weekday `json:"day_of_week"`
HumanDayOfWeek string `json:"human_day_of_week"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
Desc string `json:"desc"`
Location *LocationDTO `json:"location"`
}
PracticeDTO represents a single event series in a calendaric format.
type PracticeSeason ¶
type PracticeSeason uint8
PracticeSeason represents summer or winter in practice context.
const ( PracticeSeasonSummer PracticeSeason = 0 PracticeSeasonWinter PracticeSeason = 1 )
func (PracticeSeason) String ¶
func (ps PracticeSeason) String() string
String returns a string representation of the underlying integer constant.
type PushActionData ¶
type PushActionData struct {
Action PushActionType `json:"action"`
Title string `json:"title"`
Type string `json:"type"`
}
type PushActionType ¶
type PushActionType string
type PushMessage ¶
type PushMessage struct {
Title string `json:"title"`
Body string `json:"body"`
Data map[string]any `json:"data"`
Tag string `json:"tag"`
Actions []PushActionData `json:"actions"`
}
PushMessage represents the raw data for a push notification message that is encoded into the JSON payload. Closely follows the DOM type `NotificationOptions`.
type PushService ¶
type PushService interface {
SendPushMessage(msg *PushMessage, sub *webpush.Subscription) error
// contains filtered or unexported methods
}
PushService defines the app-wide interface for sending push notifications.
func NewPushService ¶
func NewPushService() PushService
NewPushService creates a new PushServiceImpl instance, making sure the VAPID credentials are present in the environment.
type PushServiceImpl ¶
PushServiceImpl is the default implementation of PushService. It is meant as a singleton, to be instantiated only once. The main advantage is that it encapsulates the VAPID credentials and handles the actual sending of push notifications.
func (PushServiceImpl) SendPushMessage ¶
func (p PushServiceImpl) SendPushMessage(msg *PushMessage, sub *webpush.Subscription) error
SendPushMessage sends a push notification to the given subscription.
type PushSubscription ¶
type PushSubscription struct {
core.BaseRecordProxy
}
PushSubscription RecordProxy for collection `pushsubscriptions`. Provides type-safe struct access to push subscription records.
func GetSubscriptionsForUserIDs ¶
func GetSubscriptionsForUserIDs(userIDs []string, app core.App) ([]PushSubscription, error)
func (*PushSubscription) CollectionName ¶
func (p *PushSubscription) CollectionName() string
func (*PushSubscription) Encoding ¶
func (p *PushSubscription) Encoding() string
func (*PushSubscription) Endpoint ¶
func (p *PushSubscription) Endpoint() string
func (*PushSubscription) ID ¶
func (p *PushSubscription) ID() string
func (*PushSubscription) KeyAuth ¶
func (p *PushSubscription) KeyAuth() string
func (*PushSubscription) KeyP256dh ¶
func (p *PushSubscription) KeyP256dh() string
func (*PushSubscription) SetEncoding ¶
func (p *PushSubscription) SetEncoding(encoding string)
func (*PushSubscription) SetEndpoint ¶
func (p *PushSubscription) SetEndpoint(endpoint string)
func (*PushSubscription) SetKeyAuth ¶
func (p *PushSubscription) SetKeyAuth(key string)
func (*PushSubscription) SetKeyP256dh ¶
func (p *PushSubscription) SetKeyP256dh(key string)
func (*PushSubscription) SetUser ¶
func (p *PushSubscription) SetUser(userId string)
func (*PushSubscription) ToWebPushSubscription ¶
func (p *PushSubscription) ToWebPushSubscription() webpush.Subscription
ToWebPushSubscription converts a Diamond Planner push subscription record from the database to a webpush.Subscription to be sent via external browser-vendored Push Service.
func (*PushSubscription) User ¶
func (p *PushSubscription) User() string
type ResponseStatus ¶
type ResponseStatus string
const ( ResponseStatusSuccess ResponseStatus = "success" ResponseStatusError ResponseStatus = "error" )
type SeriesState ¶
type SeriesState string
const ( SeriesStateFuture SeriesState = "future" SeriesStatePast SeriesState = "past" SeriesStateOngoing SeriesState = "ongoing" )
type ServiceEntry ¶
type ServiceEntry struct {
core.BaseRecordProxy
}
ServiceEntry RecordProxy for collection `serviceentries`. Provides type-safe struct access to service entry records.
func (*ServiceEntry) AdminComment ¶
func (s *ServiceEntry) AdminComment() string
func (*ServiceEntry) BoardMember ¶
func (s *ServiceEntry) BoardMember() string
func (*ServiceEntry) Club ¶
func (s *ServiceEntry) Club() string
func (*ServiceEntry) CollectionName ¶
func (s *ServiceEntry) CollectionName() string
func (*ServiceEntry) Description ¶
func (s *ServiceEntry) Description() string
func (*ServiceEntry) HideAdminFields ¶
func (s *ServiceEntry) HideAdminFields()
func (*ServiceEntry) ID ¶
func (s *ServiceEntry) ID() string
func (*ServiceEntry) Member ¶
func (s *ServiceEntry) Member() string
func (*ServiceEntry) Minutes ¶
func (s *ServiceEntry) Minutes() int
func (*ServiceEntry) ServiceDate ¶
func (s *ServiceEntry) ServiceDate() types.DateTime
func (*ServiceEntry) SetAdminComment ¶
func (s *ServiceEntry) SetAdminComment(comment string)
func (*ServiceEntry) SetBoardMember ¶
func (s *ServiceEntry) SetBoardMember(id string)
func (*ServiceEntry) SetClub ¶
func (s *ServiceEntry) SetClub(id string)
func (*ServiceEntry) SetDescription ¶
func (s *ServiceEntry) SetDescription(description string)
func (*ServiceEntry) SetMember ¶
func (s *ServiceEntry) SetMember(id string)
func (*ServiceEntry) SetMinutes ¶
func (s *ServiceEntry) SetMinutes(minutes int)
func (*ServiceEntry) SetServiceDate ¶
func (s *ServiceEntry) SetServiceDate(dt types.DateTime)
func (*ServiceEntry) SetTitle ¶
func (s *ServiceEntry) SetTitle(title string)
func (*ServiceEntry) Title ¶
func (s *ServiceEntry) Title() string
type SimpleCount ¶
type SimpleCount struct {
Count int `json:"count" db:"count"`
}
type Team ¶
type Team struct {
core.BaseRecordProxy
}
Team RecordProxy for collection `teams`. Provides type-safe struct access to team records.
func (*Team) BSMLeagueGroup ¶
func (*Team) CollectionName ¶
func (*Team) Description ¶
func (*Team) HideSignupKey ¶
func (t *Team) HideSignupKey()
func (*Team) SetAgeGroup ¶
func (*Team) SetBSMLeagueGroup ¶
func (*Team) SetDescription ¶
func (*Team) SetSignupKey ¶
func (*Team) UnhideSignupKey ¶
func (t *Team) UnhideSignupKey()
type TeamWithSignupKey ¶
type TeamWithSignupKey struct {
Id string `db:"id"`
Club string `db:"club"`
SignupKey string `db:"signup_key"`
}
TeamWithSignupKey represents a reduced record with just the relevant fields.
type User ¶
type User struct {
core.BaseRecordProxy
}
User RecordProxy for collection `users`. Provides type-safe struct access to user records.
func (*User) CollectionName ¶
func (*User) DisplayName ¶
func (*User) DisplayOnWebsite ¶
func (*User) EmailVisibility ¶
func (*User) SetBirthday ¶
func (*User) SetDisplayName ¶
func (*User) SetDisplayOnWebsite ¶
func (*User) SetEmailVisibility ¶
func (*User) SetFirstName ¶
func (*User) SetICalLink ¶
SetICalLink sets the user's custom iCal link. Requires `WithCustomData` to be set.
func (*User) SetLastLogin ¶
func (*User) SetLastName ¶
func (*User) SetPosition ¶
func (*User) SetSignupKey ¶
func (*User) SetUsername ¶
func (*User) SetVerified ¶
type UserCommunityServiceData ¶
type UserCommunityServiceData struct {
User User `json:"user"`
Season int `json:"season"`
Items []UserCommunityServiceItem `json:"items"`
}
type UserCommunityServiceItem ¶
type UserCommunityServiceItem struct {
Club Club `json:"club"`
CurrentMinutes int `json:"current_minutes"`
Entries []ServiceEntry `json:"entries"`
}
type UserParticipationDTO ¶
type UserServiceApp ¶
type UserServiceApp interface {
FindRecordsByFilter(collectionModelOrIdentifier any, filter string, sort string, limit int, offset int, params ...dbx.Params) ([]*core.Record, error)
Logger() *slog.Logger
ExpandRecords(records []*core.Record, expands []string, optFetchFunc core.ExpandFetchFunc) map[string]error
}
Source Files
¶
- PersonalAttendanceStatsItem.go
- announcement.go
- block_noise.go
- club.go
- community_service.go
- community_service_data.go
- count.go
- date_time_utility.go
- diamond_planner.go
- enrich_event_participation_data.go
- error_handling.go
- event.go
- event_series.go
- event_type.go
- hash.go
- hook_community_service.go
- hook_manage_event_series.go
- hooks_announcement.go
- hooks_event.go
- hooks_team.go
- hooks_user.go
- import_Games.go
- import_LeagueGroups.go
- interface_helpers.go
- last_login.go
- league_group.go
- location.go
- participationByPerson.go
- participation_type.go
- participations.go
- personal_stats.go
- push_service.go
- push_subscription.go
- record_proxy.go
- requireUserAccess.go
- response_status.go
- route_personal_stats.go
- route_start_LeagueGroups_import.go
- routes_club_admin.go
- routes_community_service.go
- routes_ical.go
- routes_push.go
- routes_teams.go
- signup_key.go
- team.go
- trigger_league_import.go
- user.go
- user_queries.go