mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 18:38:31 +03:00
Beautify operator chat URLs
This commit is contained in:
parent
e31b03ccdf
commit
e886e7dc33
@ -8,5 +8,5 @@
|
|||||||
(function(d,e){d.Views.QueuedThread=d.Views.CompositeBase.extend({template:e.templates.queued_thread,itemView:d.Views.Control,itemViewContainer:".thread-controls",className:"thread",modelEvents:{change:"render"},events:{"click .open-dialog":"openDialog","click .view-control":"viewDialog","click .track-control":"showTrack","click .ban-control":"showBan","click .geo-link":"showGeoInfo","click .first-message a":"showFirstMessage"},initialize:function(){this.lastStyles=[]},serializeData:function(){var a=
|
(function(d,e){d.Views.QueuedThread=d.Views.CompositeBase.extend({template:e.templates.queued_thread,itemView:d.Views.Control,itemViewContainer:".thread-controls",className:"thread",modelEvents:{change:"render"},events:{"click .open-dialog":"openDialog","click .view-control":"viewDialog","click .track-control":"showTrack","click .ban-control":"showBan","click .geo-link":"showGeoInfo","click .first-message a":"showFirstMessage"},initialize:function(){this.lastStyles=[]},serializeData:function(){var a=
|
||||||
this.model,b=d.Objects.Models.page,c=a.toJSON();c.stateDesc=this.stateToDesc(a.get("state"));c.chatting=a.get("state")==a.STATE_CHATTING;c.tracked=b.get("showVisitors");c.firstMessage&&(c.firstMessagePreview=30<c.firstMessage.length?c.firstMessage.substring(0,30)+"...":c.firstMessage);return c},stateToDesc:function(a){var b=d.Localization;return a==this.model.STATE_QUEUE?b.get("chat.thread.state_wait"):a==this.model.STATE_WAITING?b.get("chat.thread.state_wait_for_another_agent"):a==this.model.STATE_CHATTING?
|
this.model,b=d.Objects.Models.page,c=a.toJSON();c.stateDesc=this.stateToDesc(a.get("state"));c.chatting=a.get("state")==a.STATE_CHATTING;c.tracked=b.get("showVisitors");c.firstMessage&&(c.firstMessagePreview=30<c.firstMessage.length?c.firstMessage.substring(0,30)+"...":c.firstMessage);return c},stateToDesc:function(a){var b=d.Localization;return a==this.model.STATE_QUEUE?b.get("chat.thread.state_wait"):a==this.model.STATE_WAITING?b.get("chat.thread.state_wait_for_another_agent"):a==this.model.STATE_CHATTING?
|
||||||
b.get("chat.thread.state_chatting_with_agent"):a==this.model.STATE_CLOSED?b.get("chat.thread.state_closed"):a==this.model.STATE_LOADING?b.get("chat.thread.state_loading"):""},showGeoInfo:function(){var a=this.model.get("userIp");if(a){var b=d.Objects.Models.page,c=b.get("geoLink").replace("{ip}",a);d.Popup.open(c,"ip"+a,b.get("geoWindowParams"))}},openDialog:function(){var a=this.model;if(a.get("canOpen")||a.get("canView"))a=!a.get("canOpen"),this.showDialogWindow(a)},viewDialog:function(){this.showDialogWindow(!0)},
|
b.get("chat.thread.state_chatting_with_agent"):a==this.model.STATE_CLOSED?b.get("chat.thread.state_closed"):a==this.model.STATE_LOADING?b.get("chat.thread.state_loading"):""},showGeoInfo:function(){var a=this.model.get("userIp");if(a){var b=d.Objects.Models.page,c=b.get("geoLink").replace("{ip}",a);d.Popup.open(c,"ip"+a,b.get("geoWindowParams"))}},openDialog:function(){var a=this.model;if(a.get("canOpen")||a.get("canView"))a=!a.get("canOpen"),this.showDialogWindow(a)},viewDialog:function(){this.showDialogWindow(!0)},
|
||||||
showDialogWindow:function(a){var b=this.model.id,c=d.Objects.Models.page;d.Popup.open(c.get("agentLink")+"?thread="+b+(a?"&viewonly=true":""),"ImCenter"+b,c.get("chatWindowParams"))},showTrack:function(){var a=this.model.id,b=d.Objects.Models.page;d.Popup.open(b.get("trackedLink")+"?thread="+a,"ImTracked"+a,b.get("trackedUserWindowParams"))},showBan:function(){var a=this.model,b=a.get("ban"),c=d.Objects.Models.page;d.Popup.open(c.get("banLink")+"/"+(!1!==b?b.id+"/edit":"add?thread="+a.id),"ImBan"+
|
showDialogWindow:function(a){var b=this.model.id,c=d.Objects.Models.page;d.Popup.open(c.get("agentLink")+"/"+b+(a?"?viewonly=true":""),"ImCenter"+b,c.get("chatWindowParams"))},showTrack:function(){var a=this.model.id,b=d.Objects.Models.page;d.Popup.open(b.get("trackedLink")+"?thread="+a,"ImTracked"+a,b.get("trackedUserWindowParams"))},showBan:function(){var a=this.model,b=a.get("ban"),c=d.Objects.Models.page;d.Popup.open(c.get("banLink")+"/"+(!1!==b?b.id+"/edit":"add?thread="+a.id),"ImBan"+b.id,c.get("banWindowParams"))},
|
||||||
b.id,c.get("banWindowParams"))},showFirstMessage:function(){var a=this.model.get("firstMessage");a&&alert(a)}})})(Mibew,Handlebars);
|
showFirstMessage:function(){var a=this.model.get("firstMessage");a&&alert(a)}})})(Mibew,Handlebars);
|
||||||
|
@ -95,8 +95,8 @@ a,c);return c.field},updateVisitors:function(a){if(0==a.errorCode){var c;c=a.cur
|
|||||||
(function(d,e){d.Views.QueuedThread=d.Views.CompositeBase.extend({template:e.templates.queued_thread,itemView:d.Views.Control,itemViewContainer:".thread-controls",className:"thread",modelEvents:{change:"render"},events:{"click .open-dialog":"openDialog","click .view-control":"viewDialog","click .track-control":"showTrack","click .ban-control":"showBan","click .geo-link":"showGeoInfo","click .first-message a":"showFirstMessage"},initialize:function(){this.lastStyles=[]},serializeData:function(){var a=
|
(function(d,e){d.Views.QueuedThread=d.Views.CompositeBase.extend({template:e.templates.queued_thread,itemView:d.Views.Control,itemViewContainer:".thread-controls",className:"thread",modelEvents:{change:"render"},events:{"click .open-dialog":"openDialog","click .view-control":"viewDialog","click .track-control":"showTrack","click .ban-control":"showBan","click .geo-link":"showGeoInfo","click .first-message a":"showFirstMessage"},initialize:function(){this.lastStyles=[]},serializeData:function(){var a=
|
||||||
this.model,b=d.Objects.Models.page,c=a.toJSON();c.stateDesc=this.stateToDesc(a.get("state"));c.chatting=a.get("state")==a.STATE_CHATTING;c.tracked=b.get("showVisitors");c.firstMessage&&(c.firstMessagePreview=30<c.firstMessage.length?c.firstMessage.substring(0,30)+"...":c.firstMessage);return c},stateToDesc:function(a){var b=d.Localization;return a==this.model.STATE_QUEUE?b.get("chat.thread.state_wait"):a==this.model.STATE_WAITING?b.get("chat.thread.state_wait_for_another_agent"):a==this.model.STATE_CHATTING?
|
this.model,b=d.Objects.Models.page,c=a.toJSON();c.stateDesc=this.stateToDesc(a.get("state"));c.chatting=a.get("state")==a.STATE_CHATTING;c.tracked=b.get("showVisitors");c.firstMessage&&(c.firstMessagePreview=30<c.firstMessage.length?c.firstMessage.substring(0,30)+"...":c.firstMessage);return c},stateToDesc:function(a){var b=d.Localization;return a==this.model.STATE_QUEUE?b.get("chat.thread.state_wait"):a==this.model.STATE_WAITING?b.get("chat.thread.state_wait_for_another_agent"):a==this.model.STATE_CHATTING?
|
||||||
b.get("chat.thread.state_chatting_with_agent"):a==this.model.STATE_CLOSED?b.get("chat.thread.state_closed"):a==this.model.STATE_LOADING?b.get("chat.thread.state_loading"):""},showGeoInfo:function(){var a=this.model.get("userIp");if(a){var b=d.Objects.Models.page,c=b.get("geoLink").replace("{ip}",a);d.Popup.open(c,"ip"+a,b.get("geoWindowParams"))}},openDialog:function(){var a=this.model;if(a.get("canOpen")||a.get("canView"))a=!a.get("canOpen"),this.showDialogWindow(a)},viewDialog:function(){this.showDialogWindow(!0)},
|
b.get("chat.thread.state_chatting_with_agent"):a==this.model.STATE_CLOSED?b.get("chat.thread.state_closed"):a==this.model.STATE_LOADING?b.get("chat.thread.state_loading"):""},showGeoInfo:function(){var a=this.model.get("userIp");if(a){var b=d.Objects.Models.page,c=b.get("geoLink").replace("{ip}",a);d.Popup.open(c,"ip"+a,b.get("geoWindowParams"))}},openDialog:function(){var a=this.model;if(a.get("canOpen")||a.get("canView"))a=!a.get("canOpen"),this.showDialogWindow(a)},viewDialog:function(){this.showDialogWindow(!0)},
|
||||||
showDialogWindow:function(a){var b=this.model.id,c=d.Objects.Models.page;d.Popup.open(c.get("agentLink")+"?thread="+b+(a?"&viewonly=true":""),"ImCenter"+b,c.get("chatWindowParams"))},showTrack:function(){var a=this.model.id,b=d.Objects.Models.page;d.Popup.open(b.get("trackedLink")+"?thread="+a,"ImTracked"+a,b.get("trackedUserWindowParams"))},showBan:function(){var a=this.model,b=a.get("ban"),c=d.Objects.Models.page;d.Popup.open(c.get("banLink")+"/"+(!1!==b?b.id+"/edit":"add?thread="+a.id),"ImBan"+
|
showDialogWindow:function(a){var b=this.model.id,c=d.Objects.Models.page;d.Popup.open(c.get("agentLink")+"/"+b+(a?"?viewonly=true":""),"ImCenter"+b,c.get("chatWindowParams"))},showTrack:function(){var a=this.model.id,b=d.Objects.Models.page;d.Popup.open(b.get("trackedLink")+"?thread="+a,"ImTracked"+a,b.get("trackedUserWindowParams"))},showBan:function(){var a=this.model,b=a.get("ban"),c=d.Objects.Models.page;d.Popup.open(c.get("banLink")+"/"+(!1!==b?b.id+"/edit":"add?thread="+a.id),"ImBan"+b.id,c.get("banWindowParams"))},
|
||||||
b.id,c.get("banWindowParams"))},showFirstMessage:function(){var a=this.model.get("firstMessage");a&&alert(a)}})})(Mibew,Handlebars);
|
showFirstMessage:function(){var a=this.model.get("firstMessage");a&&alert(a)}})})(Mibew,Handlebars);
|
||||||
/*
|
/*
|
||||||
Copyright 2005-2014 the original author or authors.
|
Copyright 2005-2014 the original author or authors.
|
||||||
Licensed under the Apache License, Version 2.0 (the "License").
|
Licensed under the Apache License, Version 2.0 (the "License").
|
||||||
|
@ -180,9 +180,8 @@
|
|||||||
// Open chat window
|
// Open chat window
|
||||||
Mibew.Popup.open(
|
Mibew.Popup.open(
|
||||||
page.get('agentLink')
|
page.get('agentLink')
|
||||||
+ '?thread='
|
+ '/' + threadId
|
||||||
+ threadId
|
+ (viewOnly ? '?viewonly=true': ''),
|
||||||
+ (viewOnly ? '&viewonly=true': ''),
|
|
||||||
'ImCenter' + threadId,
|
'ImCenter' + threadId,
|
||||||
page.get('chatWindowParams')
|
page.get('chatWindowParams')
|
||||||
);
|
);
|
||||||
|
@ -569,10 +569,7 @@ function setup_chatview_for_operator(Thread $thread, $operator)
|
|||||||
// Set SSL link
|
// Set SSL link
|
||||||
if (Settings::get('enablessl') == "1" && !is_secure_request()) {
|
if (Settings::get('enablessl') == "1" && !is_secure_request()) {
|
||||||
$data['chat']['links']['ssl'] = get_app_location(true, true)
|
$data['chat']['links']['ssl'] = get_app_location(true, true)
|
||||||
. "/operator/chat?thread="
|
. "/operator/chat/" . $thread->id . '/' . $thread->lastToken;
|
||||||
. $thread->id
|
|
||||||
. "&token="
|
|
||||||
. $thread->lastToken;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set history window params
|
// Set history window params
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
namespace Mibew\Controller\Chat\Operator;
|
namespace Mibew\Controller\Chat\Operator;
|
||||||
|
|
||||||
use Mibew\Controller\Chat\AbstractController;
|
use Mibew\Controller\Chat\AbstractController;
|
||||||
use Mibew\Http\Exception\BadRequestException;
|
use Mibew\Http\Exception\NotFoundException;
|
||||||
use Mibew\Style\PageStyle;
|
use Mibew\Style\PageStyle;
|
||||||
use Mibew\Thread;
|
use Mibew\Thread;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -34,8 +34,8 @@ class ChatController extends AbstractController
|
|||||||
* @param Request $request Incoming request.
|
* @param Request $request Incoming request.
|
||||||
* @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered
|
* @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered
|
||||||
* page content or a redirect response.
|
* page content or a redirect response.
|
||||||
* @throws BadRequestException If the thread cannot be loaded by some
|
* @throws NotFoundException If the thread with specified ID and token is
|
||||||
* reasons.
|
* not found.
|
||||||
*/
|
*/
|
||||||
public function indexAction(Request $request)
|
public function indexAction(Request $request)
|
||||||
{
|
{
|
||||||
@ -46,27 +46,13 @@ class ChatController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$operator = $this->getOperator();
|
$operator = $this->getOperator();
|
||||||
|
$thread_id = $request->attributes->getInt('thread_id');
|
||||||
|
$token = $request->attributes->get('token');
|
||||||
|
|
||||||
// Get and validate thread id
|
|
||||||
$thread_id = $request->query->get('thread');
|
|
||||||
if (!preg_match("/^\d{1,10}$/", $thread_id)) {
|
|
||||||
throw new BadRequestException('Wrong value of "thread" argument.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$request->query->has('token')) {
|
|
||||||
// There is no token in the request so we need to start the chat
|
|
||||||
return $this->startChat($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get token and verify it
|
|
||||||
$token = $request->query->get('token');
|
|
||||||
if (!preg_match("/^\d{1,10}$/", $token)) {
|
|
||||||
throw new BadRequestException('Wrong value of "token" argument.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$thread = Thread::load($thread_id, $token);
|
$thread = Thread::load($thread_id, $token);
|
||||||
if (!$thread) {
|
if (!$thread) {
|
||||||
throw new BadRequestException('Wrong thread.');
|
throw new NotFoundException('The thread is not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the current operator has enough permissions to use the thread
|
// Check if the current operator has enough permissions to use the thread
|
||||||
@ -89,13 +75,11 @@ class ChatController extends AbstractController
|
|||||||
* @param Request $request Incoming request.
|
* @param Request $request Incoming request.
|
||||||
* @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered
|
* @return string|\Symfony\Component\HttpFoundation\RedirectResponse Rendered
|
||||||
* page content or a redirect response.
|
* page content or a redirect response.
|
||||||
* @throws BadRequestException If the thread cannot be loaded by some
|
|
||||||
* reasons.
|
|
||||||
*/
|
*/
|
||||||
protected function startChat(Request $request)
|
public function startAction(Request $request)
|
||||||
{
|
{
|
||||||
$operator = $this->getOperator();
|
$operator = $this->getOperator();
|
||||||
$thread_id = $request->query->getInt('thread');
|
$thread_id = $request->attributes->getInt('thread_id');
|
||||||
|
|
||||||
// Check operator's browser level because old browsers aren't supported.
|
// Check operator's browser level because old browsers aren't supported.
|
||||||
$remote_level = get_remote_level($request->headers->get('User-Agent'));
|
$remote_level = get_remote_level($request->headers->get('User-Agent'));
|
||||||
@ -122,10 +106,10 @@ class ChatController extends AbstractController
|
|||||||
|
|
||||||
if ($force_take == false) {
|
if ($force_take == false) {
|
||||||
$link = $this->generateUrl(
|
$link = $this->generateUrl(
|
||||||
'chat_operator',
|
'chat_operator_start',
|
||||||
array(
|
array(
|
||||||
'thread' => $thread_id,
|
'thread_id' => $thread_id,
|
||||||
'force' => true,
|
'force' => 'true',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$page = array(
|
$page = array(
|
||||||
@ -154,7 +138,7 @@ class ChatController extends AbstractController
|
|||||||
$redirect_to = $this->generateUrl(
|
$redirect_to = $this->generateUrl(
|
||||||
'chat_operator',
|
'chat_operator',
|
||||||
array(
|
array(
|
||||||
'thread' => intval($thread_id),
|
'thread_id' => intval($thread_id),
|
||||||
'token' => urlencode($thread->lastToken),
|
'token' => urlencode($thread->lastToken),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -52,7 +52,7 @@ class InvitationController extends AbstractController
|
|||||||
$redirect_to = $this->generateUrl(
|
$redirect_to = $this->generateUrl(
|
||||||
'chat_operator',
|
'chat_operator',
|
||||||
array(
|
array(
|
||||||
'thread' => intval($thread->id),
|
'thread_id' => intval($thread->id),
|
||||||
'token' => urlencode($thread->lastToken),
|
'token' => urlencode($thread->lastToken),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -2,10 +2,13 @@
|
|||||||
|
|
||||||
## Operator's chat
|
## Operator's chat
|
||||||
chat_operator:
|
chat_operator:
|
||||||
path: /operator/chat
|
path: /operator/chat/{thread_id}/{token}
|
||||||
defaults:
|
defaults:
|
||||||
_controller: Mibew\Controller\Chat\Operator\ChatController::indexAction
|
_controller: Mibew\Controller\Chat\Operator\ChatController::indexAction
|
||||||
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||||
|
requirements:
|
||||||
|
thread_id: \d{1,10}
|
||||||
|
token: \d{1,10}
|
||||||
|
|
||||||
chat_operator_redirect:
|
chat_operator_redirect:
|
||||||
path: /operator/chat/{thread_id}/{token}/redirect
|
path: /operator/chat/{thread_id}/{token}/redirect
|
||||||
@ -16,6 +19,14 @@ chat_operator_redirect:
|
|||||||
thread_id: \d{1,10}
|
thread_id: \d{1,10}
|
||||||
token: \d{1,10}
|
token: \d{1,10}
|
||||||
|
|
||||||
|
chat_operator_start:
|
||||||
|
path: /operator/chat/{thread_id}
|
||||||
|
defaults:
|
||||||
|
_controller: Mibew\Controller\Chat\Operator\ChatController::startAction
|
||||||
|
_access_check: Mibew\AccessControl\Check\LoggedInCheck
|
||||||
|
requirements:
|
||||||
|
thread_id: \d{1,10}
|
||||||
|
|
||||||
chat_operator_redirection_links:
|
chat_operator_redirection_links:
|
||||||
path: /operator/chat/{thread_id}/{token}/redirection-links
|
path: /operator/chat/{thread_id}/{token}/redirection-links
|
||||||
defaults:
|
defaults:
|
||||||
|
Loading…
Reference in New Issue
Block a user