Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums
  1. Home
  2. APIs
  3. getMessagesPage with $or field not working probably

getMessagesPage with $or field not working probably

Scheduled Pinned Locked Moved APIs
messaging
2 Posts 2 Posters 901 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kirlos Yousef
    wrote on last edited by
    #1

    Hello,

    I have been trying to call getMessagesPage with $or field, to get the messages sent to/from the specified profile ID. (to have a small one-to-one chat.)

    Instead, I am receiving all the messages of the current user, no matter who was the sender or receiver.

    In short: calling the API with $or, having the same response as calling it without searchCriteria at all.

    Request:

    {
        "context": {
            "searchCriteria": {
                "$or": [
                    { "message.from": "184d9950-180b-4da4-a362-f9d4a2418b81" },
                    { "message.to": "184d9950-180b-4da4-a362-f9d4a2418b81" }
                ]
            }
        }
    }
    

    In the following response, I receive three messages, when only the last one follows the rule:

    {
        "data": {
            "results": {
                "count": 3,
                "page": 1,
                "items": [
                    {
                        "message": {
                            "from": {
                                "id": "e81e35db-c349-4cee-8851-32e29538b11e",
                                "name": "Tester 1"
                            },
                            "sentAt": 1666125294637,
                            "to": [
                                "14869a2a-631b-4ea9-b241-b06a57e729f4"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "inbox"
                    },
                    {
                        "message": {
                            "from": {
                                "id": "14869a2a-631b-4ea9-b241-b06a57e729f4",
                                "name": "Tester 2"
                            },
                            "sentAt": 1666125957202,
                            "to": [
                                "e81e35db-c349-4cee-8851-32e29538b11e"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "sent"
                    },
                    {
                        "message": {
                            "from": {
                                "id": "14869a2a-631b-4ea9-b241-b06a57e729f4",
                                "name": "Tester 2"
                            },
                            "sentAt": 1666179911502,
                            "to": [
                                "184d9950-180b-4da4-a362-f9d4a2418b81"
                            ],
                            "content": {
                                "text": "Chat and messaging features are here!"
                            }
                        },
                        "msgbox": "sent"
                    }
                ]
            }
        },
        "status": 200
    }
    

    So, am I doing something wrong here?

    Thank you very much.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JasonL
      bitHeads
      wrote on last edited by
      #2

      Hi Kirlos, as you can see from the response's message field, there are two elements (id and name) underneath, you need to append .id to specify the first search field for id, so change the "message.from" to "messsge.from.id" should solve this problem.

      1 Reply Last reply
      1

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Solved
      • Unsolved
      • Users