mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-22 22:28:51 +01:00
Refactor out deletion request handling to prep for #33
This commit is contained in:
parent
dd887b5a42
commit
d15376f37d
@ -3,7 +3,6 @@ package cmd
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@ -89,15 +88,7 @@ func deleteOnRemoteInstances(ctx *context.Context, historyEntries []*data.Histor
|
||||
for _, entry := range historyEntries {
|
||||
deletionRequest.Messages.Ids = append(deletionRequest.Messages.Ids, shared.MessageIdentifier{Date: entry.EndTime, DeviceId: entry.DeviceId})
|
||||
}
|
||||
data, err := json.Marshal(deletionRequest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = lib.ApiPost("/api/v1/add-deletion-request", "application/json", data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send deletion request to backend service, this may cause commands to not get deleted on other instances of hishtory: %v", err)
|
||||
}
|
||||
return nil
|
||||
return lib.SendDeletionRequest(deletionRequest)
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -1255,3 +1255,15 @@ func GetDumpRequests(config hctx.ClientConfig) ([]*shared.DumpRequest, error) {
|
||||
err = json.Unmarshal(resp, &dumpRequests)
|
||||
return dumpRequests, err
|
||||
}
|
||||
|
||||
func SendDeletionRequest(deletionRequest shared.DeletionRequest) error {
|
||||
data, err := json.Marshal(deletionRequest)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = ApiPost("/api/v1/add-deletion-request", "application/json", data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to send deletion request to backend service, this may cause commands to not get deleted on other instances of hishtory: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user