diff options
author | 2024-07-20 15:02:22 +0200 | |
---|---|---|
committer | 2024-07-20 14:02:22 +0100 | |
commit | ad700c5029688ffabae568c23bedd7bb333f7f33 (patch) | |
tree | 189e5657eb53722df004cd94727b0518bd9b4ef2 /internal/typeutils | |
parent | [feature] use webp for thumbnails (#3116) (diff) | |
download | gotosocial-ad700c5029688ffabae568c23bedd7bb333f7f33.tar.xz |
[chore/frontend] Use smaller webp images for logo and default avatars (#3119)
Diffstat (limited to 'internal/typeutils')
-rw-r--r-- | internal/typeutils/defaulticons.go | 4 | ||||
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 4 | ||||
-rw-r--r-- | internal/typeutils/internaltofrontend_test.go | 100 |
3 files changed, 54 insertions, 54 deletions
diff --git a/internal/typeutils/defaulticons.go b/internal/typeutils/defaulticons.go index e3a090109..88785879c 100644 --- a/internal/typeutils/defaulticons.go +++ b/internal/typeutils/defaulticons.go @@ -28,7 +28,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/log" ) -const defaultHeaderPath = "/assets/default_header.png" +const defaultHeaderPath = "/assets/default_header.webp" // populateDefaultAvatars returns a slice of standard avatars found // in the path [web-assets-base-dir]/default_avatars. The slice @@ -73,7 +73,7 @@ func populateDefaultAvatars() (defaultAvatars []string) { // take only files with simple extensions // that we know will work OK as avatars switch strings.ToLower(extension) { - case "jpeg", "jpg", "gif", "png": + case "jpeg", "jpg", "gif", "png", "webp": avatarURL := config.GetProtocol() + "://" + config.GetHost() + "/assets/default_avatars/" + fileName defaultAvatars = append(defaultAvatars, avatarURL) default: diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index f11c4af21..f64f4acff 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -1466,7 +1466,7 @@ func (c *Converter) InstanceToAPIV1Instance(ctx context.Context, i *gtsmodel.Ins instance.ThumbnailType = iAccount.AvatarMediaAttachment.File.ContentType instance.ThumbnailDescription = iAccount.AvatarMediaAttachment.Description } else { - instance.Thumbnail = config.GetProtocol() + "://" + i.Domain + "/assets/logo.png" // default thumb + instance.Thumbnail = config.GetProtocol() + "://" + i.Domain + "/assets/logo.webp" // default thumb } // contact account @@ -1536,7 +1536,7 @@ func (c *Converter) InstanceToAPIV2Instance(ctx context.Context, i *gtsmodel.Ins thumbnail.Description = iAccount.AvatarMediaAttachment.Description thumbnail.Blurhash = iAccount.AvatarMediaAttachment.Blurhash } else { - thumbnail.URL = config.GetProtocol() + "://" + i.Domain + "/assets/logo.png" // default thumb + thumbnail.URL = config.GetProtocol() + "://" + i.Domain + "/assets/logo.webp" // default thumb } instance.Thumbnail = thumbnail diff --git a/internal/typeutils/internaltofrontend_test.go b/internal/typeutils/internaltofrontend_test.go index f335e6fce..aeb7ea0b9 100644 --- a/internal/typeutils/internaltofrontend_test.go +++ b/internal/typeutils/internaltofrontend_test.go @@ -149,8 +149,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendAliasedAndMoved() "url": "http://localhost:8080/@1happyturtle", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 8, @@ -350,8 +350,8 @@ func (suite *InternalToFrontendTestSuite) TestAccountToFrontendPublicPunycode() "url": "https://xn--xample-ova.org/users/@%C3%BCser", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 0, @@ -388,8 +388,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendPubl "url": "http://localhost:8080/@localhost:8080", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 0, @@ -426,8 +426,8 @@ func (suite *InternalToFrontendTestSuite) TestLocalInstanceAccountToFrontendBloc "url": "http://localhost:8080/@localhost:8080", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 0, @@ -484,8 +484,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontend() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -633,8 +633,8 @@ func (suite *InternalToFrontendTestSuite) TestWarnFilteredStatusToFrontend() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -866,8 +866,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownAttachments "url": "http://example.org/@Some_User", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 1, @@ -994,8 +994,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToWebStatus() { "url": "http://example.org/@Some_User", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 1, @@ -1155,8 +1155,8 @@ func (suite *InternalToFrontendTestSuite) TestStatusToFrontendUnknownLanguage() "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -1471,7 +1471,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() { "status_count": 20, "user_count": 4 }, - "thumbnail": "http://localhost:8080/assets/logo.png", + "thumbnail": "http://localhost:8080/assets/logo.webp", "contact_account": { "id": "01F8MH17FWEB39HZJ76B6VXSKF", "username": "admin", @@ -1485,8 +1485,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV1ToFrontend() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -1535,7 +1535,7 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() { } }, "thumbnail": { - "url": "http://localhost:8080/assets/logo.png" + "url": "http://localhost:8080/assets/logo.webp" }, "languages": [ "nl", @@ -1619,8 +1619,8 @@ func (suite *InternalToFrontendTestSuite) TestInstanceV2ToFrontend() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -1735,8 +1735,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend1() { "url": "http://fossbros-anonymous.io/@foss_satan", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 3, @@ -1778,8 +1778,8 @@ func (suite *InternalToFrontendTestSuite) TestReportToFrontend2() { "url": "http://localhost:8080/@1happyturtle", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 8, @@ -1853,8 +1853,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "url": "http://fossbros-anonymous.io/@foss_satan", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 3, @@ -1894,8 +1894,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "url": "http://localhost:8080/@1happyturtle", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 8, @@ -1951,8 +1951,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -1997,8 +1997,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend1() { "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -2066,8 +2066,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "url": "http://localhost:8080/@1happyturtle", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 8, @@ -2123,8 +2123,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "url": "http://fossbros-anonymous.io/@foss_satan", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 3, @@ -2170,8 +2170,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontend2() { "url": "http://fossbros-anonymous.io/@foss_satan", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 3, @@ -2321,8 +2321,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "url": "http://fossbros-anonymous.io/@foss_satan", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 3, @@ -2362,8 +2362,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "url": "http://localhost:8080/@1happyturtle", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 0, "following_count": 0, "statuses_count": 0, @@ -2408,8 +2408,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, @@ -2454,8 +2454,8 @@ func (suite *InternalToFrontendTestSuite) TestAdminReportToFrontendSuspendedLoca "url": "http://localhost:8080/@admin", "avatar": "", "avatar_static": "", - "header": "http://localhost:8080/assets/default_header.png", - "header_static": "http://localhost:8080/assets/default_header.png", + "header": "http://localhost:8080/assets/default_header.webp", + "header_static": "http://localhost:8080/assets/default_header.webp", "followers_count": 1, "following_count": 1, "statuses_count": 4, |