powered by Jive Software

REST API and Getting MUC Room Chat History

Hello,

I have a use case and a working code enhancement for retrieving the MUC Room Chat History, for any given room, via Rest. Is there anyone with specific interest in the same feature or general comments?

1 Like

Maybe @Redeyes, the author of Rest API plugin, would have any comments.

Hey @dbh,

It would be great if you could create a pull request for that.
I think there is definitely interest in that.

Best,

Awesome. I’ll try to get that in next week

Here’s how it is currently looking on my dev-station. The URL is bogus.

Endpoint example : http://bogus.davidbharrison.com:9090/plugins/restapi/v1/chatrooms/dbh/chathistory
The from value shows the sending occupant after “/”.

Users in the MUC:

  • dharrison
  • bmereba6

JSON Output example

{
    "message": [
        {
            "to": "dharrison@bogus.davidbharrison.com/t460",
            "from": "dbh@conference.bogus.davidbharrison.com/dharrison",
            "type": "groupchat",
            "body": "well....",
            "when": "2018-07-24T06:17:11.056Z"
        },
        {
            "to": "dharrison@bogus.davidbharrison.com/t460",
            "from": "dbh@conference.bogus.davidbharrison.com/dharrison",
            "type": "groupchat",
            "body": "this could work",
            "when": "2018-07-24T06:17:13.330Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/bmereba6",
            "type": "groupchat",
            "body": "This is a test of chat history functionality.",
            "when": "2018-07-31T22:14:38.941Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/dharrison",
            "type": "groupchat",
            "body": "Hello bmereba6. Thanks for helping me test. ",
            "when": "2018-07-31T22:14:54.365Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/dharrison",
            "type": "groupchat",
            "body": "Each of our messages should get logged as part of chathistory",
            "when": "2018-07-31T22:15:05.435Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/dharrison",
            "type": "groupchat",
            "body": "Then, the rest API for retrieving chat history will return each groupchat message,  with a timestamp",
            "when": "2018-07-31T22:15:29.372Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/bmereba6",
            "type": "groupchat",
            "body": "Great, let's see if it works",
            "when": "2018-07-31T22:15:35.477Z"
        },
        {
            "to": "dbh@conference.bogus.davidbharrison.com",
            "from": "dbh@conference.bogus.davidbharrison.com/bmereba6",
            "type": "groupchat",
            "body": "!",
            "when": "2018-07-31T22:15:36.117Z"
        }
    ]
}

I like it!
If you have time, it would be nice if you could create a pull request

submitted OF-1585 and a PR

For anyone interested, this is now available in version 1.3.5 in the REST API plugin

The response body ends up looking like this

{
    "message": [
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/zbeeblebrox",
            "type": "groupchat",
            "body": "Hello Arthur",
            "delay_stamp": "2018-08-13T04:46:27.594Z"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/adent",
            "type": "groupchat",
            "body": "Hello Zaphod",
            "delay_stamp": "2018-08-13T04:46:40.400Z",
            "delay_from": "adent@bogus.davidbharrison.com/25iwa374c2"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/adent",
            "type": "groupchat",
            "body": "Nice ship! Where did you get it?",
            "delay_stamp": "2018-08-13T04:46:50.074Z",
            "delay_from": "adent@bogus.davidbharrison.com/25iwa374c2"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/zbeeblebrox",
            "type": "groupchat",
            "body": "Never mind that. Here... drink this...",
            "delay_stamp": "2018-08-13T04:48:51.227Z"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/adent",
            "type": "groupchat",
            "body": "What is it?",
            "delay_stamp": "2018-08-13T04:48:58.416Z",
            "delay_from": "adent@bogus.davidbharrison.com/25iwa374c2"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/zbeeblebrox",
            "type": "groupchat",
            "body": "A pan galatic gargle blaster.. Drink it",
            "delay_stamp": "2018-08-13T04:49:12.265Z"
        },
        {
            "to": "heart_of_gold@conference.bogus.davidbharrison.com",
            "from": "heart_of_gold@conference.bogus.davidbharrison.com/adent",
            "type": "groupchat",
            "body": "sure why not",
            "delay_stamp": "2018-08-13T04:49:25.323Z",
            "delay_from": "adent@bogus.davidbharrison.com/25iwa374c2"
        }
    ]
}