assertUser($this->assertParameter($parameters, 'username')); } /** * @inheritDoc */ public function execute($parameters, Room $room, ?UserProfile $user = null) { if ($user === null) { $user = new UserProfile(WCF::getUser()); } $objectTypeID = $this->getMessageObjectTypeID('be.bastelstu.chat.messageType.info'); $target = new ChatUser($this->getUser($this->assertParameter($parameters, 'username'))); $rooms = \array_values(\array_map(static function ($assoc) { $room = RoomCache::getInstance()->getRoom($assoc['roomID']); return [ 'title' => (string)$room, 'roomID' => $assoc['roomID'], 'lastPush' => $assoc['lastPush'], 'lastPull' => $assoc['lastPull'], 'active' => $assoc['active'], 'link' => $room->getLink(), ]; }, \array_filter($target->getRoomAssociations(), static function ($assoc) { return RoomCache::getInstance()->getRoom($assoc['roomID'])->canSee(); }))); $payload = [ 'data' => [ 'rooms' => $rooms, 'away' => $target->chatAway, 'user' => $target, ], 'caller' => $user, ]; EventHandler::getInstance()->fireAction($this, 'execute', $payload); (new MessageAction( [ ], 'create', [ 'data' => [ 'roomID' => $room->roomID, 'userID' => $user->userID, 'username' => $user->username, 'time' => TIME_NOW, 'objectTypeID' => $objectTypeID, 'payload' => \serialize($payload['data']), ], 'updateTimestamp' => true, ] ))->executeAction(); } }