Tims-Chat/files/lib/system/message/type/UnsuspendMessageType.class.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

107 lines
2.5 KiB
PHP
Raw Normal View History

2018-08-16 22:30:59 +00:00
<?php
2022-03-04 17:10:24 +00:00
2018-08-16 22:30:59 +00:00
/*
2022-03-04 17:10:24 +00:00
* Copyright (c) 2010-2022 Tim Düsterhus.
2018-08-16 22:30:59 +00:00
*
* Use of this software is governed by the Business Source License
* included in the LICENSE file.
*
2022-03-04 17:10:24 +00:00
* Change Date: 2026-03-04
2018-08-16 22:30:59 +00:00
*
* On the date above, in accordance with the Business Source
* License, use of this software will be governed by version 2
* or later of the General Public License.
*/
namespace chat\system\message\type;
2022-03-04 17:10:24 +00:00
use chat\data\message\Message;
use chat\data\room\Room;
use wcf\data\user\UserProfile;
use wcf\system\event\EventHandler;
use wcf\system\WCF;
2018-08-16 22:30:59 +00:00
/**
* UnsuspendMessageType informs about removed suspensions.
*/
2022-03-04 17:10:24 +00:00
class UnsuspendMessageType implements IMessageType
{
/**
* @inheritDoc
*/
public function getJavaScriptModuleName()
{
return 'Bastelstu.be/Chat/MessageType/Unsuspend';
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* @inheritDoc
*/
public function getPayload(Message $message, ?UserProfile $user = null)
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
$payload = $message->payload;
unset($payload['roomIDs']);
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
$parameters = [
'message' => $message,
'user' => $user,
'payload' => $payload,
];
EventHandler::getInstance()->fireAction($this, 'getPayload', $parameters);
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
return $parameters['payload'];
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* @inheritDoc
*/
public function canSee(Message $message, Room $room, ?UserProfile $user = null)
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
$parameters = [
'message' => $message,
'room' => $room,
'user' => $user,
'canSee' => \in_array($room->roomID, $message->payload['roomIDs'], true),
];
EventHandler::getInstance()->fireAction($this, 'canSee', $parameters);
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
return $parameters['canSee'];
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* @inheritDoc
*/
public function canSeeInLog(Message $message, Room $room, ?UserProfile $user = null)
{
if ($user === null) {
$user = new UserProfile(WCF::getUser());
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
$parameters = [
'message' => $message,
'room' => $room,
'user' => $user,
'canSee' => \in_array($room->roomID, $message->payload['roomIDs'], true),
];
EventHandler::getInstance()->fireAction($this, 'canSeeInLog', $parameters);
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
return $parameters['canSee'];
}
2018-08-16 22:30:59 +00:00
2022-03-04 17:10:24 +00:00
/**
* @inheritDoc
*/
public function supportsFastSelect()
{
return false;
}
2018-08-16 22:30:59 +00:00
}