fix(shangwutong): close contact sync review gaps (#4)

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-13 01:21:07 +08:00
committed by GitHub
co-authored by rogee
parent 406e7a07fe
commit 0e9bf8dc14
15 changed files with 212 additions and 39 deletions
@@ -771,6 +771,20 @@ func TestWidgetHandler_Cov3_PublicCreateContact_Success_Cov3(t *testing.T) {
assert.Equal(t, "New Contact", resp["name"])
}
func TestWidgetHandler_PublicContactIgnoresCID(t *testing.T) {
db, router, _ := setupWidgetHandlerTest(t)
_, _, channelAPI := seedPublicAPIInbox(t, db)
body, _ := json.Marshal(map[string]any{"name": "Visitor", "source_id": "visitor", "channel_metadata": map[string]any{"cid": "forged"}})
w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodPost, "/public/api/v1/inboxes/"+channelAPI.Identifier+"/contacts", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
router.ServeHTTP(w, req)
require.Equal(t, http.StatusOK, w.Code, w.Body.String())
var contactInbox model.ContactInbox
require.NoError(t, db.Where("source_id = ?", "visitor").First(&contactInbox).Error)
assert.NotContains(t, string(contactInbox.ChannelMetadata), "forged")
}
func TestWidgetHandler_Cov3_PublicUpdateContact_Success_Cov3(t *testing.T) {
db, router, _ := setupWidgetHandlerTest(t)
_, _, channelAPI := seedPublicAPIInbox(t, db)