Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Conversation's messages via json

lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

The http://example.com/messages.json/1 return

{
    "Recipients": [
        {
            "UserID": "1",
            "Name": "admin",
            "Email": "MyEmail",
            "Deleted": "0",
            "Photo": "userpics/456/YPAO206WQOCK.jpg",
            "DateLastActive": "2013-05-04 08:55:13"
        },
        {
            "UserID": "8",
            "Name": "text",
            "Email": "anotheremail",
            "Deleted": "0",
            "Photo": "userpics/207/CP0D2DEW0JHG.png",
            "DateLastActive": null
        }
    ],
    "Conversation": {
        "ConversationID": "1",
        "Subject": null,
        "Contributors": "a:2:{i:0;s:1:\"1\";i:1;s:1:\"8\";}",
        "FirstMessageID": "1",
        "InsertUserID": "1",
        "DateInserted": "2013-05-04 08:55:13",
        "InsertIPAddress": "127.0.0.1",
        "UpdateUserID": "1",
        "DateUpdated": "2013-05-04 08:55:13",
        "UpdateIPAddress": "127.0.0.1",
        "CountMessages": "1",
        "LastMessageID": "1",
        "RegardingID": null,
        "CountNewMessages": 0,
        "CountReadMessages": "1",
        "DateLastViewed": "2013-05-04 08:55:13"
    }
}

This request correspond to http://example.com/messages/1, but the json request doesn't return conversation's messages...

Any advice on how to get conversation's messages (in json)?

Using vanilla 2.1 and conversations application

There was an error rendering this rich post.

Best Answer

Answers

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    You are right, messages are fetched directly in the messages.php view

    foreach ($this->MessageData->Result() as $Message) {
    
    }
    

    There was an error rendering this rich post.

  • it wouldn't really be complicated to add that with a hook.

    grep is your friend.

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    I fixed that using @kasperisager suggestion. I changed also the messages.php view to reuse fetched data in the controller:

    foreach ($this->Data['Messages'] as $Message) {}
    

    I'll open an issue on github, since I think that this behaviour is the default expected by a user (json response should return same data as html do).

    There was an error rendering this rich post.

    Kasperhgtonight
  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    There was an error rendering this rich post.

    hgtonightsica07
  • LincLinc Detroit Admin

    I just merged this. Better late than never?

Sign In or Register to comment.