Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user profile image/banner #181

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions definitions/UserDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use humhub\modules\user\models\Group;
use humhub\modules\user\models\Session;
use humhub\modules\user\models\User;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

/**
Expand All @@ -41,14 +42,26 @@ public static function getUser(User $user)
'display_name' => $user->displayName,
'url' => Url::to(['/', 'container' => $user], true),
'account' => static::getAccount($user),
'profile' => static::getProfile($user->profile),
'profile' => static::getProfile($user),
];
}

public static function getProfile(Profile $profile)
public static function getProfile(User $user)
{
$attributes = $profile->attributes;
unset($attributes['user_id']);
$attributes = $user->profile->attributes;
ArrayHelper::remove($attributes, 'user_id');

ArrayHelper::setValue(
$attributes,
'image_url',
Url::to($user->profileImage->getUrl(), true),
);
ArrayHelper::setValue(
$attributes,
'banner_url',
Url::to($user->profileBannerImage->getUrl(), true),
);

return $attributes;
}

Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

0.10.4 (Unreleased)
---------------------------
- Enh #181: Added user profile `image_url` and `banner_url`

0.10.3 (September 13, 2024)
---------------------------
- Enh #177: Collect user data for Legal module
Expand Down
4 changes: 2 additions & 2 deletions docs/html/auth.html

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/html/user.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/swagger/user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,10 @@ definitions:
type: string
url_twitter:
type: string
image_url:
type: string
banner_url:
type: string
xml:
name: Profile

Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": [
"api", "rest"
],
"version": "0.10.3",
"version": "0.10.4",
"homepage": "https://github.com/humhub/rest",
"humhub": {
"minVersion": "1.16"
Expand Down
Loading