public void TrustContact(int contactId) { Pull(); Log("Sending TRUST_CONTACT command."); TextEncoder.SendCommand(stream, ConnectionCommand.TRUST_CONTACT); TextEncoder.SendInt(stream, contactId); using (Context context = new Context(config)) { var contact = context.Contacts .Where(u => u.PublicId == contactId) .SingleOrDefault(); contact.Trusted = 1; context.SaveChanges(); if (contact.SendAesKey == null) { AESPassword password = AESPassword.GenerateAESPassword(); JAESKey key = new JAESKey(contactId, password); PushOperations.SendIJType(context, key, UserId, UserId); X509Certificate2 cert = X509Certificate2Utils.ImportFromPem( context.Contacts .Where(u => u.PublicId == contactId) .Select(u => u.PublicCertificate) .SingleOrDefault()); BinaryEncoder.SendBytes(stream, RSAEncoder.Encrypt(password.Password, cert)); context.SaveChanges(); } } Push(); }
public void DoDelete(Context context) { foreach (var message in context.Messages .Where(u => u.IdMessagesThread == thread.PublicId)) { DMessage dMessage = new DMessage(message, myUserId); dMessage.DoDelete(context); } context.MessagesThread.Remove(thread); var jthread = new JMessageThread() { PublicId = thread.PublicId, DoOnlyDelete = true }; PushOperations.SendIJType(context, jthread, myUserId, myUserId); //PushOperations.DeleteBlobMessage(context, thread.GetBlobId(), myUserId); //Piggy bug fix //throw new NotSupportedException("Not supported, because developer of this app is absolutly useless."); }