feat(smzdm): require 1:1 cover and surface image fetch failure prompt
Add SMZDM to the cover-required platform list on both client and server, register a 800x800 native cover spec in the admin cover catalog, and normalize the desktop-client `smzdm_image_fetch_failed` adapter error to a user-friendly Chinese prompt across the publisher error pipeline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,15 @@ const requirementCatalog: Record<string, Partial<PlatformCoverRequirement>> = {
|
||||
outputHeight: 900,
|
||||
priority: 90,
|
||||
},
|
||||
smzdm: {
|
||||
required: true,
|
||||
supportMode: 'native',
|
||||
aspectRatio: 1,
|
||||
aspectLabel: '1:1',
|
||||
outputWidth: 800,
|
||||
outputHeight: 800,
|
||||
priority: 90,
|
||||
},
|
||||
}
|
||||
|
||||
export function getPlatformCoverRequirements(
|
||||
|
||||
@@ -787,7 +787,7 @@ function failureResult(
|
||||
if (message.startsWith('smzdm_image_fetch_failed')) {
|
||||
return {
|
||||
status: 'failed',
|
||||
summary: '什么值得买正文图片读取失败,请检查文章图片后重试。',
|
||||
summary: '图片获取错误,请检查你文章和封面图片是否正确',
|
||||
error: {
|
||||
code: 'smzdm_image_fetch_failed',
|
||||
message,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE,
|
||||
PUBLISH_ACCOUNT_NOT_LOGGED_IN_MESSAGE,
|
||||
QIEHAO_REAL_NAME_AUTH_MESSAGE,
|
||||
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
|
||||
WANGYIHAO_DRAFT_SAVE_PARAMETER_MESSAGE,
|
||||
WANGYIHAO_PUBLISH_CLICK_MESSAGE,
|
||||
WANGYIHAO_TOKEN_MISSING_MESSAGE,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
normalizePublisherErrorMessage,
|
||||
normalizePublisherLoginErrorMessage,
|
||||
normalizeQiehaoPublishErrorMessage,
|
||||
normalizeSmzdmPublishErrorMessage,
|
||||
normalizeWangyihaoPublishErrorMessage,
|
||||
normalizeWeixinGzhPublishErrorMessage,
|
||||
} from './publisher-errors'
|
||||
@@ -113,6 +115,15 @@ describe('publisher error normalization', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('normalizes SMZDM image fetch failures to the desktop Chinese prompt', () => {
|
||||
expect(normalizePublisherErrorMessage('smzdm_image_fetch_failed', 'smzdm')).toBe(
|
||||
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
|
||||
)
|
||||
expect(normalizeSmzdmPublishErrorMessage('Error: smzdm_image_fetch_failed')).toBe(
|
||||
SMZDM_IMAGE_FETCH_FAILED_MESSAGE,
|
||||
)
|
||||
})
|
||||
|
||||
it('leaves unknown publisher errors unchanged', () => {
|
||||
expect(normalizePublisherErrorMessage('qiehao_publish_failed')).toBe('qiehao_publish_failed')
|
||||
})
|
||||
|
||||
@@ -14,6 +14,8 @@ export const BAIJIAHAO_CHALLENGE_REQUIRED_MESSAGE =
|
||||
'百家号检测到网络环境异常,需要人机验证。请打开百家号后台手动完成一次发稿或验证后再重试发布。'
|
||||
export const DONGCHEDI_PLATFORM_EXCEPTION_MESSAGE =
|
||||
'懂车帝平台返回异常,请打开懂车帝后台查看并处理平台提示,确认账号状态后再重试。'
|
||||
export const SMZDM_IMAGE_FETCH_FAILED_MESSAGE =
|
||||
'图片获取错误,请检查你文章中图片是否正确'
|
||||
|
||||
const PUBLISH_PLATFORM_LABELS: Record<string, string> = {
|
||||
baijiahao: '百家号',
|
||||
@@ -264,6 +266,20 @@ export function normalizeDongchediPublishErrorMessage(
|
||||
return normalized
|
||||
}
|
||||
|
||||
export function normalizeSmzdmPublishErrorMessage(
|
||||
message: string | null | undefined,
|
||||
): string | null {
|
||||
const normalized = normalizeErrorText(message)
|
||||
if (!normalized) {
|
||||
return null
|
||||
}
|
||||
|
||||
if (/\bsmzdm_image_fetch_failed\b/i.test(normalized)) {
|
||||
return SMZDM_IMAGE_FETCH_FAILED_MESSAGE
|
||||
}
|
||||
return normalized
|
||||
}
|
||||
|
||||
export function normalizePublisherErrorMessage(
|
||||
message: string | null | undefined,
|
||||
platform?: string | null,
|
||||
@@ -279,6 +295,7 @@ export function normalizePublisherErrorMessage(
|
||||
const wangyihaoMessage = normalizeWangyihaoPublishErrorMessage(qiehaoMessage)
|
||||
const baijiahaoMessage = normalizeBaijiahaoPublishErrorMessage(wangyihaoMessage)
|
||||
const dongchediMessage = normalizeDongchediPublishErrorMessage(baijiahaoMessage, platform)
|
||||
const loginMessage = normalizePublisherLoginErrorMessage(dongchediMessage)
|
||||
const smzdmMessage = normalizeSmzdmPublishErrorMessage(dongchediMessage)
|
||||
const loginMessage = normalizePublisherLoginErrorMessage(smzdmMessage)
|
||||
return normalizeWeixinGzhPublishErrorMessage(loginMessage)
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func publishBatchRequiresCover(accounts []platformAccountSeed) bool {
|
||||
|
||||
func publishPlatformRequiresCover(platformID string) bool {
|
||||
switch strings.TrimSpace(platformID) {
|
||||
case "weixin_gzh", "baijiahao", "dongchedi":
|
||||
case "weixin_gzh", "baijiahao", "dongchedi", "smzdm":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
|
||||
@@ -5,7 +5,7 @@ import "testing"
|
||||
func TestPublishPlatformRequiresCover(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, platformID := range []string{"weixin_gzh", "baijiahao", "dongchedi"} {
|
||||
for _, platformID := range []string{"weixin_gzh", "baijiahao", "dongchedi", "smzdm"} {
|
||||
if !publishPlatformRequiresCover(platformID) {
|
||||
t.Fatalf("publishPlatformRequiresCover(%q) = false, want true", platformID)
|
||||
}
|
||||
@@ -19,12 +19,12 @@ func TestPublishPlatformRequiresCover(t *testing.T) {
|
||||
func TestPublishCoverRequirementCallersIncludeWeixinGzh(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
accounts := []platformAccountSeed{{PlatformID: "weixin_gzh"}}
|
||||
accounts := []platformAccountSeed{{PlatformID: "weixin_gzh"}, {PlatformID: "smzdm"}}
|
||||
if !publishBatchRequiresCover(accounts) {
|
||||
t.Fatal("publishBatchRequiresCover() = false for weixin_gzh, want true")
|
||||
t.Fatal("publishBatchRequiresCover() = false for cover-required platforms, want true")
|
||||
}
|
||||
|
||||
if !schedulePublishPlatformsRequireCover([]string{"weixin_gzh"}) {
|
||||
t.Fatal("schedulePublishPlatformsRequireCover() = false for weixin_gzh, want true")
|
||||
if !schedulePublishPlatformsRequireCover([]string{"weixin_gzh", "smzdm"}) {
|
||||
t.Fatal("schedulePublishPlatformsRequireCover() = false for cover-required platforms, want true")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user