Sorted_metaarray key not receiving on the client side

I’m sending additional info in the sorted_metaarray key via the platform api (using postman) but for some reason i’m not receiving the same on the client side on android, the key is missing from the BaseMessage class itself, is there something i’m missing?
SDK version: 3.0.159
This is the request:

{
    "custom_type": "text",
    "user_id": "406172",
    "message": "This is a user sent message",
    "type": "MESG",
    "sorted_metaarray": [
        {
            "key": "versions",
            "value": [
                1
            ]
        }
    ],
    "channel_url": "consult_private_thread_1",
    "message_id": 80290057
}

This is the response:

{
    "message_survival_seconds": -1,
    "custom_type": "text",
    "mentioned_users": [],
    "translations": {},
    "updated_at": 0,
    "is_op_msg": false,
    "is_removed": false,
    "user": {
        "require_auth_for_profile_image": false,
        "is_active": true,
        "role": "",
        "user_id": "406172",
        "nickname": "Arjun",
        "profile_url": "",
        "metadata": {}
    },
    "file": {},
    "message": "This is a user sent message",
    "data": "",
    "silent": false,
    "type": "MESG",
    "created_at": 1615885911354,
    "sorted_metaarray": [
        {
            "key": "versions",
            "value": [
                "1"
            ]
        }
    ],
    "mention_type": "users",
    "channel_url": "sendbird_group_channel_8751938_f4a3f58aab375c188db6cd73e01604c6700c3ee6",
    "message_id": 83140443
}

@arjun,

I want to make sure I understand correctly. The issue is that when you grab the message data using the Android SDK, it does not contain the sorted_metaarray?

-Tyler

Yes, you got that right

@arjun Thanks. Allow me some time to investigate.

1 Like

Hi @arjun ,
There is a method in SDK to retrieve all meta arrays, BaseMessage.getAllMetaArrays() which returns the MessageMetaArray list.

Could you check if this list returns the list with meta array you set?

(FYI, your request/response payload doesn’t seem to be the actual request/response. Their messageId and channelUrl is different.)

1 Like

Hi @hoons I tried out this method but no luck, I tried digging deep and found that the getAllMetaArrays() calls the protected List<MessageMetaArray> mMetaArrays; to fetch the info and it turns out that this itself is empty so nothing is returned.

This is my request:

{
    "custom_type": "image",
    "message": "This is a user image caption",
    "message_type": "MESG",
    "user_id": "406172",
    "sorted_metaarray": [
        {
            "key": "versions",
            "value": [
                1
            ]
        },
        {
            "key": "file_uuid",
            "value": [
                "48d7a5dd-0e8b-4a1e-b8a1-60c75755081b"
            ]
        }
    ]
}

and this is my response:

{
    "message_survival_seconds": -1,
    "custom_type": "image",
    "mentioned_users": [],
    "translations": {},
    "updated_at": 0,
    "is_op_msg": false,
    "is_removed": false,
    "user": {
        "require_auth_for_profile_image": false,
        "is_active": true,
        "role": "",
        "user_id": "406172",
        "nickname": "Arjun",
        "profile_url": "",
        "metadata": {}
    },
    "file": {},
    "message": "This is a user image caption",
    "data": "",
    "silent": false,
    "type": "MESG",
    "created_at": 1615959690625,
    "sorted_metaarray": [
        {
            "key": "versions",
            "value": [
                "1"
            ]
        },
        {
            "key": "file_uuid",
            "value": [
                "48d7a5dd-0e8b-4a1e-b8a1-60c75755081b"
            ]
        }
    ],
    "mention_type": "users",
    "channel_url": "sendbird_group_channel_8751938_f4a3f58aab375c188db6cd73e01604c6700c3ee6",
    "message_id": 83409064
}

and i tried fetching the meta arrray using val meta = message.getMetaArrays(listOf("versions", "file_uuid"))

I hope i’m not doing anything wrong

Hi @arjun ,
I see you’re sending the message using the postman, could you tell me how you are getting the message object from the SDK side?

Is it from the real time event handler, ChannelHandler.onMessageReceived(),
or is it from one of the BaseChannel.getMessagesByTimestamp() or BaseChannel.getMessagesById()?

receiving it using the handler in real time

when i hit this url to add sorted_metaarray
https://api-847E89AF-7271-42B8-BCBE-FDCFBB16F99A.sendbird.com/v3/group_channels/sendbird_group_channel_8751938_f4a3f58aab375c188db6cd73e01604c6700c3ee6/messages/83735383/sorted_metaarray

i get this response:

{
    "message": "\"Key, value pair already exists\" violates unique constraint.",
    "code": 400202,
    "error": true
}

this ensures that the message has the required meta array but when i try it on the client side then i don’t get it.

as you can see the mMetaArray is empty

Hi @arjun, thanks for more information.

Is the response payload from here the response from postman?

It’d be helpful if you could grab us the payload you got from the SDK side.
You can use SendBird.setLoggerLevel(LogLevel.VERBOSE) to enable all logs, and could you grab logs right after you try the platform api with the postman?

We’re still investigating and we’re trying to identify if it’s a problem in payload the SDK receives when the message was sent, or if it’s the SDK’s internal issue.

yes, everything i’ve shared till now is from postman only, the first one had messageId and channelUrl wrong but it didn’t have any effect on the response (i hope so),

Let me enable the logger and try, i’ll get back

@hoons
the sorted_metaArray shows up in the logcat

1 Like

Hi @arjun ,

We’ve tried to reproduce it, but haven’t been successful.
In this reply, the messageId you attempt to add (83735383), and the screenshot of the message from Android Studio messageId (83737666) is not the same.

Can I ask for one more log, with one additional log of the message object received on ChannelHandler.onMessageReceived()? This is so that we can compare the received message payload vs the actual message object the SDK parsed.

A full log just like the previous reply from the time of the message sent by the postman, until the log from ChannelHandler.onMessageReceived() would help us a lot.

Thank you.

@hoons Thanks for the tip, it seems like I’m indeed receiving the meta data


But when i pull the list of messages using the GetMessagesHandler then the messages doesn’t contain the meta array

@arjun If you need to get the message with metaarray via using GetMessageHandler, you should set the value of includeMetaArray as True. Would you check whether that value is set True?

@LeoShin where am i suppose to set this includeMetaArray flag?
Nevermind got it, thanks

@arjun Which API did you use?

public void getMessagesByTimestamp(long ts, MessageListParams params, final GetMessagesHandler handler)

If you are using this API, you can find the parameter in MessageListParams.

1 Like

thanks @Tyler @LeoShin @hoons

2 Likes