mirror of
https://github.com/Mibew/mibew.git
synced 2025-05-12 06:43:08 +03:00
Fix attempt to restore closed chat in popup
This commit is contained in:
parent
8a2fbc6f38
commit
5f2aab1501
@ -49,6 +49,14 @@ chat_user:
|
|||||||
thread_id: \d{1,10}
|
thread_id: \d{1,10}
|
||||||
token: \d{1,10}
|
token: \d{1,10}
|
||||||
|
|
||||||
|
chat_user_check:
|
||||||
|
path: /chat/{thread_id}/{token}/check
|
||||||
|
defaults:
|
||||||
|
_controller: Mibew\Controller\Chat\UserChatController::checkAction
|
||||||
|
requirements:
|
||||||
|
thread_id: \d{1,10}
|
||||||
|
token: \d{1,10}
|
||||||
|
|
||||||
chat_user_invitation:
|
chat_user_invitation:
|
||||||
path: /chat/invitation
|
path: /chat/invitation
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -333,7 +333,7 @@ var Mibew = Mibew || {};
|
|||||||
if (openedChatUrl) {
|
if (openedChatUrl) {
|
||||||
// The chat was not closed so the popup should be reopened when a
|
// The chat was not closed so the popup should be reopened when a
|
||||||
// new page is visited.
|
// new page is visited.
|
||||||
this.open(openedChatUrl);
|
this.safeOpen(openedChatUrl);
|
||||||
// Check minification status of the popup and toggle it if needed.
|
// Check minification status of the popup and toggle it if needed.
|
||||||
var minifiedPopup = Mibew.Utils.readCookie('mibew-chat-frame-minified-' + this.id);
|
var minifiedPopup = Mibew.Utils.readCookie('mibew-chat-frame-minified-' + this.id);
|
||||||
if (minifiedPopup === 'true') {
|
if (minifiedPopup === 'true') {
|
||||||
@ -430,6 +430,24 @@ var Mibew = Mibew || {};
|
|||||||
this.isOpened = true;
|
this.isOpened = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check chat URL via special request, open the chat if check passes,
|
||||||
|
* close the popup if the check fails.
|
||||||
|
*
|
||||||
|
* @param {String} [url] The URL to open in the popup
|
||||||
|
*/
|
||||||
|
Mibew.ChatPopup.IFrame.prototype.safeOpen = function(url) {
|
||||||
|
var check = Mibew.Utils.loadScript(url + '/check', 'mibew-check-iframe-' + this.id);
|
||||||
|
check.popup = this;
|
||||||
|
check.url = url;
|
||||||
|
check.onload = function(){
|
||||||
|
this.popup.open(this.url);
|
||||||
|
}
|
||||||
|
check.onerror = function(){
|
||||||
|
this.popup.close();
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the popup.
|
* Closes the popup.
|
||||||
*/
|
*/
|
||||||
|
@ -74,6 +74,31 @@ class UserChatController extends AbstractController
|
|||||||
return $this->render('chat', $page);
|
return $this->render('chat', $page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check chat to exists.
|
||||||
|
*
|
||||||
|
* @param Request $request Incoming request.
|
||||||
|
* @return string Empty string.
|
||||||
|
* @throws NotFoundException If the thread with specified ID and token is
|
||||||
|
* not found.
|
||||||
|
*/
|
||||||
|
public function checkAction(Request $request)
|
||||||
|
{
|
||||||
|
$thread_id = $request->attributes->getInt('thread_id');
|
||||||
|
$token = $request->attributes->get('token');
|
||||||
|
|
||||||
|
// We have to check that the thread is owned by the user.
|
||||||
|
$is_own_thread = isset($_SESSION[SESSION_PREFIX . 'own_threads'])
|
||||||
|
&& in_array($thread_id, $_SESSION[SESSION_PREFIX . 'own_threads']);
|
||||||
|
|
||||||
|
$thread = Thread::load($thread_id, $token);
|
||||||
|
if (!$thread || !$is_own_thread) {
|
||||||
|
throw new NotFoundException('The thread is not found.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the chat.
|
* Starts the chat.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user