Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b553b43
Make possible to send requests as anonymous users in integration tests
danxuliu Dec 3, 2020
184742e
Make possible to set body in requesttoken requests in integration tests
danxuliu Dec 3, 2020
2cc22a0
Add integration tests for user avatars
danxuliu Dec 3, 2020
1552add
Add integration tests for resized user avatars
danxuliu Dec 4, 2020
b4b3276
Add integration tests for getting guest avatars
danxuliu Dec 7, 2020
1de8dc3
Add getter for generic avatars to IAvatarManager
danxuliu Dec 7, 2020
bcce5a6
Add OCS endpoint for avatars
danxuliu Dec 7, 2020
2522439
Make possible to set body in OCS requests in integration tests
danxuliu Dec 7, 2020
b190431
Add integration tests for getting and setting generic avatars
danxuliu Dec 7, 2020
63cbd7b
fixup! Add OCS endpoint for avatars
danxuliu Dec 9, 2020
a31a7fd
fixup! Add OCS endpoint for avatars
danxuliu Dec 10, 2020
92c9fc0
Make possible to define custom avatar types
danxuliu Dec 10, 2020
a836608
fixup! Add OCS endpoint for avatars
danxuliu Dec 10, 2020
95e0177
Move registration of IAvatarProviders to IRegistrationContext
danxuliu Dec 10, 2020
f04a16a
fixup! Make possible to define custom avatar types
danxuliu Dec 14, 2020
ebf242a
fixup! Add OCS endpoint for avatars
danxuliu Dec 14, 2020
bf9169e
fixup! Add getter for generic avatars to IAvatarManager
danxuliu Dec 14, 2020
1e13309
fixup! Make possible to define custom avatar types
danxuliu Dec 14, 2020
6e43ce7
fixup! Add OCS endpoint for avatars
danxuliu Dec 14, 2020
90ac35d
fixup! Make possible to define custom avatar types
danxuliu Dec 14, 2020
5d0102e
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu Dec 14, 2020
ab910ec
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu Dec 14, 2020
a2c63ff
fixup! Make possible to define custom avatar types
danxuliu Dec 14, 2020
76e4bd2
Move deprecated ILogger to LoggerInterface in avatar private classes
danxuliu Dec 14, 2020
612dbe6
Add explicit providers for user and guest avatars
danxuliu Dec 14, 2020
0e953eb
Remove no longer needed attributes from AvatarManager
danxuliu Dec 14, 2020
0bb311f
Get the avatar provider rather than the avatar itself from the manager
danxuliu Dec 14, 2020
611881b
Add method to get the cache duration of an avatar to IAvatarProvider
danxuliu Dec 14, 2020
6c99a9a
fixup! Add method to get the cache duration of an avatar to IAvatarPr…
danxuliu Dec 14, 2020
6079793
fixup! Add explicit providers for user and guest avatars
danxuliu Dec 15, 2020
bcd2074
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu Dec 15, 2020
23f4c1d
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu Dec 15, 2020
e88d3b6
fixup! Make possible to define custom avatar types
danxuliu Dec 15, 2020
4a26943
fixup! Add explicit providers for user and guest avatars
danxuliu Dec 15, 2020
fa0342a
fixup! Add explicit providers for user and guest avatars
danxuliu Dec 15, 2020
ebc3f14
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu Dec 15, 2020
03eed3e
fixup! Add integration tests for getting and setting generic avatars
danxuliu Dec 15, 2020
1348cab
fixup! Add integration tests for getting and setting generic avatars
danxuliu Dec 15, 2020
8d69a4e
fixup! Add OCS endpoint for avatars
danxuliu Dec 15, 2020
4368ec0
fixup! Make possible to define custom avatar types
danxuliu Dec 15, 2020
6b8f290
fixup! Add integration tests for getting and setting generic avatars
danxuliu Dec 15, 2020
68b298e
fixup! Add method to get the cache duration of an avatar to IAvatarPr…
danxuliu Dec 16, 2020
cc7cd18
Split try/catch blocks to catch only the relevant exceptions
danxuliu Dec 16, 2020
6ed5fde
Add method to check if an avatar can be accessed by the current user
danxuliu Dec 16, 2020
65c8c22
Add method to check if an avatar can be modified by the current user
danxuliu Dec 16, 2020
135d14b
Add integration tests for unauthorized modification of avatars
danxuliu Dec 16, 2020
330fac8
Add method to get the version of an avatar
danxuliu Dec 16, 2020
68fa045
Limit the returned sizes of the avatars to a predefined set
danxuliu Dec 16, 2020
601d741
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu Dec 16, 2020
6391a2b
fixup! Add explicit providers for user and guest avatars
danxuliu Dec 16, 2020
029d22c
fixup! Add method to check if an avatar can be modified by the curren…
danxuliu Dec 16, 2020
3a4b926
fixup! Add explicit providers for user and guest avatars
danxuliu Dec 16, 2020
6895199
fixup! Make possible to define custom avatar types
danxuliu Dec 16, 2020
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
Prev Previous commit
Next Next commit
Add method to get the version of an avatar
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu committed Dec 16, 2020
commit 330fac872282eec66ff114cb315b23df9f51908b
10 changes: 10 additions & 0 deletions lib/private/Avatar/GuestAvatarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ public function canBeModifiedByCurrentUser(IAvatar $avatar): bool {
return false;
}

/**
* Returns the latest value of the avatar version
*
* @param IAvatar $avatar ignored
* @return int 0, as versions are not supported by guest avatars
*/
public function getVersion(IAvatar $avatar): int {
return 0;
}

/**
* Returns the cache duration for guest avatars in seconds
*
Expand Down
15 changes: 15 additions & 0 deletions lib/private/Avatar/UserAvatarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,21 @@ public function canBeModifiedByCurrentUser(IAvatar $avatar): bool {
return $avatar->getUser()->getUID() === $this->currentUser->getUID();
}

/**
* Returns the latest value of the avatar version
*
* @param IAvatar $avatar the avatar to check
* @return int the latest value of the avatar version
* @throws \InvalidArgumentException if the given avatar is not a UserAvatar
*/
public function getVersion(IAvatar $avatar): int {
if (!($avatar instanceof UserAvatar)) {
throw new \InvalidArgumentException();
}

return (int) $this->config->getUserValue($avatar->getUser()->getUID(), 'avatar', 'version', 0);
}

/**
* Returns the cache duration for user avatars in seconds
*
Expand Down
16 changes: 16 additions & 0 deletions lib/public/IAvatarProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ public function canBeAccessedByCurrentUser(IAvatar $avatar): bool;
*/
public function canBeModifiedByCurrentUser(IAvatar $avatar): bool;
Copy link
Member

Choose a reason for hiding this comment

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

I agree with @ChristophWurst that we should inject the user here


/**
* Returns the latest value of the avatar version
*
* Implementers of IAvatarProvider may not throw \InvalidArgumentException
* if the behaviour does not depend on specific avatar instances (for
* example, if versions are not supported and the same version is always
* returned).
*
Comment on lines +84 to +90
Copy link
Member

Choose a reason for hiding this comment

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

Now you described what it does. But what is it used for? Caching of the avatars? Do we need to bump it on each patch we do?

* @param IAvatar $avatar the avatar to check
* @return int the latest value of the avatar version
* @throws \InvalidArgumentException if the given avatar is not supported by
* this provider
* @since 21.0.0
*/
public function getVersion(IAvatar $avatar): int;

/**
* Returns the cache duration in seconds
*
Expand Down