如何在Quickblox中按自定义值过滤[tag:ChatDialog]消息?

时间:2017-04-19 23:53:16

标签: android quickblox

我在我的应用程序中使用Quickblox,问题是当尝试使用自定义值参数过滤消息时,过滤器无效。
聊天documentation
这是mu代码:

        ArrayList<QBChatMessage> messages = null;
        QBMessageGetBuilder qbMessageGetBuilder = new QBMessageGetBuilder();
        qbMessageGetBuilder.eq("bookID", customDialog.getBookID());
        qbMessageGetBuilder.sortAsc("date_sent");
        try {
            messages = QBRestChatService.getDialogMessages(qbChatDialog, qbMessageGetBuilder).perform();
        } catch (QBResponseException e) {
            e.printStackTrace();
        }

响应示例:

{
  "skip": 0,
  "limit": 100,
  "items": [
    {
      "_id": "58f6c9f4a28f9a0c7f000003",
      "attachments": [],
      "bookID": "-Kh9UzvClNyHuwNhLcFV",
      "chat_dialog_id": "58f6bcdea0eb4766d900003c",
      "created_at": "2017-04-19T02:22:44Z",
      //other fields
    },
    {
      "_id": "58f6ca12a28f9a08c5000001",
      "attachments": [],
      "bookID": "-KeA1pw5DGMSTg67Pbp0",
      "chat_dialog_id": "58f6bcdea0eb4766d900003c",
      "created_at": "2017-04-19T02:23:15Z",
      //other fields

    }
  ]
}

[更新] 我使用的是3.3.0版本。

[更新] 22/4/2017 我也尝试了@Jagapathi的回答,我替换了这一行

qbMessageGetBuilder.eq("bookID", customDialog.getBookID());

用这个:

qbMessageGetBuilder.addRule("bookID", QueryRule.EQ, customDialog.getBookID());

但也行不通。

1 个答案:

答案 0 :(得分:1)

  

qbMessageGetBuilder.eq

“eq”不适用于每个doc,用于比较需要使用的排序的相同值。

  

messageGetBuilder.addRule(“bookID”,QueryRule.EQ,“ - Kh9UzvClNyHuwNhLcFV”);

Image From dOC