mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-25 17:08:47 -05:00
faulty otr messages now generate an error
This commit is contained in:
parent
3bb585c020
commit
3a57f6df89
@ -88,4 +88,22 @@ public class MessageGenerator {
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
public MessagePacket generateNotAcceptable(MessagePacket origin) {
|
||||
MessagePacket packet = generateError(origin);
|
||||
Element error = packet.addChild("error");
|
||||
error.setAttribute("type", "modify");
|
||||
error.setAttribute("code", "406");
|
||||
error.addChild("not-acceptable");
|
||||
return packet;
|
||||
}
|
||||
|
||||
private MessagePacket generateError(MessagePacket origin) {
|
||||
MessagePacket packet = new MessagePacket();
|
||||
packet.setId(origin.getId());
|
||||
packet.setTo(origin.getFrom());
|
||||
packet.setBody(origin.getBody());
|
||||
packet.setType(MessagePacket.TYPE_ERROR);
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
|
@ -92,9 +92,9 @@ public class MessageParser extends AbstractParser {
|
||||
} catch (Exception e) {
|
||||
String receivedId = packet.getId();
|
||||
if (receivedId!=null) {
|
||||
mXmppConnectionService.replyWithError(account,packet);
|
||||
mXmppConnectionService.replyWithNotAcceptable(account,packet);
|
||||
}
|
||||
conversation.resetOtrSession();
|
||||
conversation.endOtrIfNeeded();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1475,8 +1475,10 @@ public class XmppConnectionService extends Service {
|
||||
return this.pm;
|
||||
}
|
||||
|
||||
public void replyWithError(Account account, MessagePacket packet) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void replyWithNotAcceptable(Account account, MessagePacket packet) {
|
||||
if (account.getStatus() == Account.STATUS_ONLINE) {
|
||||
MessagePacket error = this.mMessageGenerator.generateNotAcceptable(packet);
|
||||
account.getXmppConnection().sendMessagePacket(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user