getMessageObjectTypeID('be.bastelstu.chat.messageType.where'); $roomList = new \chat\data\room\RoomList(); $roomList->readObjects(); $rooms = array_map(function (Room $room) { $users = array_map(function (\chat\data\user\User $user) { return $user->jsonSerialize(); }, $room->getUsers()); return [ 'roomID' => $room->roomID , 'users' => array_values($users) ]; }, array_filter($roomList->getObjects(), 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(); } }