Skip to content

Commit f6514c2

Browse files
committed
Merge branch 'release/v0.1.2'
2 parents dd929e9 + cd31ea9 commit f6514c2

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
### v0.1.2
6+
7+
> 23 October 2022
8+
9+
- Fixed error UserId parsing when upload files
10+
511
### v0.1.1
612

713
> 23 October 2022

routes/files/bundle_filegroup.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/aws/aws-sdk-go-v2/aws"
1414
"github.com/aws/aws-sdk-go-v2/service/s3"
1515
"github.com/gin-gonic/gin"
16-
"github.com/google/uuid"
1716
"github.com/slaveofcode/hansip/age_encryption"
1817
"github.com/slaveofcode/hansip/repository"
1918
"github.com/slaveofcode/hansip/repository/models"
@@ -26,11 +25,11 @@ import (
2625
)
2726

2827
type BundleFileGroupParam struct {
29-
FileGroupId uuid.UUID `json:"fileGroupId" binding:"required"`
30-
ExpiredAt string `json:"expiredAt" binding:"required,datetime=2006-01-02T15:04:05Z07:00"` // format UTC: 2021-07-18T10:00:00.000Z
31-
Passcode string `json:"passcode" binding:"required,gte=6,lte=100"`
32-
DownloadPassword string `json:"downloadPassword" binding:"omitempty,gte=6,lte=100"`
33-
UserIds []uint64 `json:"userIds" binding:"omitempty"`
28+
FileGroupId uint64 `json:"fileGroupId" binding:"required"`
29+
ExpiredAt string `json:"expiredAt" binding:"required,datetime=2006-01-02T15:04:05Z07:00"` // format UTC: 2021-07-18T10:00:00.000Z
30+
Passcode string `json:"passcode" binding:"required,gte=6,lte=100"`
31+
DownloadPassword string `json:"downloadPassword" binding:"omitempty,gte=6,lte=100"`
32+
UserIds []uint64 `json:"userIds" binding:"omitempty"`
3433
}
3534

3635
func BundleFileGroup(repo repository.Repository, s3Client *s3.Client) func(c *gin.Context) {
@@ -46,6 +45,7 @@ func BundleFileGroup(repo repository.Repository, s3Client *s3.Client) func(c *gi
4645

4746
var bodyParams BundleFileGroupParam
4847
if err := c.ShouldBindJSON(&bodyParams); err != nil {
48+
log.Println(err)
4949
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{
5050
"success": false,
5151
"message": "Invalid body request",
@@ -67,7 +67,7 @@ func BundleFileGroup(repo repository.Repository, s3Client *s3.Client) func(c *gi
6767
var fileGroup models.FileGroup
6868
res := db.Where(
6969
`id = ? AND "userId" = ? AND "bundledAt" IS NULL`,
70-
bodyParams.FileGroupId.String(),
70+
bodyParams.FileGroupId,
7171
userId,
7272
).First(&fileGroup)
7373

routes/files/create_filegroup.go

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package files
22

33
import (
4+
"log"
45
"net/http"
56

67
"github.com/gin-gonic/gin"
@@ -17,6 +18,7 @@ func CreateFileGroup(repo repository.Repository) func(c *gin.Context) {
1718
return func(c *gin.Context) {
1819
userId, err := middleware.GetUserId(c)
1920
if err != nil {
21+
log.Println("error:", err.Error())
2022
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{
2123
"success": false,
2224
"message": "Unauthorized request",

routes/middleware/auth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func UserData(repo repository.Repository) func(ctx *gin.Context) {
6363
return
6464
}
6565

66-
ctx.Set(CTX_USER_ID, acct.UserId)
66+
ctx.Set(CTX_USER_ID, strconv.FormatUint(acct.UserId, 10))
6767
}
6868
}
6969

0 commit comments

Comments
 (0)