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

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
Tagged:
0
Best Answer
-
Kasper Scholar of the Bits Copenhagen Vanilla Staff
Just had a look through the Messages controller and it would appear that the actual message data isn't set. This...
// Fetch message data $this->MessageData = $this->ConversationMessageModel->Get( $ConversationID, $Session->UserID, $this->Offset, $Limit );
...should be followed by this:
$this->SetData('Messages', $this->MessageData);
However, it isn't so the message data isn't available through API calls.
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
7
Answers
Just had a look through the Messages controller and it would appear that the actual message data isn't set. This...
...should be followed by this:
However, it isn't so the message data isn't available through API calls.
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
You are right, messages are fetched directly in the messages.php view
it wouldn't really be complicated to add that with a hook.
grep is your friend.
I fixed that using @kasperisager suggestion. I changed also the messages.php view to reuse fetched data in the controller:
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).
Here's the pull request https://github.com/vanillaforums/Garden/pull/1592
I just merged this. Better late than never?