[core] Allow plugins to evaluate whether permissions are available

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2022-12-05 18:57:41 +01:00
parent a06d8fa1cd
commit 29ce8820bf
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5
2 changed files with 9 additions and 0 deletions

View file

@ -33,6 +33,9 @@ type (
ActorDocumentationRegistrationFunc func(ActionDocumentation)
ChannelPermissionCheckFunc func(channel string, scopes ...string) (bool, error)
ChannelAnyPermissionCheckFunc func(channel string, scopes ...string) (bool, error)
CronRegistrationFunc func(spec string, cmd func()) (cron.EntryID, error)
EventHandlerFunc func(evt string, eventData *FieldCollection) error
@ -64,6 +67,10 @@ type (
GetTwitchClient func() *twitch.Client
// GetTwitchClientForChannel retrieves a fully configured Twitch client with initialized cache for extended permission channels
GetTwitchClientForChannel func(string) (*twitch.Client, error)
// HasAnyPermissionForChannel checks whether ANY of the given permissions were granted for the given channel
HasAnyPermissionForChannel ChannelAnyPermissionCheckFunc
// HasPermissionForChannel checks whether ALL of the given permissions were granted for the given channel
HasPermissionForChannel ChannelPermissionCheckFunc
// RegisterActor is used to register a new IRC rule-actor implementing the Actor interface
RegisterActor ActorRegistrationFunc
// RegisterActorDocumentation is used to register an ActorDocumentation for the config editor

View file

@ -126,6 +126,8 @@ func getRegistrationArguments() plugins.RegistrationArguments {
GetDatabaseConnector: func() database.Connector { return db },
GetLogger: func(moduleName string) *log.Entry { return log.WithField("module", moduleName) },
GetTwitchClient: func() *twitch.Client { return twitchClient },
HasAnyPermissionForChannel: accessService.HasAnyPermissionForChannel,
HasPermissionForChannel: accessService.HasPermissionsForChannel,
RegisterActor: registerAction,
RegisterActorDocumentation: registerActorDocumentation,
RegisterAPIRoute: registerRoute,