-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMarkAllConversationsAsRead.class.php
More file actions
49 lines (42 loc) · 1.38 KB
/
MarkAllConversationsAsRead.class.php
File metadata and controls
49 lines (42 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
namespace wcf\command\conversation;
use wcf\data\user\User;
use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\user\storage\UserStorageHandler;
use wcf\system\WCF;
/**
* Marks all conversations for a given user as read.
*
* @author Marcel Werk
* @copyright 2001-2025 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 6.2
*/
final class MarkAllConversationsAsRead
{
public function __construct(
public readonly User $user
) {}
public function __invoke(): void
{
$sql = "UPDATE wcf1_conversation_to_user
SET lastVisitTime = ?
WHERE participantID = ?";
$statement = WCF::getDB()->prepare($sql);
$statement->execute([
\TIME_NOW,
$this->user->userID,
]);
UserStorageHandler::getInstance()->reset([$this->user->userID], 'unreadConversationCount');
UserNotificationHandler::getInstance()->markAsConfirmed(
'conversation',
'com.woltlab.wcf.conversation.notification',
[$this->user->userID]
);
UserNotificationHandler::getInstance()->markAsConfirmed(
'conversationMessage',
'com.woltlab.wcf.conversation.message.notification',
[$this->user->userID]
);
}
}