/// <summary> /// Wrapper to receive message and download files <see cref="Threema.MsgApi.Helpers.E2EHelper.ReceiveMessage"/> /// </summary> /// <param name="id">Sender id</param> /// <param name="from">From id</param> /// <param name="secret">From secret</param> /// <param name="privateKey">From private key</param> /// <param name="messageId">Message id</param> /// <param name="nonce">Nonce as hex-string</param> /// <param name="box">Box message as hex-string</param> /// <param name="outputFolder">Optional path to output folder</param> /// <param name="apiUrl">Optional api url</param> /// <returns>Array with message-type, message-id and message</returns> public ArrayList ReceiveMessage(string id, string from, string secret, string privateKey, string messageId, string nonce, string box, string outputFolder = null, string apiUrl = APIConnector.DEFAULTAPIURL) { byte[] privateKeyBytes = GetKey(privateKey, Key.KeyType.PRIVATE); byte[] nonceBytes = DataUtils.HexStringToByteArray(nonce); E2EHelper e2EHelper = new E2EHelper(this.CreateConnector(from, secret, apiUrl), privateKeyBytes); byte[] boxBytes = DataUtils.HexStringToByteArray(box); ReceiveMessageResult res = e2EHelper.ReceiveMessage(id, messageId, boxBytes, nonceBytes, outputFolder); ArrayList result = new ArrayList(); result.Add(res.Message.GetTypeCode().ToString()); result.Add(res.MessageId); result.Add(res.Message.ToString()); return(result); }
protected override void Execute() { string id = this.threemaId.Value; string from = this.fromField.Value; string secret = this.secretField.Value; byte[] privateKey = this.privateKeyField.GetValue(); byte[] nonce = this.nonceField.GetValue(); string messageId = this.messageIdField.Value; string outputFolder = this.outputFolderField.GetValue(); E2EHelper e2EHelper = new E2EHelper(this.CreateConnector(from, secret), privateKey); byte[] box = DataUtils.HexStringToByteArray(System.Console.ReadLine().Trim()); ReceiveMessageResult res = e2EHelper.ReceiveMessage(id, messageId, box, nonce, outputFolder); System.Console.WriteLine(res.Message.ToString()); res.Files.ForEach(f => { System.Console.WriteLine(f.FullName); }); }