mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-02 12:26:36 +08:00
优化播放
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"github.com/truewhile/MeBox/internal/middleware"
|
||||
@@ -173,10 +175,20 @@ func externalPlaybackToken(c *gin.Context, svc *service.Container, mediaID strin
|
||||
uid, _ := c.Get(middleware.CtxUserID)
|
||||
u, err := svc.Repo.User.FindByID(c.Request.Context(), toString(uid))
|
||||
if err != nil || u == nil {
|
||||
if svc.Log != nil {
|
||||
svc.Log.Warn("external playback token: user lookup failed",
|
||||
zap.String("media_id", mediaID), zap.Error(err))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
token, err := svc.Auth.IssueExternalPlaybackToken(u, mediaID, durationSec)
|
||||
if err != nil {
|
||||
// 静默返回空串会让 stream_url 变成 ?token=(空)、外部播放器只看到
|
||||
// 401 无从排查,至少在服务端日志里留下原因。
|
||||
if svc.Log != nil {
|
||||
svc.Log.Warn("issue external playback token failed",
|
||||
zap.String("media_id", mediaID), zap.Error(err))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
return token
|
||||
|
||||
Reference in New Issue
Block a user