fix MessageSend servlet response if called for passive peer

pull/51/head
reger 9 years ago
parent de46879637
commit 27a238062f

@ -7,7 +7,7 @@
<body id="MessageSend">
#%env/templates/header.template%#
#(mode)#
<!-- =========================== write message =========================== -->
<!-- (mode=0) =========================== write message =========================== -->
<h2>Send message</h2>
#(permission)#
<!-- we have no permission to send the message -->
@ -57,7 +57,7 @@
</p>
#(/permission)#
::
<!-- =========================== preview message =========================== -->
<!-- (mode=1) =========================== preview message =========================== -->
<h2>Preview message</h2>
#(permission)#
<!-- we have no permission to send the message -->
@ -124,7 +124,7 @@
</p>
#(/permission)#
::
<!-- =========================== send message =========================== -->
<!-- (mode=2) =========================== send message =========================== -->
<h2>Send message</h2>
#(status)#
<!-- Message send successfully -->
@ -144,8 +144,8 @@
#(/status)#
::
<!-- illegal usage of this page -->
<p>You cannot call this page directly. Instead, use a link on the <a href="Network.html">Network</a> page.</p>
<!-- (mode=3) ==== illegal usage of this page ==== -->
<p>You cannot call this page directly. Instead, use a link on the <a href="Network.html?page=1&maxCount=1000">Network</a> page.</p>
#(/mode)#
#%env/templates/footer.template%#

@ -60,7 +60,7 @@ public class MessageSend_p {
final serverObjects prop = new serverObjects();
if ((post == null) || (post.get("hash","").isEmpty())) {
prop.put("mode", "2");
prop.put("mode", "3");
return prop;
}
@ -78,6 +78,7 @@ public class MessageSend_p {
// open an editor page for the message
// first ask if the other peer is online, and also what kind of document it accepts
Seed seed = sb.peers.getConnected(ASCII.getBytes(hash));
if (seed != null) {
for (String ip : seed.getIPs()) {
final Map<String, String> result = Protocol.permissionMessage(seed.getPublicAddress(ip), hash);
//System.out.println("DEBUG: permission request result = " + result.toString());
@ -87,11 +88,12 @@ public class MessageSend_p {
peerName = sb.peers.mySeed().get(Seed.NAME, "nameless");
} else {
targetPeer = sb.peers.getConnected(hash);
if (targetPeer == null)
if (targetPeer == null) {
peerName = "nameless";
else
} else {
peerName = targetPeer.get(Seed.NAME, "nameless");
}
}
prop.putXML("mode_permission_peerName", peerName);
final String response = (result == null) ? null : result.get("response");
@ -125,6 +127,10 @@ public class MessageSend_p {
}
}
}
} else { // seed == null
prop.put("mode_permission", "0");
prop.putXML("mode_permission_peerName", "a passive peer");
}
} else {
prop.put("mode", "2");
// send written message to peer

Loading…
Cancel
Save