Still push notification issues

Hi,
I am not able to fix following issue.
User A is offline and someone else sends a c2c message to user A.
But no push notification is beeing sent.
Both have registered notifications within Snikket.
Under sessions - server sessions the push server is visible.
I have even tried different apps like chatsecure and siskin. Same result.
Debug log states user has no config for push :

2022.03.28 19:35:54 TRACE [socket_c2s-thread-3]: org.igniterealtime.openfire.plugins.pushnotification.PushInterceptor - If user 'austin.powers' has push services configured, pushes need to be sent for a message that just arrived.
2022.03.28 19:35:54 WARN  [socket_c2s-thread-3]: org.igniterealtime.openfire.plugins.pushnotification.PushServiceManager - Unable to process database row content while obtaining push service configuration for user 'austin.powers'.
2022.03.28 19:35:54 TRACE [socket_c2s-thread-3]: org.igniterealtime.openfire.plugins.pushnotification.PushServiceManager - User 'austin.powers' has 0 push notification services configured.

Config:
RedHat 8
OF 4.7.1
Push notification: 0.9.0
Java Version: 1.8.0_312 Red Hat
Ldap config
external mysql database

Client: Snikket 1.2

Any hint is welcome

Andre

So, after hours of work I eventually found out where it stucks. Since I am using mysql as database backend I was able to break down the issue. There is a called table ofPushNotiSevice:
In this table are beeing stored all push notification services of each user what have accepted push trough their app on their phone.
Unfortunaltely sknikket sends no data for the field “options” and the plugin “push notification” sets it to NULL.


When this user is offline then and someoneelse sends now a message happens this:
Push notification plugin intercepts the message and runs its code until it finds a record in mentioned table above. If it does not find a message, no push notifacation will be sent. In case there is a record it saves all fields in variables. Since the field is NULL push notifiications considers this record as not usable and spits out ecactly the error I had been posting above. “User has 0 push notification services configured.”
I have been trying to modify the field directly in the database uncseccessfully by leaving any character or even leaving it empty . Then I copied and pasted the value what the app “Chatsecure” has forseen for this field and BINGO. Push notifications are being sent. I don’t have any clue why push notication app considers this field since it is optional by XEP-357.
See picture:

SInce every opening of the app or re-registering of the user manualy through the app sets the field again to NULL, I easely have set a trigger directly in the datebase what fills the field.
For reaching this I needed a kind of PINGPONG since it is not doable writing through a trigger in the same table where something needs to be modified.

  1. Create another table where data will be stored taken from table ofOffline

CREATE TABLE IF NOT EXISTS push_notification (
id int(11) NOT NULL,
message_id int(11) NOT NULL,
from_user_id text NOT NULL,
to_user_id text NOT NULL,
message text NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ;

  1. Create a trigger in table ofOffline what sends date to new table after they have just arrived


– Triggers ofOffline

DELIMITER //
CREATE TRIGGER PushNotification AFTER INSERT ON ofOffline
FOR EACH ROW BEGIN

DECLARE strMessageText VARCHAR(500) DEFAULT '';
DECLARE strSenderId VARCHAR(500) DEFAULT '';    
DECLARE strReceiverId VARCHAR(500) DEFAULT '';        
DECLARE intMessageId INT DEFAULT 1;

SET strMessageText = ExtractValue(NEW.stanza, 'message/body[1]');
SET strSenderId = ExtractValue(NEW.stanza, 'message/@from[1]');
SET strReceiverId = ExtractValue(NEW.stanza, 'message/@to[1]');
SET intMessageId = NEW.messageID;    
INSERT INTO push_notification (message_id,from_user_id,to_user_id,message) VALUES (intMessageId,strSenderId,strReceiverId,strMessageText);

END
//
DELIMITER ;

  1. Create a trigger in table push_notification what sets the desired field
CREATE TRIGGER `IfNotiOptionsEmpty` BEFORE INSERT ON `push_notification`
 FOR EACH ROW UPDATE ofPushNotiService SET options = '<x xmlns="jabber:x:data" type="submit"><field var="FORM_TYPE"><value>http://jabber.org/protocol/pubsub#publish-options</value></field><field var="token"><value>iftheappisstupid</value></field><field var="endpoint"><value>https://myDomain.net</value></field></x>' where options is NULL

It does not matter at al what is this this field. Importent is just it has to be the format like in the last trigger.

Hope I could help.

Regards,
Andre

Hi Andre,

Thanks for your very detailed bug report. I think that you’re spot on.

This issue has already been reported in NPE encountered if there are no "options" specified for the Push node for a user. · Issue #25 · igniterealtime/openfire-pushnotification-plugin · GitHub

I have just created a fix for this issue in fixes #25: fix NPE when config options are not provided. by guusdk · Pull Request #28 · igniterealtime/openfire-pushnotification-plugin · GitHub

Please help me test the fix by trying the SNAPSHOT build of this plugin that was created on, or later than May 11, 2022 7:11:44 AM.

Hey Guss,
thx for your response and especially for the fix you have implemented.
Works as expected now.

After the workaround with the trigger in the database, I also made changes to your plugin thus the trigger got obsolete. Moreover, I implemented push notification for rooms, but this is tide to my requirements here. Just to know: I am intercepting the packets, if JID is room I retrieving the users from ldap group what is also responsible for granting permissions to that room, then I am sending a push to each member of this group.

Best regards,
Andre