Fix stale cmd/ scripts, export LoginWithChromedp, clean up vet warnings

Update 5 cmd/ test utilities that referenced APIs that drifted after
bridge refactors (NewBrowserAuthManager, bridge.NewConfig, changed
function signatures). Rewrite test-kosmi and test-native to use
NewGraphQLWSClient directly. Export LoginWithChromedp for use by cmd
scripts. Fix redundant-newline vet warnings across 5 cmd/ files.
Remove unreachable code and replace deprecated ioutil calls in
bridge/helper/lottie_convert.go.

Made-with: Cursor
This commit is contained in:
cottongin
2026-04-05 05:49:26 -04:00
parent 4fc7f08b24
commit d314193540
12 changed files with 213 additions and 74 deletions

View File

@@ -3,7 +3,6 @@
package helper
import (
"io/ioutil"
"os"
"os/exec"
@@ -23,7 +22,7 @@ func CanConvertTgsToX() error {
// This relies on an external command, which is ugly, but works.
func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) error {
// lottie can't handle input from a pipe, so write to a temporary file:
tmpInFile, err := ioutil.TempFile(os.TempDir(), "matterbridge-lottie-input-*.tgs")
tmpInFile, err := os.CreateTemp(os.TempDir(), "matterbridge-lottie-input-*.tgs")
if err != nil {
return err
}
@@ -35,7 +34,7 @@ func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) erro
}()
// lottie can handle writing to a pipe, but there is no way to do that platform-independently.
// "/dev/stdout" won't work on Windows, and "-" upsets Cairo for some reason. So we need another file:
tmpOutFile, err := ioutil.TempFile(os.TempDir(), "matterbridge-lottie-output-*.data")
tmpOutFile, err := os.CreateTemp(os.TempDir(), "matterbridge-lottie-output-*.data")
if err != nil {
return err
}
@@ -64,7 +63,7 @@ func ConvertTgsToX(data *[]byte, outputFormat string, logger *logrus.Entry) erro
// 'stderr' already contains some parts of Stderr, because it was set to 'nil'.
return stderr
}
dataContents, err := ioutil.ReadFile(tmpOutFileName)
dataContents, err := os.ReadFile(tmpOutFileName)
if err != nil {
return err
}
@@ -82,7 +81,6 @@ func SupportsFormat(format string) bool {
default:
return false
}
return false
}
func LottieBackend() string {

View File

@@ -9,9 +9,9 @@ import (
"github.com/sirupsen/logrus"
)
// loginWithChromedp uses browser automation to log in and extract the JWT token.
// LoginWithChromedp uses browser automation to log in and extract the JWT token.
// This is the proven implementation that successfully authenticates users.
func loginWithChromedp(email, password string, log *logrus.Entry) (string, error) {
func LoginWithChromedp(email, password string, log *logrus.Entry) (string, error) {
log.Info("Starting browser automation for authentication...")
// Create context with timeout

View File

@@ -82,7 +82,7 @@ func (b *Bkosmi) Connect() error {
} else {
// No valid cache, authenticate with browser
b.Log.Info("Authenticating with email/password...")
token, err = loginWithChromedp(email, password, b.Log)
token, err = LoginWithChromedp(email, password, b.Log)
if err != nil {
return fmt.Errorf("authentication failed: %w", err)
}