mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-04 18:59:08 +01:00
limit screen sharing to 50 commands
This commit is contained in:
parent
0ee3af71bd
commit
fa8db1d80e
@ -2437,22 +2437,6 @@ func PurgeHistoryByIds(ctx context.Context, historyIds []string) ([]*HistoryItem
|
||||
})
|
||||
}
|
||||
|
||||
func CanScreenWebShare(screen *ScreenType) error {
|
||||
if screen == nil {
|
||||
return fmt.Errorf("cannot share screen, not found")
|
||||
}
|
||||
if screen.ShareMode == ShareModeWeb {
|
||||
return fmt.Errorf("screen is already shared to web")
|
||||
}
|
||||
if screen.ShareMode != ShareModeLocal {
|
||||
return fmt.Errorf("screen cannot be shared, invalid current share mode %q (must be local)", screen.ShareMode)
|
||||
}
|
||||
if screen.Archived {
|
||||
return fmt.Errorf("screen cannot be shared, must un-archive before sharing")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ScreenWebShareStart(ctx context.Context, screenId string, shareOpts ScreenWebShareOpts) error {
|
||||
return WithTx(ctx, func(tx *TxWrap) error {
|
||||
query := `SELECT screenid FROM screen WHERE screenid = ?`
|
||||
@ -2466,6 +2450,12 @@ func ScreenWebShareStart(ctx context.Context, screenId string, shareOpts ScreenW
|
||||
if shareMode != ShareModeLocal {
|
||||
return fmt.Errorf("screen cannot be shared, invalid current share mode %q (must be local)", shareMode)
|
||||
}
|
||||
query = `SELECT count(*) FROM line WHERE screenid = ? AND NOT archived`
|
||||
lineCount := tx.GetInt(query, screenId)
|
||||
if lineCount > MaxWebShareLineCount {
|
||||
return fmt.Errorf("screen cannot be shared, limited to a maximum of %d lines", MaxWebShareLineCount)
|
||||
go UpdateCurrentActivity(context.Background(), ActivityUpdate{WebShareLimit: 1})
|
||||
}
|
||||
query = `UPDATE screen SET sharemode = ?, webshareopts = ? WHERE screenid = ?`
|
||||
tx.Exec(query, ShareModeWeb, quickJson(shareOpts), screenId)
|
||||
insertScreenNewUpdate(tx, screenId)
|
||||
|
@ -33,6 +33,7 @@ const LineTypeText = "text"
|
||||
const LineNoHeight = -1
|
||||
const DBFileName = "prompt.db"
|
||||
const DBFileNameBackup = "backup.prompt.db"
|
||||
const MaxWebShareLineCount = 50
|
||||
|
||||
const DefaultSessionName = "default"
|
||||
const LocalRemoteAlias = "local"
|
||||
@ -177,6 +178,7 @@ type ActivityUpdate struct {
|
||||
HistoryView int
|
||||
BookmarksView int
|
||||
NumConns int
|
||||
WebShareLimit int
|
||||
BuildTime string
|
||||
}
|
||||
|
||||
@ -201,6 +203,7 @@ type TelemetryData struct {
|
||||
HistoryView int `json:"historyview,omitempty"`
|
||||
BookmarksView int `json:"bookmarksview,omitempty"`
|
||||
NumConns int `json:"numconns"`
|
||||
WebShareLimit int `json:"websharelimit,omitempty"`
|
||||
}
|
||||
|
||||
func (tdata TelemetryData) Value() (driver.Value, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user