From 27e891b2b59d398750dad901e1e9310023d7ca45 Mon Sep 17 00:00:00 2001
From: josh <josh@elixxir.io>
Date: Tue, 25 May 2021 11:00:10 -0700
Subject: [PATCH] Add delete-channel flag

---
 cmd/root.go | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/cmd/root.go b/cmd/root.go
index 9b11cfc79..91d463964 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -147,6 +147,11 @@ var rootCmd = &cobra.Command{
 			authConfirmed = true
 		}
 
+		// Delete this recipient
+		if viper.GetBool("delete-channel") {
+			deleteChannel(client, recipientID)
+		}
+
 		if client.HasAuthenticatedChannel(recipientID) {
 			jww.INFO.Printf("Authenticated channel already in "+
 				"place for %s", recipientID)
@@ -420,6 +425,13 @@ func acceptChannel(client *api.Client, recipientID *id.ID) {
 	}
 }
 
+func deleteChannel(client *api.Client, partnerId *id.ID)  {
+	err := client.DeleteContact(partnerId)
+	if err != nil {
+		jww.FATAL.Panicf("%+v", err)
+	}
+}
+
 func printChanRequest(requestor contact.Contact, message string) {
 	msg := fmt.Sprintf("Authentication channel request from: %s\n",
 		requestor.ID)
@@ -748,6 +760,10 @@ func init() {
 	viper.BindPFlag("accept-channel",
 		rootCmd.Flags().Lookup("accept-channel"))
 
+	rootCmd.Flags().Bool("delete-channel", false,
+		"Delete the channel information for the corresponding recipient ID")
+	viper.BindPFlag("delete-channel", rootCmd.Flags().Lookup("delete-channel"))
+
 	rootCmd.Flags().BoolP("send-auth-request", "", false,
 		"Send an auth request to the specified destination and wait"+
 			"for confirmation")
-- 
GitLab