⬆️ Using the latest version of paperclip
This commit is contained in:
parent
ee4f929d6c
commit
a502f11ebc
File diff suppressed because it is too large
Load Diff
@ -1,2 +1,2 @@
|
|||||||
#n:public
|
#n:public
|
||||||
!<md> [7186, 0, null, null, -2147483648, -2147483648]
|
!<md> [7430, 0, null, null, -2147483648, -2147483648]
|
||||||
|
16
.idea/workspace.xml
generated
16
.idea/workspace.xml
generated
@ -4,10 +4,18 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":recycle: Use paperclip to store avatar and more">
|
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Bug fixes in update avatar">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/cmd/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/cmd/main.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/grpc/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/grpc/auth.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/models/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/models/accounts.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/accounts_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/accounts_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/server/avatar_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/avatar_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/server/avatar_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/avatar_api.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/ui/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/ui/accounts.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/server/ui/directory.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/server/ui/directory.go" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/views/users/directory/userinfo.gohtml" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/views/users/directory/userinfo.gohtml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/pkg/views/users/me.gohtml" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/views/users/me.gohtml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -140,7 +148,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":lipstick: Fix ui design" />
|
|
||||||
<MESSAGE value=":bug: Bug fixes of design" />
|
<MESSAGE value=":bug: Bug fixes of design" />
|
||||||
<MESSAGE value=":sparkles: Bug fixes" />
|
<MESSAGE value=":sparkles: Bug fixes" />
|
||||||
<MESSAGE value=":sparkles: Batch mark notify as read API" />
|
<MESSAGE value=":sparkles: Batch mark notify as read API" />
|
||||||
@ -165,7 +172,8 @@
|
|||||||
<MESSAGE value=":sparkles: Bug fixes of permission check" />
|
<MESSAGE value=":sparkles: Bug fixes of permission check" />
|
||||||
<MESSAGE value=":sparkles: Check permissions GRPC method" />
|
<MESSAGE value=":sparkles: Check permissions GRPC method" />
|
||||||
<MESSAGE value=":recycle: Use paperclip to store avatar and more" />
|
<MESSAGE value=":recycle: Use paperclip to store avatar and more" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":recycle: Use paperclip to store avatar and more" />
|
<MESSAGE value=":bug: Bug fixes in update avatar" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":bug: Bug fixes in update avatar" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -30,8 +30,8 @@ func (v *Server) Authenticate(_ context.Context, in *proto.AuthRequest) (*proto.
|
|||||||
Name: user.Name,
|
Name: user.Name,
|
||||||
Nick: user.Nick,
|
Nick: user.Nick,
|
||||||
Email: user.GetPrimaryEmail().Content,
|
Email: user.GetPrimaryEmail().Content,
|
||||||
Avatar: fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), user.Avatar),
|
Avatar: fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), user.Avatar),
|
||||||
Banner: fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), user.Banner),
|
Banner: fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), user.Banner),
|
||||||
Description: &user.Description,
|
Description: &user.Description,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -13,8 +13,8 @@ type Account struct {
|
|||||||
Name string `json:"name" gorm:"uniqueIndex"`
|
Name string `json:"name" gorm:"uniqueIndex"`
|
||||||
Nick string `json:"nick"`
|
Nick string `json:"nick"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Avatar string `json:"avatar"`
|
Avatar *uint `json:"avatar"`
|
||||||
Banner string `json:"banner"`
|
Banner *uint `json:"banner"`
|
||||||
ConfirmedAt *time.Time `json:"confirmed_at"`
|
ConfirmedAt *time.Time `json:"confirmed_at"`
|
||||||
PermNodes datatypes.JSONMap `json:"perm_nodes"`
|
PermNodes datatypes.JSONMap `json:"perm_nodes"`
|
||||||
|
|
||||||
|
@ -37,8 +37,8 @@ func getUserinfo(c *fiber.Ctx) error {
|
|||||||
resp["email"] = data.GetPrimaryEmail().Content
|
resp["email"] = data.GetPrimaryEmail().Content
|
||||||
resp["preferred_username"] = data.Nick
|
resp["preferred_username"] = data.Nick
|
||||||
|
|
||||||
if len(data.Avatar) > 0 {
|
if data.Avatar != nil {
|
||||||
resp["picture"] = fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), data.Avatar)
|
resp["picture"] = fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), data.Avatar)
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(resp)
|
return c.JSON(resp)
|
||||||
|
@ -16,7 +16,7 @@ func setAvatar(c *fiber.Ctx) error {
|
|||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
AttachmentID string `json:"attachment" validate:"required"`
|
AttachmentID uint `json:"attachment" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.BindAndValidate(c, &data); err != nil {
|
if err := utils.BindAndValidate(c, &data); err != nil {
|
||||||
@ -24,13 +24,13 @@ func setAvatar(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
||||||
Uuid: &data.AttachmentID,
|
Id: lo.ToPtr(uint64(data.AttachmentID)),
|
||||||
Usage: lo.ToPtr("p.avatar"),
|
Usage: lo.ToPtr("p.avatar"),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("avatar was not found in repository: %v", err))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("avatar was not found in repository: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Avatar = data.AttachmentID
|
user.Avatar = &data.AttachmentID
|
||||||
|
|
||||||
if err := database.C.Save(&user).Error; err != nil {
|
if err := database.C.Save(&user).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
@ -43,7 +43,7 @@ func setBanner(c *fiber.Ctx) error {
|
|||||||
user := c.Locals("principal").(models.Account)
|
user := c.Locals("principal").(models.Account)
|
||||||
|
|
||||||
var data struct {
|
var data struct {
|
||||||
AttachmentID string `json:"attachment" validate:"required"`
|
AttachmentID uint `json:"attachment" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := utils.BindAndValidate(c, &data); err != nil {
|
if err := utils.BindAndValidate(c, &data); err != nil {
|
||||||
@ -51,13 +51,13 @@ func setBanner(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
if _, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
||||||
Uuid: &data.AttachmentID,
|
Id: lo.ToPtr(uint64(data.AttachmentID)),
|
||||||
Usage: lo.ToPtr("p.banner"),
|
Usage: lo.ToPtr("p.banner"),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("banner was not found in repository: %v", err))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("banner was not found in repository: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
user.Banner = data.AttachmentID
|
user.Banner = &data.AttachmentID
|
||||||
|
|
||||||
if err := database.C.Save(&user).Error; err != nil {
|
if err := database.C.Save(&user).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
|
@ -45,7 +45,7 @@ func selfUserinfoPage(c *fiber.Ctx) error {
|
|||||||
"birthday_at": birthday,
|
"birthday_at": birthday,
|
||||||
"personal_page": template.HTML(markdown.Render(doc, renderer)),
|
"personal_page": template.HTML(markdown.Render(doc, renderer)),
|
||||||
"userinfo": data,
|
"userinfo": data,
|
||||||
"avatar": fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), data.Avatar),
|
"avatar": fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), data.Avatar),
|
||||||
"banner": fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), data.Banner),
|
"banner": fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), data.Banner),
|
||||||
}, "views/layouts/user-center")
|
}, "views/layouts/user-center")
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func otherUserinfoPage(c *fiber.Ctx) error {
|
|||||||
"birthday_at": birthday,
|
"birthday_at": birthday,
|
||||||
"personal_page": template.HTML(markdown.Render(doc, renderer)),
|
"personal_page": template.HTML(markdown.Render(doc, renderer)),
|
||||||
"userinfo": data,
|
"userinfo": data,
|
||||||
"avatar": fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), data.Avatar),
|
"avatar": fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), data.Avatar),
|
||||||
"banner": fmt.Sprintf("%s/api/attachments/%s", viper.GetString("paperclip.endpoint"), data.Banner),
|
"banner": fmt.Sprintf("%s/api/attachments/%d", viper.GetString("paperclip.endpoint"), data.Banner),
|
||||||
}, "views/layouts/user-center")
|
}, "views/layouts/user-center")
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@1.4.6/dist/utilities.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@1.4.6/dist/utilities.min.css">
|
||||||
|
|
||||||
<div class="banner-container">
|
<div class="banner-container">
|
||||||
{{if gt (len .userinfo.Banner) 0}}
|
{{if ne .userinfo.Banner nil}}
|
||||||
<img src="{{.banner}}" alt="Banner" class="banner">
|
<img src="{{.banner}}" alt="Banner" class="banner">
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="left-part name-card">
|
<div class="left-part name-card">
|
||||||
{{if gt (len .userinfo.Avatar) 0}}
|
{{if ne .userinfo.Avatar nil}}
|
||||||
<img src="{{.avatar}}" alt="Avatar" class="avatar">
|
<img src="{{.avatar}}" alt="Avatar" class="avatar">
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="avatar empty">
|
<div class="avatar empty">
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@1.4.6/dist/utilities.min.css">
|
<link rel="stylesheet" href="https://unpkg.com/tailwindcss@1.4.6/dist/utilities.min.css">
|
||||||
|
|
||||||
<div class="banner-container">
|
<div class="banner-container">
|
||||||
{{if gt (len .userinfo.Banner) 0}}
|
{{if ne .userinfo.Banner nil}}
|
||||||
<img src="{{.banner}}" alt="Banner" class="banner">
|
<img src="{{.banner}}" alt="Banner" class="banner">
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="left-part name-card">
|
<div class="left-part name-card">
|
||||||
{{if gt (len .userinfo.Avatar) 0}}
|
{{if ne .userinfo.Avatar nil}}
|
||||||
<img src="{{.avatar}}" alt="Avatar" class="avatar">
|
<img src="{{.avatar}}" alt="Avatar" class="avatar">
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="avatar empty">
|
<div class="avatar empty">
|
||||||
|
Loading…
Reference in New Issue
Block a user