chore: linted
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of the Auto Attendance app that looks for
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// browser.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of the Auto Attendance app that looks for
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// browser.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -46,10 +46,10 @@ type AppConfig struct {
|
||||
}
|
||||
|
||||
type ScreenshotConfig struct {
|
||||
ScreenIndex int `mapstructure:"screen_index"`
|
||||
Interval int `mapstructure:"interval"`
|
||||
ScreenIndex int `mapstructure:"screen_index"`
|
||||
Interval int `mapstructure:"interval"`
|
||||
Directory string `mapstructure:"directory"`
|
||||
BufferCount int `mapstructure:"buffer_count"`
|
||||
BufferCount int `mapstructure:"buffer_count"`
|
||||
}
|
||||
|
||||
type CommunicationConfig struct {
|
||||
@@ -84,8 +84,8 @@ func getDefaultConfig() Config {
|
||||
},
|
||||
Screenshot: ScreenshotConfig{
|
||||
ScreenIndex: 0,
|
||||
Interval: 5,
|
||||
Directory: getTempDirectoryPath(),
|
||||
Interval: 5,
|
||||
Directory: getTempDirectoryPath(),
|
||||
BufferCount: 5,
|
||||
},
|
||||
Logging: LoggingConfig{
|
||||
|
||||
@@ -52,10 +52,10 @@ func (v *linkValidatorImpl) ValidateLink(rawURL string) (token string, ok bool)
|
||||
if v.config.Communication.QrUrl != "" {
|
||||
expectedURL, err := url.Parse(v.config.Communication.QrUrl)
|
||||
if err == nil {
|
||||
if parsedURL.Scheme != expectedURL.Scheme ||
|
||||
parsedURL.Host != expectedURL.Host ||
|
||||
parsedURL.Path != expectedURL.Path {
|
||||
v.log.Debug("URL doesn't match configured QR URL pattern",
|
||||
if parsedURL.Scheme != expectedURL.Scheme ||
|
||||
parsedURL.Host != expectedURL.Host ||
|
||||
parsedURL.Path != expectedURL.Path {
|
||||
v.log.Debug("URL doesn't match configured QR URL pattern",
|
||||
"url", rawURL, "expected", v.config.Communication.QrUrl)
|
||||
return "", false
|
||||
}
|
||||
@@ -64,7 +64,7 @@ func (v *linkValidatorImpl) ValidateLink(rawURL string) (token string, ok bool)
|
||||
|
||||
if v.config.Communication.ApiSelfApproveMethod != "" {
|
||||
if !strings.Contains(parsedURL.Path, v.config.Communication.ApiSelfApproveMethod) {
|
||||
v.log.Debug("URL doesn't contain expected API method",
|
||||
v.log.Debug("URL doesn't contain expected API method",
|
||||
"url", parsedURL.Path, "expected", v.config.Communication.ApiSelfApproveMethod)
|
||||
return "", false
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of the Auto Attendance app that looks for
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// browser.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -43,15 +43,15 @@ var (
|
||||
|
||||
type wholeScreenCapturer struct {
|
||||
config *config.Config
|
||||
log *logger.Logger
|
||||
log *logger.Logger
|
||||
|
||||
displayIndex int
|
||||
displayBounds image.Rectangle
|
||||
interval int
|
||||
bufferCount int
|
||||
displayIndex int
|
||||
displayBounds image.Rectangle
|
||||
interval int
|
||||
bufferCount int
|
||||
tempDirectory string
|
||||
initialized bool
|
||||
running bool
|
||||
initialized bool
|
||||
running bool
|
||||
|
||||
files []string
|
||||
latest string
|
||||
@@ -189,7 +189,7 @@ func (w *wholeScreenCapturer) captureAndSave() (string, error) {
|
||||
|
||||
func (w *wholeScreenCapturer) addToBuffer(fp string) {
|
||||
w.mu.Lock()
|
||||
defer w.mu.Unlock()
|
||||
defer w.mu.Unlock()
|
||||
w.files = append(w.files, fp)
|
||||
w.latest = fp
|
||||
|
||||
@@ -208,20 +208,22 @@ func (w *wholeScreenCapturer) createTempDirectory() (path string, err error) {
|
||||
return os.MkdirTemp(w.config.Screenshot.Directory, constants.AppName+"-*")
|
||||
}
|
||||
|
||||
func NewWholeScreenCapturer(lc fx.Lifecycle, config *config.Config, log *logger.Logger) ScreenCapturer {
|
||||
func NewWholeScreenCapturer(
|
||||
lc fx.Lifecycle, config *config.Config, log *logger.Logger,
|
||||
) ScreenCapturer {
|
||||
capturer := &wholeScreenCapturer{
|
||||
config: config,
|
||||
log: log,
|
||||
done: make(chan struct{}),
|
||||
}
|
||||
lc.Append(fx.StopHook(func(ctx context.Context) error {
|
||||
if (!capturer.initialized) {
|
||||
if !capturer.initialized {
|
||||
log.Debug("wholescreencapturer not initialized, nothing to do")
|
||||
return nil
|
||||
}
|
||||
|
||||
log.Debug("stopping wholescreencapturer")
|
||||
|
||||
|
||||
err := capturer.Stop()
|
||||
if err != nil {
|
||||
log.Error("failed to stop wholescreencapturer gracefully")
|
||||
@@ -237,4 +239,3 @@ func NewWholeScreenCapturer(lc fx.Lifecycle, config *config.Config, log *logger.
|
||||
}))
|
||||
return capturer
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ var (
|
||||
|
||||
// AnalyzeImage implements Vision.
|
||||
func (v *visionImpl) AnalyzeImage(filePath string) (data VisionData, err error) {
|
||||
// TODO: scanning for multiple QR-codes at once
|
||||
v.log.Debug("analyzing image for qr codes", "filePath", filePath)
|
||||
|
||||
img := gocv.IMRead(filePath, gocv.IMReadColor)
|
||||
@@ -78,7 +79,7 @@ func (v *visionImpl) AnalyzeImage(filePath string) (data VisionData, err error)
|
||||
}
|
||||
|
||||
v.log.Info("QR code decoded successfully", "content", result.GetText())
|
||||
|
||||
|
||||
data = VisionData{result.GetText()}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of the Auto Attendance app that looks for
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// self-attend QR-codes during lectures and opens their URLs in your
|
||||
// browser.
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
||||
Reference in New Issue
Block a user