Shashank Shah Shashank Shah - 4 years ago 170
reST (reStructuredText) Question

Get last Last Logout details openfire using REST API

We do have functionality for offline group push notification from server end.


Scenario is below :-


Application is open and go to the group message tab. Now send a message to the group so, other users of group will get message i sent.

By closing (kill or in background) the application from ios end they are setting users presence to offline. So once application is closed they will get push notification in mobile.

Issue is by closing the application still i am receiving push notification in mobile even though i read the same message.

From back-end i have set a cron job which runs on server at every 30 seconds and checks the user presence in the group and send push notificaiton to those users who are offline in their mobile.

So is there any way to get last logout timestamp using REST API so i can put condition and check if last user logged in time is less than current time accrodingly push notificaitons will send.

Not able to get last logout time using REST API
http://example.com:9090/plugins/restapi/v1/sessions/yourUserName

which outputs :-

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <sessions>
<session>
<sessionId>yourUserName@example.com/1ae2xq14da</sessionId>
<username>yourUserName</username>
<ressource>1ae2xq14da</ressource>
<node>Local</node>
<sessionStatus>Closed</sessionStatus>
<presenceStatus>Online</presenceStatus>
<priority>0</priority>
<creationDate>2017-01-18T08:58:01.611Z</creationDate>
<lastActionDate>2017-01-18T08:58:05.121Z</lastActionDate>
<secure>false</secure>
</session>
</sessions>


By executing above method getting creation date and last action date incorrect.

1) creationDate :- 2017-01-18T08:58:01.611Z

2) lastActionDate :- 2017-01-18T08:58:05.121Z

http://example.com:9090/plugins/restapi/v1/users/yourUserName

Which doesnot output last login timestamp

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<user>
<username>yourUserName</username>
<name>yourUserName</name>
<email>yourUserName@example.com</email>
<properties/>
</user>


We have used REST API Plugin

Any Help would be appriciate.

Answer Source

User Status Plugin did the job!

User Status Plugin is a plugin for the Openfire XMPP server to save the user status to the database.

This plugin automatically saves the last status (presence, IP address, logon and logoff time) per user and resource to userStatus table in the Openfire database.

Optionally you can archive user status entries (IP address, logon and logoff time) for a specified time. History entries are stored in the userStatusHistory table. The settings for history archiving can be configured on the "User Status Settings" page that you'll find on the "Server" tab of the Openfire Admin Console.

The plugin is available at http://maven.reucon.com/projects/public/user-status

According to the project's Web site, currently this plugin only works with MySQL.

So by putting condition based on logoff time and message time push notifications are sending.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download