mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-21 21:30:08 +00:00
Prevent inviting users who have blocked the sender
This commit is contained in:
parent
32ba532bc7
commit
14c594b082
@ -192,7 +192,7 @@ Open the smiley wcfDialog
|
||||
Handle private channel menu
|
||||
|
||||
$('#timsChatMessageTabMenu > .tabMenu').on 'click', '.timsChatMessageTabMenuAnchor', ->
|
||||
openPrivateChannel $(@).data 'userID'
|
||||
openPrivateChannel $(@).data 'userID'
|
||||
|
||||
Handle submitting the form. The message will be validated by some basic checks, passed to the `submit` eventlisteners
|
||||
and afterwards sent to the server by an AJAX request.
|
||||
@ -410,11 +410,19 @@ Show invite dialog.
|
||||
success: (data) ->
|
||||
do new WCF.System.Notification(WCF.Language.get 'wcf.global.success').show
|
||||
|
||||
failure: (data) ->
|
||||
return true unless (data?.returnValues?.errorType?) or (data?.message?)
|
||||
|
||||
$("""<div class="ajaxDebugMessage">#{(data?.returnValues?.errorType) ? data.message}</div>""").wcfDialog title: WCF.Language.get 'wcf.global.error.title'
|
||||
|
||||
return false
|
||||
|
||||
$('#timsChatInviteDialog').wcfDialog 'close'
|
||||
|
||||
timsChatInviteDialog.wcfDialog
|
||||
title: WCF.Language.get 'chat.global.invite'
|
||||
|
||||
onShow: -> do $('#userInviteDialogUsernameInput').focus
|
||||
|
||||
|
||||
Hide topic container.
|
||||
|
||||
|
@ -67,12 +67,35 @@ public function validateInvite() {
|
||||
if (!$this->room->canEnter()) throw new \wcf\system\exception\PermissionDeniedException();
|
||||
|
||||
if (!isset($this->parameters['recipients'])) throw new \wcf\system\exception\UserInputException("recipients");
|
||||
|
||||
$this->parameters['recipients'] = \wcf\util\ArrayUtil::toIntegerArray($this->parameters['recipients']);
|
||||
|
||||
$ignoredByList = new \wcf\data\user\ignore\UserIgnoreList();
|
||||
$ignoredByList->getConditionBuilder()->add('user_ignore.ignoreUserID = ?', array(WCF::getUser()->userID));
|
||||
$ignoredByList->getConditionBuilder()->add('user_ignore.userID IN (?)', array($this->parameters['recipients']));
|
||||
|
||||
if (!empty($ignoredByList->sqlSelects)) $ignoredByList->sqlSelects .= ',';
|
||||
$ignoredByList->sqlSelects .= "user_ignore.ignoreID";
|
||||
$ignoredByList->sqlSelects .= ", user_table.username";
|
||||
$ignoredByList->sqlJoins .= " LEFT JOIN wcf".WCF_N."_user user_table ON (user_table.userID = user_ignore.userID)";
|
||||
|
||||
$ignoredByList->readObjects();
|
||||
$ignoredByUsers = $ignoredByList->getObjects();
|
||||
|
||||
if (!empty($ignoredByUsers)) {
|
||||
$usernames = array();
|
||||
foreach ($ignoredByUsers as $user) {
|
||||
$usernames[] = $user->username;
|
||||
}
|
||||
|
||||
throw new \wcf\system\exception\UserInputException("recipients", WCF::getLanguage()->getDynamicVariable('chat.error.invite.ignored', array('users' => $ignoredByUsers, 'usernames' => $usernames)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invites users.
|
||||
*/
|
||||
public function invite() {
|
||||
\wcf\system\user\notification\UserNotificationHandler::getInstance()->fireEvent('invited', 'be.bastelstu.chat.room', new \chat\system\user\notification\object\RoomUserNotificationObject($this->room), \wcf\util\ArrayUtil::toIntegerArray($this->parameters['recipients']), array('userID' => WCF::getUser()->userID));
|
||||
\wcf\system\user\notification\UserNotificationHandler::getInstance()->fireEvent('invited', 'be.bastelstu.chat.room', new \chat\system\user\notification\object\RoomUserNotificationObject($this->room), $this->parameters['recipients'], array('userID' => WCF::getUser()->userID));
|
||||
}
|
||||
}
|
||||
|
@ -149,6 +149,7 @@ Probieren Sie, den Chat neu zu laden<!-- , bei Risiken und Nebenwirkungen fragen
|
||||
<item name="chat.error.reload"><![CDATA[Neu laden]]></item>
|
||||
|
||||
<item name="chat.error.whisper.ignoresYou"><![CDATA[„{$user}“ hat Sie blockiert.]]></item>
|
||||
<item name="chat.error.invite.ignored"><![CDATA[Die folgenden Nutzer haben Sie blockiert: {implode from=$usernames item=username}{$username}{/implode}]]></item>
|
||||
</category>
|
||||
|
||||
<category name="chat.global">
|
||||
|
@ -149,6 +149,7 @@ Please try to reload the chat.]]></item>
|
||||
<item name="chat.error.reload"><![CDATA[Reload]]></item>
|
||||
|
||||
<item name="chat.error.whisper.ignoresYou"><![CDATA[“{$user}” has blocked you.]]></item>
|
||||
<item name="chat.error.invite.ignored"><![CDATA[The following users have blocked you: {implode from=$usernames item=username}{$username}{/implode}]]></item>
|
||||
</category>
|
||||
|
||||
<category name="chat.global">
|
||||
|
Loading…
Reference in New Issue
Block a user