fix conversation lookup for smp initialization

This commit is contained in:
kosyak 2024-10-29 17:30:57 +07:00
parent 948fd85a43
commit e1e2de8a76

View file

@ -107,7 +107,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) { public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
try { try {
final Jid jid = OtrJidHelper.fromSessionID(id); final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null); Conversation conversation = this.mXmppConnectionService.find(this.account, jid, jid);
if (conversation != null) { if (conversation != null) {
conversation.smp().hint = question; conversation.smp().hint = question;
conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED; conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED;
@ -187,7 +187,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
MessageGenerator.addMessageHints(packet); MessageGenerator.addMessageHints(packet);
try { try {
Jid jid = OtrJidHelper.fromSessionID(session); Jid jid = OtrJidHelper.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account, jid, null); Conversation conversation = mXmppConnectionService.find(account, jid, jid);
if (conversation != null && conversation.setOutgoingChatState(Config.DEFAULT_CHAT_STATE)) { if (conversation != null && conversation.setOutgoingChatState(Config.DEFAULT_CHAT_STATE)) {
if (mXmppConnectionService.sendChatStates()) { if (mXmppConnectionService.sendChatStates()) {
packet.addChild(ChatState.toElement(conversation.getOutgoingChatState())); packet.addChild(ChatState.toElement(conversation.getOutgoingChatState()));
@ -233,7 +233,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
private void setSmpStatus(SessionID id, int status) { private void setSmpStatus(SessionID id, int status) {
try { try {
final Jid jid = OtrJidHelper.fromSessionID(id); final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null); Conversation conversation = this.mXmppConnectionService.find(this.account, jid, jid);
if (conversation != null) { if (conversation != null) {
conversation.smp().status = status; conversation.smp().status = status;
mXmppConnectionService.updateConversationUi(); mXmppConnectionService.updateConversationUi();
@ -264,7 +264,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
public void sendOtrErrorMessage(SessionID session, String errorText) { public void sendOtrErrorMessage(SessionID session, String errorText) {
try { try {
Jid jid = OtrJidHelper.fromSessionID(session); Jid jid = OtrJidHelper.fromSessionID(session);
Conversation conversation = mXmppConnectionService.find(account, jid, null); Conversation conversation = mXmppConnectionService.find(account, jid, jid);
String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId(); String id = conversation == null ? null : conversation.getLastReceivedOtrMessageId();
if (id != null) { if (id != null) {
MessagePacket packet = mXmppConnectionService.getMessageGenerator() MessagePacket packet = mXmppConnectionService.getMessageGenerator()
@ -290,7 +290,7 @@ public class OtrService extends OtrCryptoEngineImpl implements OtrEngineHost {
Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")"); Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
try { try {
final Jid jid = OtrJidHelper.fromSessionID(id); final Jid jid = OtrJidHelper.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid, null); Conversation conversation = this.mXmppConnectionService.find(this.account, jid, jid);
if (conversation != null) { if (conversation != null) {
if (approved) { if (approved) {
conversation.getContact().addOtrFingerprint(fingerprint); conversation.getContact().addOtrFingerprint(fingerprint);