Live Helper Chat support forum.. Forum is locked. New place for questions - Github Discussions
You are not logged in.
Pages: 1
Hi,
I'm go crazy with a strage problem
My listener is on start chat event and have to push a message to the chat.
To do this, in my listener, I make a api call to /restapi/addmsgadmin but chat was not found:
$Chat = erLhcoreClassChat::getSession()->load( 'erLhcoreClassModelChat', $form->chat_id);
if (!($Chat instanceof erLhcoreClassModelChat)) {
throw new Exception('Chat could not be found!');
}
Exception message is:
A query failed internally in Persistent Object: No object of class 'erLhcoreClassModelChat' with id '844409'.
So I try to investigate deeper adding some log with erLhcoreClassLog::write before the call and after.
The strange thing is:
- before the call: $Chat = erLhcoreClassChat::getSession()->load( 'erLhcoreClassModelChat', $chatId); found the chat
- after the call, as I said before, using same method, chat was not found!
p.s. searching in database with a db client I the chat was found
p.s. there is another way to add message to chat other than api call?
Thanks in advance
Last edited by elplaza (2021-01-08 15:51:11)
Offline
If you are listening to `chat.chat_started` older LHC versions were executing this event during db transactions. It means that transaction is not commited yet and any other call would not see this chat yet. Newer versions calls this after transaction is commited so this problem dissapears.
So please update your LHC version. Or describe how exactly you are starting a chat.
Offline
Hi remdex,
I'm starting chat in this way:
- widget in external site page
- added listener on event chat.chat_started, get params and make api call
Thanks in advance,
Offline
Same response applies as above and I have nothing to add...
Offline
Pages: 1