Add API's for marking a feed as blocked

This commit is contained in:
Jeremy Lakeman
2017-06-05 12:39:07 +09:30
parent f83b15d251
commit 508e95436a
11 changed files with 192 additions and 116 deletions

View File

@ -17,6 +17,12 @@ public class MeshMBCommon {
public static final String SERVICE = "MeshMB1";
public enum SubscriptionAction{
Follow,
Ignore,
Block
}
public static int sendMessage(ServalDHttpConnectionFactory connector, SigningKey id, String text) throws IOException, ServalDInterfaceException {
HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshmb/" + id.toHex() + "/sendmessage");
PostHelper helper = new PostHelper(conn);
@ -28,15 +34,8 @@ public class MeshMBCommon {
return conn.getResponseCode();
}
public static int ignore(ServalDHttpConnectionFactory connector, Subscriber id, SigningKey peer) throws ServalDInterfaceException, IOException {
HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshmb/" + id.signingKey.toHex() + "/ignore/" + peer.toHex());
conn.setRequestMethod("POST");
conn.connect();
return conn.getResponseCode();
}
public static int follow(ServalDHttpConnectionFactory connector, Subscriber id, SigningKey peer) throws ServalDInterfaceException, IOException {
HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshmb/" + id.signingKey.toHex() + "/follow/" + peer.toHex());
public static int alterSubscription(ServalDHttpConnectionFactory connector, Subscriber id, SubscriptionAction action, SigningKey peer) throws ServalDInterfaceException, IOException {
HttpURLConnection conn = connector.newServalDHttpConnection("/restful/meshmb/" + id.signingKey.toHex() + "/"+action.toString().toLowerCase()+"/" + peer.toHex());
conn.setRequestMethod("POST");
conn.connect();
return conn.getResponseCode();