Mibew Messenger Community
General => Support => Topic started by: Bert on January 29, 2018, 03:04:09 PM
-
We currently happily use Mibew on several of our websites.
To make sure we don't accidentally leave the chat Available outside business hours, I would like to add a cronjob to automatically set the chat to Away/Offline.
I'm looking for which SQL query to use.
I've already tried using...
UPDATE `operator` SET idisabled=1
...but this doesn't seem to have the intended effect.
(In fact, it somehow made it impossible for me to close the chat manually...)
Which query can I run to automatically close the chat?
-
To mess with the system on its low level is not the best way to do the job.
However, one can take a look on this function (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php#L147) as a starting point.
-
To mess with the system on its low level is not the best way to do the job.
Hm, good point.
However, one can take a look on this function (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php#L147) as a starting point.
Are you sure that function is in use, I don't see any calls to it in the code.
I think maybe I need to use notify_operator_alive() (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/libs/operator.php#L442)?
[Edit:]
Maybe this is a bit closer?
UPDATE operator SET istatus=1,idisabled=1,dtmlastvisited=UNIX_TIMESTAMP(NOW());
-
However, one can take a look on this function (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php#L147) as a starting point.
Are you sure that function is in use, I don't see any calls to it in the code.
Yes, I'm sure (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/js/source/users/models/agent.js#L78). ;D
It's a part of the core Client-Server interaction for the Users application. It's called during the special RPC-like interaction between the client and the server. However, it's a little bit complicated matter that can be hard to explain. If you really want to understand it you should start with the docs: https://docs.mibew.org/development/core-architecture.html
I think maybe I need to use notify_operator_alive() (https://github.com/Mibew/mibew/blob/9608c5a83d711f3d57d2beadeaf9848d7287a242/src/mibew/libs/operator.php#L442)?
Yes, probably you could write a plugin that utilizes the CRON_RUN event (https://docs.mibew.org/development/server-side-events.html#cron-events) and calls this function.
[Edit:]
Maybe this is a bit closer?
UPDATE operator SET istatus=1,idisabled=1,dtmlastvisited=UNIX_TIMESTAMP(NOW());
To begin with, you don't need idisabled. You don't have to disable an operator, just alter the status. And as it was written before, bare SQL-requests is a bad idea.
-
Thanks for the feedback.
In the end, I decided to go for a different approach.
I now hide the mibew button itself outside business hours.
So, during the day, they can on-/offline the button...
...and when we're closed visitors don't see the button, which means it's not an issue if an employee accidentally leaves the chat online.