-
Notifications
You must be signed in to change notification settings - Fork 416
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
๐ผ๏ธ Conversation avatars API #8333
Conversation
Added some todos in the PR description |
If this in renamed to a more general "AvatarController", would that supersede the "TempAvatarController" ( |
No, as that is still an API that should not be in talk but in server |
ac6d967
to
323dd3c
Compare
@@ -88,6 +88,7 @@ | |||
| `statusMessage` | string | v4 | | Optional: Only available for one-to-one conversations and when `includeStatus=true` is set | | |||
| `participants` | array | v1 | v2 | **Removed** | | |||
| `guestList` | string | v1 | v2 | **Removed** | | |||
| `avatarUrl` | string | v4 | | Avatar URL of the conversation including a version flag `v=โฆ` for easier expiration of the avatar in case a moderator updates it, since the avatar endpoint should be cached for 24 hours. | |
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.
I think this parameter is a bit problematic. It will make the avatar look updated on the conversation list, but e.g. search results, notifications, etc still show the old one. So basically we would need to tell clients to track this value and when it is different, they should invalidate their avatar image cache.
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.
Any idea what the best way would be? I'd like to have it similar to user avatars. They work without any additional information, you just need the userid (conversation token) and can make your URL. It's cached so can take some time until others see it. Should be fine, unless you did the change yourself.
Would you think it's okay to have it cached/old on the mobile apps when you changed it in the web? Or what would be a good way to handle this?
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.
The user avatar also have a query string to expire with an incremental value called v
too.
The endpoint /avatar/{userId}/{size}
haven't this value because is only to expire and is send by query string.
When the backend delete the avatar, the version is incremented:
https://github.com/nextcloud/server/blob/master/lib/private/Avatar/UserAvatar.php#L194-L195
The same code is trigged when we set a new avatar:
https://github.com/nextcloud/server/blob/master/lib/private/Avatar/UserAvatar.php#L90-L96
The frontend every time get the version directly from userconfig
:
https://github.com/nextcloud/server/blob/master/apps/settings/src/components/PersonalInfo/AvatarSection.vue#L149
The backend also retrieve the avatar version every time when is the current user that request:
https://github.com/nextcloud/server/blob/master/lib/private/TemplateLayout.php#L157
and when the current user need the avatar of other user:
https://github.com/nextcloud/server/blob/master/lib/private/Template/JSConfigHelper.php#L287-L290
Is a bit complex to identify this in the server repository because the code that do this is fragmented in a lot of places, but the server store and use the version number of avatar.
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.
The frontend every time get the version directly from userconfig:
This is only for your very own avatar. It is not done for the avatar of others, see:
https://github.com/nextcloud/nextcloud-vue/blob/master/src/components/NcAvatar/NcAvatar.vue#L627-L647
But that is exactly the problem here. It's basically always the avatar of others ๐ฌ
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.
I think that this wont be a problem to Talk.
I already implemented to send the version of avatar in Room object, then, in all places that we need to display the current room avatar, will be possible.
In the places that we haven't the Room object, we will send the URL of avatar and we already have a contract to do this, have places in server that need a property called icon, other use iconUrl and we can do the same in Talk.
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.
That is exactly why I started the discussion here. We will NOT be able to add the avatar URL on all things. But anyway.
We can move this to a follow up issue so we can merge this PR
lib/Service/AvatarService.php
Outdated
$file->delete(); | ||
} | ||
|
||
$avatarName = $this->random->generate(10, ISecureRandom::CHAR_HUMAN_READABLE); |
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.
Should add the file extension?
$avatarName = $this->random->generate(10, ISecureRandom::CHAR_HUMAN_READABLE); | |
$avatarName = $this->random->generate(6, ISecureRandom::CHAR_HUMAN_READABLE) . ($mimeType === 'image/jpeg' ? '.jpg' : '.png'); |
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.
Is possible, but we will need change the current implementation a bit to consider the extension.
For now, the name that we stored on database is only to have a token to expire the previous image. Now, if we send a request without the version, will get the room image too.
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.
I meant for readability on the filesystem (also user avatars have it). But sure if it works, let's keep it in the current format.
It could still work without it.
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.
Yes, will be more readable to save the filename with the extension.
Maybe we can change this approach in the future creating a table to store all room avatar, maybe room_avatar
to make possible to have a gallery of room avatar. With room avatar gallery, we can maintain only the name with the 10 chars (without the extension) in room table following the current approach to store the current room avatar. In the table room_avatar
we can store more details, by example, the full name of file in filesystem.
Signed-off-by: Vitor Mattos <vitor@php.rio>
If receive `@all` mention, will be necessary to get the avatar from room object Signed-off-by: Vitor Mattos <vitor@php.rio>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
Signed-off-by: Joas Schilling <coding@schilljs.com>
40110b7
to
592f52a
Compare
Rebased to resolve conflicts from breakout rooms part1 merge |
Otherwise the avatar can not be displayed but instead the browser downloads it Signed-off-by: Joas Schilling <coding@schilljs.com>
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.
Added a commit so the file can be viewed in the browser and does not trigger a download.
Other than that only the system messages are missing, but we can do that as a follow up.
Follow up in #8443 |
nextcloud/spreed#8333 introduced an optional `icon-url` for the call objects in rich messages. nextcloud/spreed#8389 Signed-off-by: Vitor Mattos <vitor@php.rio>
Fix #927
๐ง TODO
/api/{apiVersion}/room/{token}/image
- Similar to https://github.com/nextcloud/spreed/blob/master/lib/Controller/TempAvatarController.phpOCP\Files\IAppData
with conversation token + file type as name/dark
URL for dark avatars๐ Checklist
docs/
has been updated or is not required