@Override public boolean removeFollowRequest(UserPublicKey owner, byte[] req) { try { byte[] unsigned = owner.unsignMessage(req); FollowRequestData request = new FollowRequestData(owner, unsigned); return request.delete(); } catch (TweetNaCl.InvalidSignatureException e) { return false; } }
@Override public boolean followRequest(UserPublicKey owner, byte[] encryptedPermission) { byte[] dummy = null; FollowRequestData selector = new FollowRequestData(owner, dummy); RowData[] requests = selector.select(); if (requests != null && requests.length > CoreNode.MAX_PENDING_FOLLOWERS) return false; // ToDo add a crypto currency transaction to prevent spam FollowRequestData request = new FollowRequestData(owner, encryptedPermission); return request.insert(); }
@Override public byte[] getFollowRequests(UserPublicKey owner) { byte[] dummy = null; FollowRequestData request = new FollowRequestData(owner, dummy); RowData[] requests = request.select(); if (requests == null) return new byte[4]; ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutput dout = new DataOutputStream(bout); try { dout.writeInt(requests.length); for (RowData req : requests) Serialize.serialize(req.data, dout); return bout.toByteArray(); } catch (IOException e) { e.printStackTrace(); return null; } }