From d0800f7661f13fabe7bb6f4aa0ea50764f106405 Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Mon, 28 Feb 2022 08:34:43 +0100 Subject: [PATCH] Implement avatar miniatures (#4639) * client: remove unused file * refactor(client/my-actor-avatar): size from input Read size from component input instead of scss, to make it possible to use smaller avatar images when implemented. * implement avatar miniatures close #4560 * fix(test): max file size * fix(search-index): normalize res acc to avatarMini * refactor avatars to an array * client/search: resize channel avatar to 120 * refactor(client/videos): remove unused function * client(actor-avatar): set default size * fix tests and avatars full result When findOne is used only an array containting one avatar is returned. * update migration version and version notations * server/search: harmonize normalizing * Cleanup avatar miniature PR Co-authored-by: Chocobozzz --- .../account-video-channels.component.html | 7 +- .../account-video-channels.component.scss | 1 - .../src/app/+accounts/accounts.component.html | 2 +- .../instance-account-blocklist.component.html | 56 ---- .../video-comment-list.component.html | 2 +- .../video-channel-update.component.ts | 4 +- .../my-account-settings.component.ts | 2 +- .../my-video-channels.component.html | 2 +- .../my-video-channels.component.scss | 1 - .../my-follows/my-followers.component.html | 2 +- .../my-follows/my-followers.component.scss | 2 +- .../my-subscriptions.component.html | 2 +- .../my-accept-ownership.component.ts | 4 +- .../my-ownership/my-ownership.component.html | 2 +- .../my-video-playlist-create.component.ts | 4 +- .../my-video-playlist-update.component.ts | 4 +- client/src/app/+search/search.component.html | 2 +- client/src/app/+search/search.component.scss | 4 - .../video-channels.component.html | 4 +- .../video-channels.component.scss | 4 - .../video-add-components/video-send.ts | 4 +- .../+video-edit/video-update.resolver.ts | 4 +- .../comment/video-comment.component.html | 2 +- .../comment/video-comment.component.scss | 9 - .../video-avatar-channel.component.html | 6 +- .../video-avatar-channel.component.scss | 9 - .../video-avatar-channel.component.ts | 4 - .../overview/video-overview.component.html | 2 +- .../overview/video-overview.component.scss | 1 - client/src/app/core/users/user.model.ts | 4 +- client/src/app/core/users/user.service.ts | 2 +- client/src/app/helpers/utils/channel.ts | 7 +- .../account-setup-warning-modal.component.ts | 2 +- .../abuse-list-table.component.html | 2 +- .../actor-avatar-edit.component.ts | 2 +- .../actor-avatar.component.scss | 29 +- .../actor-avatar.component.ts | 15 +- .../channel-miniature-markup.component.html | 2 +- .../channel-miniature-markup.component.scss | 2 - .../select/select-channel.component.ts | 2 +- .../shared-main/account/account.model.ts | 16 +- .../shared/shared-main/account/actor.model.ts | 20 +- .../misc/channels-setup-message.component.ts | 2 +- .../users/user-notification.model.ts | 8 +- .../video-channel/video-channel.model.ts | 42 +-- .../video-channel/video-channel.service.ts | 2 +- .../shared/shared-main/video/video.model.ts | 12 +- .../account-blocklist.component.html | 2 +- .../video-miniature.component.html | 2 + .../images/default-avatar-account-48x48.png | Bin 0 -> 878 bytes .../default-avatar-video-channel-48x48.png | Bin 0 -> 728 bytes .../sass/include/_account-channel-page.scss | 4 - client/src/sass/include/_actor.scss | 4 +- client/src/sass/include/_mixins.scss | 2 +- scripts/migrations/peertube-4.2.ts | 106 +++++++ server/controllers/activitypub/client.ts | 15 +- server/controllers/api/accounts.ts | 2 +- server/controllers/api/users/me.ts | 19 +- .../controllers/api/users/my-notifications.ts | 2 +- server/controllers/api/video-channel.ts | 20 +- server/controllers/client.ts | 4 +- server/controllers/lazy-static.ts | 10 +- server/helpers/activitypub.ts | 3 + server/initializers/constants.ts | 30 +- .../migrations/0685-multiple-actor-images.ts | 62 ++++ server/lib/activitypub/actors/image.ts | 89 +++--- .../lib/activitypub/actors/shared/creator.ts | 16 +- .../shared/object-to-model-attributes.ts | 56 ++-- server/lib/activitypub/actors/updater.ts | 12 +- server/lib/actor-image.ts | 14 + server/lib/client-html.ts | 10 +- server/lib/local-actor.ts | 89 +++--- .../shared/comment/comment-mention.ts | 2 +- .../comment/new-comment-for-video-owner.ts | 2 +- server/models/abuse/abuse-message.ts | 32 +- server/models/account/account-blocklist.ts | 83 +++--- server/models/account/account-video-rate.ts | 56 ++-- server/models/account/account.ts | 59 ++-- server/models/actor/actor-follow.ts | 263 +++++++++-------- server/models/actor/actor-image.ts | 67 ++++- server/models/actor/actor.ts | 129 ++++---- server/models/server/plugin.ts | 9 +- server/models/server/server-blocklist.ts | 13 +- server/models/shared/index.ts | 1 + server/models/shared/model-builder.ts | 101 +++++++ .../user-notitication-list-query-builder.ts | 269 +++++++++++++++++ server/models/user/user-notification.ts | 275 ++++-------------- server/models/user/user.ts | 13 +- server/models/utils.ts | 2 +- server/models/video/sql/video/index.ts | 3 + .../{ => video}/shared/abstract-run-query.ts | 0 .../shared/abstract-video-query-builder.ts | 15 +- .../shared/video-file-query-builder.ts | 0 .../{ => video}/shared/video-model-builder.ts | 51 +++- .../shared/video-table-attributes.ts | 4 +- .../video-model-get-query-builder.ts | 0 .../videos-id-list-query-builder.ts | 0 .../videos-model-list-query-builder.ts | 0 server/models/video/video-channel.ts | 209 +++++++------ server/models/video/video-comment.ts | 102 ++++--- server/models/video/video-import.ts | 11 +- server/models/video/video-playlist-element.ts | 36 ++- server/models/video/video-playlist.ts | 98 +++++-- server/models/video/video-share.ts | 5 +- server/models/video/video.ts | 18 +- .../tests/api/check-params/video-channels.ts | 2 +- server/tests/api/moderation/abuses.ts | 7 +- server/tests/api/moderation/blocklist.ts | 4 +- .../tests/api/moderation/video-blacklist.ts | 2 + .../api/notifications/notifications-api.ts | 10 + .../search-activitypub-video-channels.ts | 4 + .../search-activitypub-video-playlists.ts | 2 + .../api/search/search-activitypub-videos.ts | 4 + server/tests/api/search/search-channels.ts | 8 +- server/tests/api/search/search-index.ts | 14 +- server/tests/api/search/search-playlists.ts | 6 +- server/tests/api/search/search-videos.ts | 8 +- server/tests/api/server/homepage.ts | 6 +- server/tests/api/users/user-subscriptions.ts | 4 + .../tests/api/users/users-multiple-servers.ts | 18 +- server/tests/api/users/users.ts | 8 +- server/tests/api/videos/multiple-servers.ts | 7 +- server/tests/api/videos/single-server.ts | 11 +- server/tests/api/videos/video-channels.ts | 32 +- server/tests/api/videos/video-comments.ts | 17 +- server/tests/api/videos/video-playlists.ts | 2 + .../tests/api/videos/videos-common-filters.ts | 4 +- server/tests/cli/prune-storage.ts | 29 +- server/tests/feeds/feeds.ts | 4 +- ...resized.gif => avatar-resized-120x120.gif} | Bin ...resized.png => avatar-resized-120x120.png} | Bin .../tests/fixtures/avatar-resized-48x48.gif | Bin 0 -> 20462 bytes .../tests/fixtures/avatar-resized-48x48.png | Bin 0 -> 727 bytes ...esized.png => avatar2-resized-120x120.png} | Bin .../tests/fixtures/avatar2-resized-48x48.png | Bin 0 -> 760 bytes server/tests/shared/notifications.ts | 11 +- server/types/models/actor/actor-image.ts | 2 +- server/types/models/actor/actor.ts | 37 +-- server/types/models/user/user-notification.ts | 9 +- .../models/activitypub/activitypub-actor.ts | 7 +- shared/models/actors/account.model.ts | 7 +- shared/models/actors/actor-image.model.ts | 1 + shared/models/actors/actor.model.ts | 6 +- .../models/users/user-notification.model.ts | 11 +- .../videos/channel/video-channel.model.ts | 13 +- shared/server-commands/users/accounts.ts | 15 + shared/server-commands/users/index.ts | 1 + shared/server-commands/videos/channels.ts | 13 +- support/doc/api/openapi.yaml | 131 +++++---- support/nginx/peertube | 2 +- 150 files changed, 2027 insertions(+), 1276 deletions(-) delete mode 100644 client/src/app/+admin/moderation/instance-blocklist/instance-account-blocklist.component.html create mode 100644 client/src/assets/images/default-avatar-account-48x48.png create mode 100644 client/src/assets/images/default-avatar-video-channel-48x48.png create mode 100644 scripts/migrations/peertube-4.2.ts create mode 100644 server/initializers/migrations/0685-multiple-actor-images.ts create mode 100644 server/lib/actor-image.ts create mode 100644 server/models/shared/model-builder.ts create mode 100644 server/models/user/sql/user-notitication-list-query-builder.ts create mode 100644 server/models/video/sql/video/index.ts rename server/models/video/sql/{ => video}/shared/abstract-run-query.ts (100%) rename server/models/video/sql/{ => video}/shared/abstract-video-query-builder.ts (95%) rename server/models/video/sql/{ => video}/shared/video-file-query-builder.ts (100%) rename server/models/video/sql/{ => video}/shared/video-model-builder.ts (89%) rename server/models/video/sql/{ => video}/shared/video-table-attributes.ts (99%) rename server/models/video/sql/{ => video}/video-model-get-query-builder.ts (100%) rename server/models/video/sql/{ => video}/videos-id-list-query-builder.ts (100%) rename server/models/video/sql/{ => video}/videos-model-list-query-builder.ts (100%) rename server/tests/fixtures/{avatar-resized.gif => avatar-resized-120x120.gif} (100%) rename server/tests/fixtures/{avatar-resized.png => avatar-resized-120x120.png} (100%) create mode 100644 server/tests/fixtures/avatar-resized-48x48.gif create mode 100644 server/tests/fixtures/avatar-resized-48x48.png rename server/tests/fixtures/{avatar2-resized.png => avatar2-resized-120x120.png} (100%) create mode 100644 server/tests/fixtures/avatar2-resized-48x48.png create mode 100644 shared/server-commands/users/accounts.ts diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html index 105bc12c3..379c0443e 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.html +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.html @@ -9,8 +9,11 @@

diff --git a/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss index be9e94f69..30b8098be 100644 --- a/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss +++ b/client/src/app/+accounts/account-video-channels/account-video-channels.component.scss @@ -29,7 +29,6 @@ grid-template-rows: auto 1fr; my-actor-avatar { - @include actor-avatar-size(75px); @include margin-right(15px); grid-column: 1; diff --git a/client/src/app/+accounts/accounts.component.html b/client/src/app/+accounts/accounts.component.html index 8362e6b7e..1544ad034 100644 --- a/client/src/app/+accounts/accounts.component.html +++ b/client/src/app/+accounts/accounts.component.html @@ -2,7 +2,7 @@