diff --git a/cmd/signaldctl/cmd/message/send/send-message.go b/cmd/signaldctl/cmd/message/send/send-message.go index 2e9b60f..b0cd39d 100644 --- a/cmd/signaldctl/cmd/message/send/send-message.go +++ b/cmd/signaldctl/cmd/message/send/send-message.go @@ -20,6 +20,7 @@ import ( "fmt" "log" "os" + "path/filepath" "strings" "github.com/jedib0t/go-pretty/v6/table" @@ -28,11 +29,13 @@ import ( "gitlab.com/signald/signald-go/cmd/signaldctl/common" "gitlab.com/signald/signald-go/cmd/signaldctl/config" + v0 "gitlab.com/signald/signald-go/signald/client-protocol/v0" "gitlab.com/signald/signald-go/signald/client-protocol/v1" ) var ( - account string + account string + attachments []string SendMessageCmd = &cobra.Command{ Use: "send ", @@ -56,6 +59,7 @@ var ( req := v1.SendRequest{ Username: account, MessageBody: strings.Join(args[1:], " "), + Attachments: []*v0.JsonAttachment{}, } if strings.HasPrefix(args[0], "+") { @@ -64,6 +68,15 @@ var ( req.RecipientGroupID = args[0] } + for _, attachment := range attachments { + path, err := filepath.Abs(attachment) + if err != nil { + log.Fatal("error resolving attachment", err) + } + log.Println(path) + req.Attachments = append(req.Attachments, &v0.JsonAttachment{Filename: path}) + } + resp, err := req.Submit(common.Signald) if err != nil { log.Fatal("error sending request to signald: ", err) @@ -121,4 +134,5 @@ var ( func init() { SendMessageCmd.Flags().StringVarP(&account, "account", "a", "", "local account to use") + SendMessageCmd.Flags().StringSliceVarP(&attachments, "attachment", "A", []string{}, "attach a file to your outbound message. may be specified multiple times.") }