-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Make possible for apps to define their own avatar types #24579
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
Closed
danxuliu
wants to merge
53
commits into
master
from
make-possible-for-apps-to-define-their-own-avatar-types
Closed
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 184742e
Make possible to set body in requesttoken requests in integration tests
danxuliu 2cc22a0
Add integration tests for user avatars
danxuliu 1552add
Add integration tests for resized user avatars
danxuliu b4b3276
Add integration tests for getting guest avatars
danxuliu 1de8dc3
Add getter for generic avatars to IAvatarManager
danxuliu bcce5a6
Add OCS endpoint for avatars
danxuliu 2522439
Make possible to set body in OCS requests in integration tests
danxuliu b190431
Add integration tests for getting and setting generic avatars
danxuliu 63cbd7b
fixup! Add OCS endpoint for avatars
danxuliu a31a7fd
fixup! Add OCS endpoint for avatars
danxuliu 92c9fc0
Make possible to define custom avatar types
danxuliu a836608
fixup! Add OCS endpoint for avatars
danxuliu 95e0177
Move registration of IAvatarProviders to IRegistrationContext
danxuliu f04a16a
fixup! Make possible to define custom avatar types
danxuliu ebf242a
fixup! Add OCS endpoint for avatars
danxuliu bf9169e
fixup! Add getter for generic avatars to IAvatarManager
danxuliu 1e13309
fixup! Make possible to define custom avatar types
danxuliu 6e43ce7
fixup! Add OCS endpoint for avatars
danxuliu 90ac35d
fixup! Make possible to define custom avatar types
danxuliu 5d0102e
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu ab910ec
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu a2c63ff
fixup! Make possible to define custom avatar types
danxuliu 76e4bd2
Move deprecated ILogger to LoggerInterface in avatar private classes
danxuliu 612dbe6
Add explicit providers for user and guest avatars
danxuliu 0e953eb
Remove no longer needed attributes from AvatarManager
danxuliu 0bb311f
Get the avatar provider rather than the avatar itself from the manager
danxuliu 611881b
Add method to get the cache duration of an avatar to IAvatarProvider
danxuliu 6c99a9a
fixup! Add method to get the cache duration of an avatar to IAvatarPr…
danxuliu 6079793
fixup! Add explicit providers for user and guest avatars
danxuliu bcd2074
fixup! Move registration of IAvatarProviders to IRegistrationContext
danxuliu 23f4c1d
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu e88d3b6
fixup! Make possible to define custom avatar types
danxuliu 4a26943
fixup! Add explicit providers for user and guest avatars
danxuliu fa0342a
fixup! Add explicit providers for user and guest avatars
danxuliu ebc3f14
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu 03eed3e
fixup! Add integration tests for getting and setting generic avatars
danxuliu 1348cab
fixup! Add integration tests for getting and setting generic avatars
danxuliu 8d69a4e
fixup! Add OCS endpoint for avatars
danxuliu 4368ec0
fixup! Make possible to define custom avatar types
danxuliu 6b8f290
fixup! Add integration tests for getting and setting generic avatars
danxuliu 68b298e
fixup! Add method to get the cache duration of an avatar to IAvatarPr…
danxuliu cc7cd18
Split try/catch blocks to catch only the relevant exceptions
danxuliu 6ed5fde
Add method to check if an avatar can be accessed by the current user
danxuliu 65c8c22
Add method to check if an avatar can be modified by the current user
danxuliu 135d14b
Add integration tests for unauthorized modification of avatars
danxuliu 330fac8
Add method to get the version of an avatar
danxuliu 68fa045
Limit the returned sizes of the avatars to a predefined set
danxuliu 601d741
fixup! Get the avatar provider rather than the avatar itself from the…
danxuliu 6391a2b
fixup! Add explicit providers for user and guest avatars
danxuliu 029d22c
fixup! Add method to check if an avatar can be modified by the curren…
danxuliu 3a4b926
fixup! Add explicit providers for user and guest avatars
danxuliu 6895199
fixup! Make possible to define custom avatar types
danxuliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fixup! Make possible to define custom avatar types
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
- Loading branch information
commit e88d3b6a4ca54cbd40abf53fc5e4b0f814732d2b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||
| <?php | ||||||
|
|
||||||
| declare(strict_types=1); | ||||||
|
|
||||||
| /** | ||||||
| * @copyright Copyright (c) 2020, Daniel Calviño Sánchez ([email protected]) | ||||||
| * | ||||||
| * @author Daniel Calviño Sánchez <[email protected]> | ||||||
| * | ||||||
| * @license GNU AGPL version 3 or any later version | ||||||
| * | ||||||
| * This program is free software: you can redistribute it and/or modify | ||||||
| * it under the terms of the GNU Affero General Public License as | ||||||
| * published by the Free Software Foundation, either version 3 of the | ||||||
| * License, or (at your option) any later version. | ||||||
| * | ||||||
| * This program is distributed in the hope that it will be useful, | ||||||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
| * GNU Affero General Public License for more details. | ||||||
| * | ||||||
| * You should have received a copy of the GNU Affero General Public License | ||||||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||
| * | ||||||
| */ | ||||||
|
|
||||||
| namespace OCP; | ||||||
|
|
||||||
| /** | ||||||
| * Generic exception thrown when an AvatarProvider can not perform an action | ||||||
| * | ||||||
| * @since 21.0.0 | ||||||
| */ | ||||||
| class AvatarProviderException extends \RuntimeException { | ||||||
|
|
||||||
| public function __construct(string $message = "", int $code = 0, \Exception $previous = null) { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and for |
||||||
| parent::__construct($message, $code, $previous); | ||||||
| } | ||||||
| } | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could catch
OCP\Files\NotFoundExceptionas it is thrown by getFile(),InvalidArgumentExceptionas it is thrown byIAvatarManagerand whatever is thrown byIAvatarProvider::getAvatar(). I wonder whether other exceptions should be catched or just left to bubble up and generate an error 500 (maybe even the exception thrown byIAvatarProvider::getAvatar()if it ends being just a genericException).👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of
AvatarExceptionI named itAvatarProviderException, as that is more specific and gives room to add in the future anAvatarExceptionfor avatar specific errors if needed.In the end I removed the log, as now a generic exception is no longer caught, but an
AvatarProviderException, which would be thrown if the provider can not get an avatar for the given id. I think that belongs to the realm of expected errors that do not need to be logged (but if I am wrong it can be added back, of course ;-) ).