Project

General

Profile

Update AMP messages in msg_history

Luca Stucchi
Added about 4 years ago

Hi there, first of all Happy New Year !

I am trying to find the best way to update a message with an addition XML tag for messages in the msg_history table so that if and when the message will be finally delivered, the recipient will have an additional information saying "This message was processed while you were offline".

I was wondering which was the best way to access the AMP database, using for example the same data repository to avoid having two of them.

I am within a custom developed component and I am trying not to modify AMP implementation, but build over it.

What would you suggest to do ?

Thanks in advance,

Luca


Replies (4)

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

Right now, Tigase adds information to message stored for offline user in method: OfflineMessages.savePacketForOfflineUser(...).

I think this is the best place to add more such info if needed, alternatively you can add such information in method which delivers messages to end user from offline storage once he is back online.

Added by Luca Stucchi about 4 years ago

Hi Artur,

unfortunately I need to update the message at a point in time after it is saved on the msg_history but before it will be delivered. Thinking at it like a timer, I would like to add a particular tag saying "this message was not delivered for 10 minutes". I can't add the tag at the beginning (I must wait 10 minutes) and I can't wait for the user to download it (the message could be downloaded after an hour, or even never). I have a component activating after 10 minutes and performing some operations for each message, but I still need to add this tag, and I would like to avoid creating a new connection each time... I was right looking for a smarter way !

Thanks in advance,

Luca

Avatar?id=6023&size=32x32

Added by Artur Hefczyc TigaseTeam about 4 years ago

What I would do in this case, is I would add this additional information in a method which delivers offline messages to users who just logged in. Method OfflineMessages.loadOfflineMessages(...) seems like the best place. Since the method has protected access policy, you could easily write your own plugin extending Tigase's OfflineMessages and just override this one method.

Each message which is stored in offline messages storage gets a timestamp of the exact time when it was stored. So, when you load the message you can easily check whether the message was stored for longer than 10 minutes and then add your custom information. I guess, you do not really need to have the modified message in DB, you only need to delivery message to end-user with the additional information. So there is no need to go through DB and update messages in DB, this would be very resource consuming operation.

Added by Luca Stucchi about 4 years ago

Hi Artur,

being able to obtain the desired behavior without the need to perform updates on database would be a HUGE advantage, computationally speaking ! This fact alone convinced me that your idea could be the right one, I'll see how to implement it in the easiest way.

Thanks again

Luca

    (1-4/4)