diff --git a/controllers/user/InviteController.php b/controllers/user/InviteController.php index 89509a5..3af6387 100644 --- a/controllers/user/InviteController.php +++ b/controllers/user/InviteController.php @@ -8,7 +8,7 @@ namespace humhub\modules\rest\controllers\user; use humhub\modules\rest\components\BaseController; -use humhub\modules\user\models\Invite; +use humhub\modules\rest\models\Invite; use humhub\modules\rest\definitions\InviteDefinitions; use humhub\modules\user\models\User; use Yii; @@ -57,7 +57,9 @@ public function actionIndex() public function actionList() { - $query = Invite::find()->where(['source' => Invite::SOURCE_INVITE]); + $query = Invite::find() + ->where(['source' => Invite::SOURCE_INVITE]) + ->with(['space', 'originator', 'createdBy', 'updatedBy']); $pagination = $this->handlePagination($query, 10); diff --git a/definitions/InviteDefinitions.php b/definitions/InviteDefinitions.php index a048c11..bac3dec 100644 --- a/definitions/InviteDefinitions.php +++ b/definitions/InviteDefinitions.php @@ -2,7 +2,7 @@ namespace humhub\modules\rest\definitions; -use humhub\modules\user\models\Invite; +use humhub\modules\rest\models\Invite; class InviteDefinitions { @@ -11,6 +11,15 @@ public static function getInvite(Invite $invite) return [ 'id' => $invite->id, 'email' => $invite->email, + 'firstname' => $invite->firstname, + 'lastname' => $invite->lastname, + 'language' => $invite->language, + 'space' => $invite->space ? SpaceDefinitions::getSpaceShort($invite->space) : null, + 'originator' => $invite->originator ? UserDefinitions::getUserShort($invite->originator) : null, + 'createdBy' => $invite->createdBy ? UserDefinitions::getUserShort($invite->createdBy) : null, + 'updatedBy' => $invite->updatedBy ? UserDefinitions::getUserShort($invite->updatedBy) : null, + 'createdAt' => $invite->created_at, + 'updatedAt' => $invite->updated_at, ]; } } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 900215d..229cf5b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -11,6 +11,7 @@ Changelog - Enh #155: Add `requirements.php` - Fix #164: Disable `mustChangePassword` check for impersonated access tokens - Enh #170: Added new endpoint `GET /user/invite` for user pending invites +- Enh #171: Extended invite information in response of `GET /user/invite` endpoint 0.9.3 (December 8, 2023) ------------------------ diff --git a/docs/html/user.html b/docs/html/user.html index 8fc97c5..40fa5a2 100644 --- a/docs/html/user.html +++ b/docs/html/user.html @@ -472,14 +472,14 @@
{- "emails": [
- "test1@example.com",
- "test2@example.com"
]
}
{- "total": 76,
- "page": 1,
- "results": [
- {
- "id": 14,
- "email": "email@email.org",
- "firstname": "John",
- "lastname": "Doe",
- "language": "English",
- "space": {
- "id": 1,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "name": "Welcome Space",
- "description": "Your first sample space to discover the platform.",
}, - "originator": {
- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "display_name": "John Doe",
}, - "createdBy": {
- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "display_name": "John Doe",
}, - "updatedBy": {
- "id": 14,
- "guid": "cd081891-d2e2-40d5-84a4-b47309e71c80",
- "display_name": "John Doe",
}, - "createdAt": "2024-09-11 08:46:40",
- "updatedAt": "2024-09-15 08:46:40"
}
]
}