diff --git a/cmd/root.go b/cmd/root.go index 4181ac28c04c37ce508feb7747d228c7267583a6..fc8c0b7b08eeb0d65b9a620b2238efb26f93738d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -208,18 +208,18 @@ var rootCmd = &cobra.Command{ var recipientContact contact.Contact var recipientID *id.ID + destFile := viper.GetString("destfile") destId := viper.GetString("destid") sendId := viper.GetString("sendid") - if destId == "0" || sendId == destId { + if destFile != "" { + recipientContact = readContact(destFile) + recipientID = recipientContact.ID + } else if destId == "0" || sendId == destId { jww.INFO.Printf("Sending message to self") recipientID = receptionIdentity.ID recipientContact = receptionIdentity.GetContact() - } else if destId != "0" { - recipientContact = readContact() - recipientID = parseRecipient(destId) } else { - recipientContact = readContact() - recipientID = recipientContact.ID + recipientID = parseRecipient(destId) } isPrecanPartner := isPrecanID(recipientID) diff --git a/cmd/utils.go b/cmd/utils.go index aca4fc016ca31eae6efee3087791510ddef0ea42..12c01738e45ecae13c9a4fef3fdb4140f3284a42 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -87,8 +87,7 @@ func writeContact(c contact.Contact) { } } -func readContact() contact.Contact { - inputFilePath := viper.GetString("destfile") +func readContact(inputFilePath string) contact.Contact { if inputFilePath == "" { return contact.Contact{} }