func ReadMessages(info *vault.AccountInfo, routingInfo *resolver.RoutingInfo, box, messageID string, since time.Time) {
	client, err := api.NewAuthenticated(*info.Address, info.GetActiveKey().PrivKey, routingInfo.Routing, internal.JwtErrorFunc)
	if err != nil {
		logrus.Fatal(err)
	}

	// generate a message list of all messages we want do display
	fmt.Print("* Fetching messages from remote server(s)...")
	messageList := queryMessages(client, info, box, messageID, since)
	fmt.Println("")

	if len(messageList) == 0 {
		fmt.Println("*  No messages found to read.")
		return
	}

	readDone := false
	idx := 0

	// iterate list until we quit
	for !readDone {
		// Find key, or iterate all keys when key is not found
		keys := info.Keys
		key, err := info.FindKey(messageList[idx].Header.To.Fingerprint)
		if err == nil {
			keys = []vault.KeyPair{*key}
		}

		// Iterate all keys (or the single key), and see if we can decrypt the message
		var decryptedMsg *message.DecryptedMessage
		for _, key := range keys {
			var err error
			decryptedMsg, err = messageList[idx].Decrypt(key.PrivKey)
			if err == nil {
				break
			}
			decryptedMsg = nil
		}

		// Display message or fail when not decrypted
		if decryptedMsg != nil {
			displayMessage(*decryptedMsg)
		} else {
			fmt.Println("Cannot decrypt message: ", err)
		}

		parseDone := false
		for !parseDone {
			readDone, parseDone = parseCommands(&idx, messageList, decryptedMsg)
		}
	}
}
// ReadMessages will read a specific message blocks
ReadMessages will read a specific message blocks
// ReadMessages will read a specific message blocks
func ReadMessages(info *vault.AccountInfo, routingInfo *resolver.RoutingInfo, box, messageID string, since time.Time) {
	client, err := api.NewAuthenticated(*info.Address, info.GetActiveKey().PrivKey, routingInfo.Routing, internal.JwtErrorFunc)
	if err != nil {
		logrus.Fatal(err)
	}
	fmt.Print("* Fetching messages from remote server(s)...")
	messageList := queryMessages(client, info, box, messageID, since)
	fmt.Println("")
	if len(messageList) == 0 {
		fmt.Println("*  No messages found to read.")
		return
	}
	readDone := false
	idx := 0
	for !readDone {
		keys := info.Keys
		key, err := info.FindKey(messageList[idx].Header.To.Fingerprint)
		if err == nil {
			keys = []vault.KeyPair{*key}
		}
		var decryptedMsg *message.DecryptedMessage
		for _, key := range keys {
			var err error
			decryptedMsg, err = messageList[idx].Decrypt(key.PrivKey)
			if err == nil {
				break
			}
			decryptedMsg = nil
		}
		if decryptedMsg != nil {
			displayMessage(*decryptedMsg)
		} else {
			fmt.Println("Cannot decrypt message: ", err)
		}
		parseDone := false
		for !parseDone {
			readDone, parseDone = parseCommands(&idx, messageList, decryptedMsg)
		}
	}
}
func ReadMessages ( info * vault . AccountInfo , routingInfo * resolver . RoutingInfo , box , messageID string , since time . Time ) { client , err := api . NewAuthenticated ( * info . Address , info . GetActiveKey ( ) . PrivKey , routingInfo . Routing , internal . JwtErrorFunc ) if err != nil { logrus . Fatal ( err ) } fmt . Print ( " " ) messageList := queryMessages ( client , info , box , messageID , since ) fmt . Println ( " " ) if len ( messageList ) == 0 { fmt . Println ( " " ) return } readDone := false idx := 0 for ! readDone { keys := info . Keys key , err := info . FindKey ( messageList [ idx ] . Header . To . Fingerprint ) if err == nil { keys = [ ] vault . KeyPair { * key } } var decryptedMsg * message . DecryptedMessage for _ , key := range keys { var err error decryptedMsg , err = messageList [ idx ] . Decrypt ( key . PrivKey ) if err == nil { break } decryptedMsg = nil } if decryptedMsg != nil { displayMessage ( * decryptedMsg ) } else { fmt . Println ( " " , err ) } parseDone := false for ! parseDone { readDone , parseDone = parseCommands ( & idx , messageList , decryptedMsg ) } } }
ReadMessages will read a specific message blocks
ReadMessages will read a specific message blocks
// generate a message list of all messages we want do display // iterate list until we quit // Find key, or iterate all keys when key is not found // Iterate all keys (or the single key), and see if we can decrypt the message // Display message or fail when not decrypted