ultisuite-backend/internal/automation/scope.go
R3D347HR4Y 1d063237b9
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Integration tests (push) Waiting to run
CI / DB migrations (push) Waiting to run
feat(transcription): integrate Faster Whisper for Jitsi transcriptions
- Added support for Faster Whisper transcription via Jigasi and Skynet.
- Updated .env.example to include new environment variables for transcription settings.
- Enhanced Jitsi Docker Compose configuration to include Skynet and Jigasi services.
- Introduced new API endpoints for managing organizational folders in the drive service.
- Updated Nextcloud initialization script to enable external file mounting.
- Improved error handling and response structures in the drive API.
- Added new properties for organization settings related to transcription and agenda management.
2026-06-12 19:10:18 +02:00

102 lines
2.0 KiB
Go

package automation
import (
"github.com/ultisuite/ulti-backend/internal/apitokens"
)
type MailScope struct {
AllAccounts bool `json:"all_accounts"`
AccountIDs []string `json:"account_ids"`
}
type DriveScope struct {
AllFolders bool `json:"all_folders"`
FolderPaths []string `json:"folder_paths"`
}
type ContactsScope struct {
AllBooks bool `json:"all_books"`
BookIDs []string `json:"book_ids"`
}
type AgendaScope struct {
AllCalendars bool `json:"all_calendars"`
CalendarIDs []string `json:"calendar_ids"`
}
func AllowsMailScope(scope MailScope, accountID string) bool {
if accountID == "" {
return true
}
if scope.AllAccounts {
return true
}
for _, id := range scope.AccountIDs {
if id == accountID {
return true
}
}
return false
}
func AllowsDriveScope(scope DriveScope, filePath string) bool {
if scope.AllFolders {
return true
}
target := apitokens.NormalizeDriveScopePath(filePath)
if target == "" {
return true
}
for _, allowed := range scope.FolderPaths {
if apitokens.NormalizeDriveScopePath(allowed) == "/" {
return true
}
if drivePathWithinScope(target, allowed) {
return true
}
}
return false
}
func drivePathWithinScope(target, allowed string) bool {
target = apitokens.NormalizeDriveScopePath(target)
allowed = apitokens.NormalizeDriveScopePath(allowed)
if allowed == "/" {
return true
}
if target == allowed {
return true
}
return len(target) > len(allowed) && target[:len(allowed)+1] == allowed+"/"
}
func AllowsContactsScope(scope ContactsScope, bookID string) bool {
if bookID == "" {
return true
}
if scope.AllBooks {
return true
}
for _, id := range scope.BookIDs {
if id == bookID {
return true
}
}
return false
}
func AllowsAgendaScope(scope AgendaScope, calendarID string) bool {
if calendarID == "" {
return true
}
if scope.AllCalendars {
return true
}
for _, id := range scope.CalendarIDs {
if id == calendarID {
return true
}
}
return false
}