Skip to content
Snippets Groups Projects
Commit 13fc8688 authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

Merge branch 'hotfix/checkchan' into 'release'

Remove the check for a channel request and add a flag to crash if an...

See merge request !522
parents ec1b14a4 b6704dc8
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,8 @@ var rootCmd = &cobra.Command{ ...@@ -116,7 +116,8 @@ var rootCmd = &cobra.Command{
// Send unsafe messages or not? // Send unsafe messages or not?
unsafe := viper.GetBool("unsafe") unsafe := viper.GetBool("unsafe")
if !unsafe { assumeAuth := viper.GetBool("assume-auth-channel")
if !unsafe && !assumeAuth {
addAuthenticatedChannel(client, recipientID, addAuthenticatedChannel(client, recipientID,
recipientContact, isPrecanPartner) recipientContact, isPrecanPartner)
} }
...@@ -376,26 +377,13 @@ func addAuthenticatedChannel(client *api.Client, recipientID *id.ID, ...@@ -376,26 +377,13 @@ func addAuthenticatedChannel(client *api.Client, recipientID *id.ID,
jww.FATAL.Panicf("User did not allow channel creation!") jww.FATAL.Panicf("User did not allow channel creation!")
} }
// Check if a channel exists for this recipientID
recipientContact, err := client.GetAuthenticatedChannelRequest(
recipientID)
if err == nil {
jww.INFO.Printf("Accepting existing channel request for %s",
recipientID)
err := client.ConfirmAuthenticatedChannel(recipientContact)
if err != nil {
jww.FATAL.Panicf("%+v", err)
}
return
} else {
recipientContact = recipient
}
msg := fmt.Sprintf("Adding authenticated channel for: %s\n", msg := fmt.Sprintf("Adding authenticated channel for: %s\n",
recipientID) recipientID)
jww.INFO.Printf(msg) jww.INFO.Printf(msg)
fmt.Printf(msg) fmt.Printf(msg)
recipientContact := recipient
if isPrecanPartner { if isPrecanPartner {
jww.WARN.Printf("Precanned user id detected: %s", jww.WARN.Printf("Precanned user id detected: %s",
recipientID) recipientID)
...@@ -680,6 +668,11 @@ func init() { ...@@ -680,6 +668,11 @@ func init() {
viper.BindPFlag("unsafe-channel-creation", viper.BindPFlag("unsafe-channel-creation",
rootCmd.Flags().Lookup("unsafe-channel-creation")) rootCmd.Flags().Lookup("unsafe-channel-creation"))
rootCmd.Flags().BoolP("assume-auth-channel", "", false,
"Do not check for an authentication channel for this user")
viper.BindPFlag("assume-auth-channel",
rootCmd.Flags().Lookup("assume-auth-channel"))
rootCmd.Flags().BoolP("accept-channel", "", false, rootCmd.Flags().BoolP("accept-channel", "", false,
"Accept the channel request for the corresponding recipient ID") "Accept the channel request for the corresponding recipient ID")
viper.BindPFlag("accept-channel", viper.BindPFlag("accept-channel",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment