0

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.

rangarajan
  • 143
  • 5
  • 17

1 Answers1

1

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
Badlop
  • 3,840
  • 1
  • 8
  • 9
  • Thank you for the solution. I tried the first option. so far, I could see the messages exchanged between the users in the **archives** table. But each message is stored two times (one for the sender and another one for the receiver). – rangarajan Aug 04 '22 at 04:30