FL-952 feat: add UserFriendsCreated event and extend CustomerUpdated with privacy fields
Summary
SDK extension for FL-952 (Public/Private Profile Visibility).
Adds one new event and extends one existing event payload to support:
- Auto-Approve on PUBLIC profile (single friend)
- Mass Auto-Accept on PRIVATE → PUBLIC transition (batch of N)
- Push storm mitigation via single consolidated event
- CMS-owned data (postsCount, whoCanViewPosts) propagation to FMS without HTTP coupling
See ADR-006 for the full design rationale and migration strategy.
Changes
New event: fms.UserFriendsCreated
type UserFriendsCreated struct {
UserID uuid.UUID `json:"userId" validate:"required"`
NewFriendsIDs []uuid.UUID `json:"newFriendsIds" validate:"required,min=1,dive,required"`
IsAutoAccepted bool `json:"isAutoAccepted"`
}
Topic: fms.user_friends.created
One event covers three cases:
- Manual accept (Phase 2+):
len=1, IsAutoAccepted=false - Auto-Approve PUBLIC:
len=1, IsAutoAccepted=true - Mass Auto-Accept:
len=N, IsAutoAccepted=true
Deprecated: fms.UserFriendCreated
Marked // Deprecated: use UserFriendsCreated. Kept in SDK during Phase 1 (manual-accept publish path); removal planned in a follow-up task.
Extended: cps.CustomerUpdated
+4 optional fields (all omitempty + validated):
-
ProfileVisibility(PUBLIC | PRIVATE) — owned by UPM -
PostsCount(*int64) — owned by CMS, propagated for FMS profile response -
WhoCanViewPosts(ALL | FRIENDS_OF_FRIENDS | FRIENDS | ONLY_ME) — owned by CMS, propagated for FMS BR-14 check -
WhoCanViewOrdersPosts— same as above
New types in cps package
-
ProfileVisibilityenum -
PostVisibilityenum
Migration strategy
Phase 1 (this MR): both UserFriendCreated and UserFriendsCreated live in parallel.
Phase 2 (separate task): migrate manual-accept publishers to new event.
Phase 3 (separate task): remove deprecated UserFriendCreated.
Test plan
-
go build ./...— clean -
go vet ./...— clean -
gofmt -l .— clean -
go test ./...— all packages pass -
New tests: 8 cases for UserFriendsCreated(3 success use cases, 3 failure cases, naming, JSON roundtrip) -
New tests: 6 cases for CustomerUpdatedprivacy fields (success PUBLIC/PRIVATE/omitted, fail invalid enum, all PostVisibility values loop)
Related
- Jira: FL-952
- Design: ADR-006 — SDK extension
- [Backend] Бриф §5 — SDK events section
Edited by David Makyan