Exemplo n.º 1
0
  @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;
    }
  }
Exemplo n.º 2
0
  @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();
  }
Exemplo n.º 3
0
  @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;
    }
  }