mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-04 04:26:38 +08:00
fix: Emby 远程挂载账号编辑保留凭据 + 代理开关回显
- UpdateStrmAccount 对 emby_remote 做合并式更新:只覆盖传入键,未提及的 地址/用户名/密码/token 密文保留,避免编辑代理开关时清空凭据 - 账号列表/编辑表单回显 proxy_play(服务端解密后下发) - 前端 StrmAccount 类型与编辑对话框支持 proxy_play 回显
This commit is contained in:
@@ -272,6 +272,15 @@ func (r *EmbyRemoteService) TestConnection(ctx context.Context, acct *model.Strm
|
||||
return r.doGet(ctx, acct, cfg, "/System/Info", nil, &out)
|
||||
}
|
||||
|
||||
// ProxyPlayOf 返回账号是否配置了播放代理(供账号列表/编辑回显)。
|
||||
func (r *EmbyRemoteService) ProxyPlayOf(acct *model.StrmAccount) (bool, error) {
|
||||
cfg, err := r.configOf(acct)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return cfg.ProxyPlay, nil
|
||||
}
|
||||
|
||||
// ─── 元数据 / 目录聚合 ─────────────────────────────────────────────────────────
|
||||
|
||||
// RemoteViews 拉取远程媒体库(View)列表,返回远程原始 view map(未重写)。
|
||||
|
||||
@@ -237,6 +237,33 @@ func (s *StrmService) strmAccountConfig(acct *model.StrmAccount) (map[string]str
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
// mergeEmbyRemoteConfig 对远程 Emby 账号配置做合并式更新:config 中出现的键
|
||||
// 覆盖写入(敏感键按明文加密),未出现的键保留原密文;显式空字符串=清除。
|
||||
func (s *StrmService) mergeEmbyRemoteConfig(existing string, config map[string]string) (string, error) {
|
||||
out := map[string]string{}
|
||||
if strings.TrimSpace(existing) != "" {
|
||||
if err := json.Unmarshal([]byte(existing), &out); err != nil {
|
||||
return "", fmt.Errorf("decode account config: %w", err)
|
||||
}
|
||||
}
|
||||
for k, v := range config {
|
||||
if v == "" {
|
||||
delete(out, k)
|
||||
continue
|
||||
}
|
||||
if strmContains(StrmAccountSecretKeys, k) {
|
||||
out[k] = s.crypto.Encrypt(v)
|
||||
} else {
|
||||
out[k] = v
|
||||
}
|
||||
}
|
||||
data, err := json.Marshal(out)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(data), nil
|
||||
}
|
||||
|
||||
// HasStrmAccountCredential 报告账号是否已配置核心凭据(用于前端展示)。
|
||||
func HasStrmAccountCredential(acct *model.StrmAccount) bool {
|
||||
switch acct.Provider {
|
||||
@@ -292,7 +319,16 @@ func (s *StrmService) UpdateStrmAccount(ctx context.Context, id, name string, en
|
||||
acct.Enabled = *enabled
|
||||
}
|
||||
if len(config) > 0 {
|
||||
enc, err := s.strmAccountConfigJSON(config, true)
|
||||
var enc string
|
||||
var err error
|
||||
if acct.Provider == model.StrmProviderEmbyRemote {
|
||||
// 远程 Emby 账号:合并式更新。config 中出现的键覆盖(敏感键按明文
|
||||
// 加密写入),未出现的键保留原密文——避免编辑「代理开关」时把已
|
||||
// 保存的地址与凭据清空。
|
||||
enc, err = s.mergeEmbyRemoteConfig(acct.Config, config)
|
||||
} else {
|
||||
enc, err = s.strmAccountConfigJSON(config, true)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user