getMessageObjectTypeID('be.bastelstu.chat.messageType.where'); $roomList = new RoomList(); $roomList->readObjects(); $rooms = \array_map(static function (Room $room) { $users = \array_map(static function (ChatUser $user) { return $user->jsonSerialize(); }, $room->getUsers()); return [ 'roomID' => $room->roomID, 'users' => \array_values($users), ]; }, \array_filter($roomList->getObjects(), static function (Room $room) { return $room->canSee(); })); (new MessageAction( [ ], 'create', [ 'data' => [ 'roomID' => $room->roomID, 'userID' => $user->userID, 'username' => $user->username, 'time' => TIME_NOW, 'objectTypeID' => $objectTypeID, 'payload' => \serialize($rooms), ], 'updateTimestamp' => true, ] ))->executeAction(); } }