Skip to content

Commit

Permalink
feat(video): add user id info to video link
Browse files Browse the repository at this point in the history
  • Loading branch information
Maple-pro committed Aug 21, 2023
1 parent 4d42635 commit 38d7953
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/services/feed/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func queryDetailed(
// fill play url
go func(i int, v *models.Video) {
defer wg.Done()
playUrl, localErr := file.GetLink(ctx, v.FileName)
playUrl, localErr := file.GetLink(ctx, v.FileName, v.UserId)
if localErr != nil {
logger.WithFields(logrus.Fields{
"video_id": v.ID,
Expand All @@ -218,7 +218,7 @@ func queryDetailed(
// fill cover url
go func(i int, v *models.Video) {
defer wg.Done()
coverUrl, localErr := file.GetLink(ctx, v.CoverName)
coverUrl, localErr := file.GetLink(ctx, v.CoverName, v.UserId)
if localErr != nil {
logger.WithFields(logrus.Fields{
"video_id": v.ID,
Expand Down
7 changes: 5 additions & 2 deletions src/storage/file/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package file
import (
"GuGoTik/src/constant/config"
"context"
"fmt"
"io"
)

Expand Down Expand Up @@ -31,6 +32,8 @@ func GetLocalPath(ctx context.Context, fileName string) string {
return client.GetLocalPath(ctx, fileName)
}

func GetLink(ctx context.Context, fileName string) (link string, err error) {
return client.GetLink(ctx, fileName)
func GetLink(ctx context.Context, fileName string, userId uint32) (link string, err error) {
originLink, err := client.GetLink(ctx, fileName)
link = fmt.Sprintf("%s?user_id=%d", originLink, userId)
return
}

0 comments on commit 38d7953

Please sign in to comment.