add client:accepttos command

This commit is contained in:
sawka 2023-04-04 21:52:20 -07:00
parent 1d5fe3c5be
commit f6c6a40aba
4 changed files with 28 additions and 3 deletions

View File

@ -177,6 +177,7 @@ func init() {
registerCmdFn("client:show", ClientShowCommand)
registerCmdFn("client:set", ClientSetCommand)
registerCmdFn("client:notifyupdatewriter", ClientNotifyUpdateWriterCommand)
registerCmdFn("client:accepttos", ClientAcceptTosCommand)
registerCmdFn("telemetry", TelemetryCommand)
registerCmdFn("telemetry:on", TelemetryOnCommand)
@ -2798,6 +2799,27 @@ func boolToStr(v bool, trueStr string, falseStr string) string {
return falseStr
}
func ClientAcceptTosCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
clientData, err := sstore.EnsureClientData(ctx)
if err != nil {
return nil, fmt.Errorf("cannot retrieve client data: %v", err)
}
clientOpts := clientData.ClientOpts
clientOpts.AcceptedTos = time.Now().UnixMilli()
err = sstore.SetClientOpts(ctx, clientOpts)
if err != nil {
return nil, fmt.Errorf("error updating client data: %v", err)
}
clientData, err = sstore.EnsureClientData(ctx)
if err != nil {
return nil, fmt.Errorf("cannot retrieve updated client data: %v", err)
}
update := sstore.ModelUpdate{
ClientData: clientData,
}
return update, nil
}
func ClientSetCommand(ctx context.Context, pk *scpacket.FeCommandPacketType) (sstore.UpdatePacket, error) {
clientData, err := sstore.EnsureClientData(ctx)
if err != nil {

View File

@ -77,6 +77,8 @@ func SubMetaCmd(cmd string) string {
return "eval"
case "export":
return "setenv"
case "connection":
return "remote"
default:
return cmd
}

View File

@ -2499,10 +2499,10 @@ func insertScreenUpdate(tx *TxWrap, screenId string, updateType string) {
func insertScreenNewUpdate(tx *TxWrap, screenId string) {
nowTs := time.Now().UnixMilli()
query := `INSERT INTO screenupdate (screenid, lineid, updatetype, updatets)
SELECT screenid, lineid, ?, ? FROM line WHERE screenid = ? AND NOT archived ORDER BY linenum`
SELECT screenid, lineid, ?, ? FROM line WHERE screenid = ? AND NOT archived ORDER BY linenum DESC`
tx.Exec(query, UpdateType_LineNew, nowTs, screenId)
query = `INSERT INTO screenupdate (screenid, lineid, updatetype, updatets)
SELECT c.screenid, l.lineid, ?, ? FROM cmd c, line l WHERE c.screenid = ? AND l.cmdid = c.cmdid AND NOT l.archived`
SELECT c.screenid, l.lineid, ?, ? FROM cmd c, line l WHERE c.screenid = ? AND l.cmdid = c.cmdid AND NOT l.archived ORDER BY l.linenum DESC`
tx.Exec(query, UpdateType_PtyPos, nowTs, screenId)
NotifyUpdateWriter()
}

View File

@ -212,7 +212,8 @@ func (tdata *TelemetryData) Scan(val interface{}) error {
}
type ClientOptsType struct {
NoTelemetry bool `json:"notelemetry,omitempty"`
NoTelemetry bool `json:"notelemetry,omitempty"`
AcceptedTos int64 `json:"acceptedtos,omitempty"`
}
type FeOptsType struct {