简体   繁体   中英

How to fetch all messages between two users in ejabberd through REST API

I'm currently working on integrating one to one chat in a web application using ejabberd.

I have tried to send message through send_message api to the user1 from user2 .

POST /api/send_message
{
  "type": "headline",
  "from": "user2@localhost",
  "to": "user1@localhost",
  "subject": "Testing",
  "body": "Sample message from user2"
}

When I opened pidgin I could see the message from user2 . I received 0 as response which means success (as mentioned in the documentation).

Until I opened pidgin and see the message, The message has been treated as offline message. I could see that from the admin panel.

Now my question is How could I fetch all the messages between the user1 and user2 through a REST API endpoint? Like how we use send_message endpoint to send message to an user from a different user.

There is no API to view messages stored in offline (or in MAM archive).

Three possibilities:

  • A) Use SQL storage for mod_offline (or mod_mam), then write a program that searches in your SQL database for the stored messages for account X.
  • B) Write a small XMPP client that logins to the account and requests MAM archive of that account.
  • C) Write a command in the ejabberd API to perform that task

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM