Skip to content

feat(User): Add getters for avatar URLs#60734

Open
provokateurin wants to merge 1 commit into
masterfrom
feat/user/avatar-url-getters
Open

feat(User): Add getters for avatar URLs#60734
provokateurin wants to merge 1 commit into
masterfrom
feat/user/avatar-url-getters

Conversation

@provokateurin
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: provokateurin <kate@provokateurin.de>
@provokateurin provokateurin added this to the Nextcloud 35 milestone May 26, 2026
@provokateurin provokateurin requested a review from a team as a code owner May 26, 2026 13:51
@provokateurin provokateurin requested review from ArtificialOwl, artonge, leftybournes and salmart-dev and removed request for a team May 26, 2026 13:51
@provokateurin
Copy link
Copy Markdown
Member Author

/backport to stable34

Copy link
Copy Markdown
Collaborator

@artonge artonge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Comment thread lib/private/User/User.php

#[\Override]
public function getUserAvatarUrlLight(int $size): string {
$url = Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $this->uid, 'size' => $size]);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$url = Server::get(IURLGenerator::class)->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $this->uid, 'size' => $size]);
$url = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $this->uid, 'size' => $size]);

Same thing below.

@provokateurin
Copy link
Copy Markdown
Member Author

Why is this needed?

It's used at least twice in Unified Sharing, so I didn't want to duplicate the logic and thought that this could be useful for others as well.

Comment on lines +213 to +221
#[\Override]
public function getUserAvatarUrlLight(int $size): string {
return $this->getUser()->getUserAvatarUrlLight($size);
}

#[\Override]
public function getUserAvatarUrlDark(int $size): string {
return $this->getUser()->getUserAvatarUrlDark($size);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s a bit sad to resolve the user object while it’s not needed to build the URL.
I’m not entirely sure these methods have their place in IUser.

Comment thread lib/public/IUser.php
public function setManagerUids(array $uids): void;

/**
* @param 64|512 $size
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only theses?
comments uses 42
user_status uses 44

Maybe there are doing it wrong but it should be justified if we need to change them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews backport-request enhancement pending documentation This pull request needs an associated documentation update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants