1
0
mirror of https://github.com/wbbaddons/Tims-Chat.git synced 2024-12-21 21:30:08 +00:00

Delete attachments when deleting messages

This commit is contained in:
Tim Düsterhus 2020-11-01 13:21:28 +01:00
parent db49854c8c
commit e9739cd806
Signed by: TimWolla
GPG Key ID: 8FF75566094168AF

View File

@ -1,11 +1,11 @@
<?php <?php
/* /*
* Copyright (c) 2010-2018 Tim Düsterhus. * Copyright (c) 2010-2020 Tim Düsterhus.
* *
* 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-10-20 * Change Date: 2024-11-01
* *
* 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
@ -14,6 +14,9 @@
namespace chat\data\message; namespace chat\data\message;
use \wcf\system\attachment\AttachmentHandler;
use \wcf\system\WCF;
/** /**
* Represents a chat message editor. * Represents a chat message editor.
*/ */
@ -22,4 +25,20 @@ class MessageEditor extends \wcf\data\DatabaseObjectEditor {
* @inheritDoc * @inheritDoc
*/ */
protected static $baseClass = Message::class; protected static $baseClass = Message::class;
/**
* @inheritDoc
*/
public static function deleteAll(array $messageIDs = []) {
WCF::getDB()->beginTransaction();
$result = parent::deleteAll($messageIDs);
if (!empty($messageIDs)) {
AttachmentHandler::removeAttachments('be.bastelstu.chat.message', $messageIDs);
}
WCF::getDB()->commitTransaction();
return $result;
}
} }