mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-21 21:30:08 +00:00
Improve attachment error handling
This commit is contained in:
parent
a0557e3178
commit
09892db6f1
@ -5,7 +5,7 @@
|
|||||||
* Use of this software is governed by the Business Source License
|
* Use of this software is governed by the Business Source License
|
||||||
* included in the LICENSE file.
|
* included in the LICENSE file.
|
||||||
*
|
*
|
||||||
* Change Date: 2024-11-01
|
* Change Date: 2024-11-02
|
||||||
*
|
*
|
||||||
* On the date above, in accordance with the Business Source
|
* On the date above, in accordance with the Business Source
|
||||||
* License, use of this software will be governed by version 2
|
* License, use of this software will be governed by version 2
|
||||||
@ -318,6 +318,8 @@ public function validatePushAttachment() {
|
|||||||
$user = new \chat\data\user\User(WCF::getUser());
|
$user = new \chat\data\user\User(WCF::getUser());
|
||||||
if (!$user->isInRoom($room)) throw new PermissionDeniedException();
|
if (!$user->isInRoom($room)) throw new PermissionDeniedException();
|
||||||
|
|
||||||
|
if (!$room->canWritePublicly(null, $reason)) throw $reason;
|
||||||
|
|
||||||
$this->readString('tmpHash');
|
$this->readString('tmpHash');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,7 +339,7 @@ public function pushAttachment() {
|
|||||||
foreach ($attachments as $attachment) {
|
foreach ($attachments as $attachment) {
|
||||||
$attachmentIDs[] = $attachment->attachmentID;
|
$attachmentIDs[] = $attachment->attachmentID;
|
||||||
}
|
}
|
||||||
|
|
||||||
$processor = new \wcf\system\html\input\HtmlInputProcessor();
|
$processor = new \wcf\system\html\input\HtmlInputProcessor();
|
||||||
$processor->process(implode(' ', array_map(function ($attachmentID) {
|
$processor->process(implode(' ', array_map(function ($attachmentID) {
|
||||||
return '[attach='.$attachmentID.',none,true][/attach]';
|
return '[attach='.$attachmentID.',none,true][/attach]';
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Use of this software is governed by the Business Source License
|
* Use of this software is governed by the Business Source License
|
||||||
* included in the LICENSE file.
|
* included in the LICENSE file.
|
||||||
*
|
*
|
||||||
* Change Date: 2024-11-01
|
* Change Date: 2024-11-02
|
||||||
*
|
*
|
||||||
* On the date above, in accordance with the Business Source
|
* On the date above, in accordance with the Business Source
|
||||||
* License, use of this software will be governed by version 2
|
* License, use of this software will be governed by version 2
|
||||||
@ -570,6 +570,11 @@ #tpl_chat_log {
|
|||||||
.attachmentPreview {
|
.attachmentPreview {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
|
.error {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
margin-left: auto !important;
|
margin-left: auto !important;
|
||||||
margin-right: auto !important;
|
margin-right: auto !important;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Use of this software is governed by the Business Source License
|
* Use of this software is governed by the Business Source License
|
||||||
* included in the LICENSE file.
|
* included in the LICENSE file.
|
||||||
*
|
*
|
||||||
* Change Date: 2024-11-01
|
* Change Date: 2024-11-02
|
||||||
*
|
*
|
||||||
* On the date above, in accordance with the Business Source
|
* On the date above, in accordance with the Business Source
|
||||||
* License, use of this software will be governed by version 2
|
* License, use of this software will be governed by version 2
|
||||||
@ -177,8 +177,16 @@ define([
|
|||||||
this.deleteOnClose = false
|
this.deleteOnClose = false
|
||||||
this.closeDialog()
|
this.closeDialog()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// TODO: Error handling
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
||||||
|
let container = this._target.querySelector('.error')
|
||||||
|
if (!container) {
|
||||||
|
container = document.createElement('div')
|
||||||
|
container.classList.add('error')
|
||||||
|
this._target.insertBefore(container, this._target.firstChild)
|
||||||
|
}
|
||||||
|
container.innerText = error.message
|
||||||
|
Dialog.rebuild(DIALOG_CONTAINER_ID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user