Skip to content

Commit f03dd8a

Browse files
author
jie
committed
fix: include cover fallback in market publish payload
1 parent 2dd7250 commit f03dd8a

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

internal/model/device_templates.http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type DeviceConfigPayload struct {
123123
OtherConfig map[string]interface{} `json:"other_config"`
124124
AdditionalInfo map[string]interface{} `json:"additional_info"`
125125
AutoRegister int16 `json:"auto_register"`
126+
ImageURL string `json:"image_url,omitempty"`
126127
}
127128

128129
// PublishTemplateReq 发布模板到市场的业务契约对象(发送给 market-service)

internal/service/device_template_publish.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func (*DeviceTemplate) PublishToMarket(req model.PublishToMarketReq, claims *uti
158158
if coverURL != "" && publicOrigin != "" && !strings.HasPrefix(coverURL, "http://") && !strings.HasPrefix(coverURL, "https://") {
159159
coverURL = strings.TrimRight(publicOrigin, "/") + "/" + strings.TrimPrefix(coverURL, "./")
160160
}
161+
deviceConfig.ImageURL = coverURL
161162

162163
// 7. Extract plugin dependencies from DeviceConfig.protocol_type
163164
pluginDeps := getPluginDependenciesFromProtocol(dc)
@@ -176,6 +177,8 @@ func (*DeviceTemplate) PublishToMarket(req model.PublishToMarketReq, claims *uti
176177
TemplateDefinition: map[string]interface{}{
177178
"web_chart_config": tplDef["web_chart_config"],
178179
"app_chart_config": tplDef["app_chart_config"],
180+
"cover_url": coverURL,
181+
"template_path": ptrStr(tpl.Path),
179182
"telemetry": deviceModel["telemetry"],
180183
"attributes": deviceModel["attributes"],
181184
"commands": deviceModel["commands"],

0 commit comments

Comments
 (0)