Skip to content

Commit

Permalink
Add THREAD_USER_IS_READY event
Browse files Browse the repository at this point in the history
  • Loading branch information
JustBlackBird committed Jun 19, 2015
1 parent 227c7a9 commit 8457e51
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mibew/libs/chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/

use Mibew\Asset\Generator\UrlGeneratorInterface as AssetUrlGeneratorInterface;
use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Settings;
use Mibew\Thread;
use Mibew\Style\ChatStyle;
Expand Down Expand Up @@ -717,5 +719,10 @@ function chat_start_for_user(
);
}

// Let plugins know that user is ready to chat.
$dispatcher = EventDispatcher::getInstance();
$event_args = array('thread' => $thread);
$dispatcher->triggerEvent(Events::THREAD_USER_IS_READY, $event_args);

return $thread;
}
12 changes: 12 additions & 0 deletions src/mibew/libs/classes/Mibew/EventDispatcher/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,18 @@ final class Events
*/
const THREAD_GET_MESSAGES_ALTER = 'threadGetMessagesAlter';

/**
* User is ready to chat.
*
* This event is triggered after the thread is created, the user passed
* pre-chat survey and all system messages are sent to him. This event is
* not triggered if there are no online operators and the chat cannot be
* started. An associative array with the following items is passed to the
* event handlers:
* - "thread": an instance of {@link \Mibew\Thread}.
*/
const THREAD_USER_IS_READY = 'threadUserIsReady';

/**
* Threads list is ready to be sent to client.
*
Expand Down

0 comments on commit 8457e51

Please sign in to comment.