X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/87c59e9c7d6743cdd04c0d5e89d3baca173aad42..77f29e78734dc16cfcea5f41b8e0185f8b33534a:/daemon.go diff --git a/daemon.go b/daemon.go index 898de68..e534aea 100644 --- a/daemon.go +++ b/daemon.go @@ -204,12 +204,24 @@ func (h *DaemonHub) read(ctx context.Context, client *DaemonClient, l *TurnLoop) err := json.Unmarshal(scanner.Bytes(), &request) if err == nil { - err = daemonRunRequest(l, h.whatsapp, request, func(text string) { - h.Send(client, Event{ - Kind: "notice", - Text: text, + if request.Type == "backup" { + var size int64 + + size, err = backupData(ctx, filepath.Dir(l.agent.dir), request.Text, h.whatsapp, l.runs.Snapshot) + if err == nil { + h.Send(client, Event{ + Kind: "backup", + Text: fmt.Sprintf("%s (%d bytes)", request.Text, size), + }) + } + } else { + err = daemonRunRequest(l, h.whatsapp, request, func(text string) { + h.Send(client, Event{ + Kind: "notice", + Text: text, + }) }) - }) + } } if err != nil {