From 2ed03ec4455f5b134eaa1f3fa77b96c0b7fc96e1 Mon Sep 17 00:00:00 2001 From: GioPan04 Date: Fri, 17 Nov 2023 13:03:14 +0100 Subject: [PATCH 1/2] feat: show avatar url in wakatime user model --- models/compat/wakatime/v1/user.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/models/compat/wakatime/v1/user.go b/models/compat/wakatime/v1/user.go index a6314782..06801efc 100644 --- a/models/compat/wakatime/v1/user.go +++ b/models/compat/wakatime/v1/user.go @@ -1,8 +1,11 @@ package v1 import ( - "github.com/muety/wakapi/models" + "fmt" "time" + + "github.com/muety/wakapi/config" + "github.com/muety/wakapi/models" ) const DefaultWakaUserDisplayName = "Anonymous User" @@ -28,6 +31,7 @@ type User struct { Website string `json:"website"` CreatedAt models.CustomTime `json:"created_at"` ModifiedAt models.CustomTime `json:"modified_at"` + Photo string `json:"photo"` } func NewFromUser(user *models.User) *User { @@ -36,6 +40,8 @@ func NewFromUser(user *models.User) *User { tz = user.Location } + config := config.Get() + return &User{ ID: user.ID, DisplayName: DefaultWakaUserDisplayName, @@ -44,6 +50,7 @@ func NewFromUser(user *models.User) *User { Username: user.ID, CreatedAt: user.CreatedAt, ModifiedAt: user.CreatedAt, + Photo: fmt.Sprintf("%s%s/%s", config.Server.GetPublicUrl(), config.Server.BasePath, user.AvatarURL(config.App.AvatarURLTemplate)), } } From 8a3dcd2753cb944529ec430cba607f1e2db4bb47 Mon Sep 17 00:00:00 2001 From: GioPan04 Date: Fri, 17 Nov 2023 13:06:58 +0100 Subject: [PATCH 2/2] feat: show user id as `display_name` in user --- models/compat/wakatime/v1/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/compat/wakatime/v1/user.go b/models/compat/wakatime/v1/user.go index 06801efc..10f0c053 100644 --- a/models/compat/wakatime/v1/user.go +++ b/models/compat/wakatime/v1/user.go @@ -44,7 +44,7 @@ func NewFromUser(user *models.User) *User { return &User{ ID: user.ID, - DisplayName: DefaultWakaUserDisplayName, + DisplayName: user.ID, Email: user.Email, TimeZone: tz, Username: user.ID,