Repository navigation
feat(common-contacts): remove the member copies once the org instance is filled - #4975
Conversation
d4525f8 to
0de9c8f
Compare
| if orgInst == nil { | ||
| return nil, fmt.Errorf("organization %s has no organization instance: %w", organizationID, instance.ErrNotFound) | ||
| } | ||
| if !orgInst.HasCommonContacts() { | ||
| return nil, errors.New("the organization instance does not read the common contacts") | ||
| } |
There was a problem hiding this comment.
Only the context flag is checked, not that the org instance is filled.
Run before the republication is consumed, it wipes the org members with nothing to replace them (live: 0 contacts with carddavPath on the org instance, 5 copies deleted).
Refuse when the org instance has no contact with a carddavPath (FindDocs, Limit 1, by-carddav-path).
| func memberCopiesFixer(c echo.Context) error { | ||
| dryRun := c.QueryParam("dry_run") == "true" | ||
| report, err := orgdirectory.RemoveMemberCopies(c.Request().Context(), c.Param("org_id"), dryRun) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| return c.JSON(http.StatusOK, report) | ||
| } |
There was a problem hiding this comment.
Unknown org, missing org instance and "does not read the common contacts" all come back as 500 Unqualified error.
Map instance.ErrNotFound to 404 and the precondition to 400 or 412.
| for domain, n := range report.Removed { | ||
| fmt.Fprintf(os.Stdout, "%s %d from %s\n", removed, n, domain) | ||
| } |
There was a problem hiding this comment.
report.Removed prints in map order. Sort the domains so outputs diff.
There was a problem hiding this comment.
The problem is the copies come back.
addMembersToGroup (model/orgdirectory/groups.go L346-L376) still upserts into every org instance, common_contacts ones included. Same for syncCreatedOrgContact (pkg/rabbitmq/org_contacts.go L46-L70) when the new member is in a context without common_contacts.
I ran the fixer locally, sent one b2b.group.member.added, and the dry run listed a copy again. Then a user.created from a plain context member brought back two more.
Either skip inst.HasCommonContacts() in both, or say in the help text that the fixer has to be rerun until #1780.
Also, after the fixer, AddGroup on a member instance (model/sharing/group.go L37-L63) only finds the contacts the feed took over. Locally a new group sharing invited alice and zed, and lost bob and carol.
Right, on its own this PR leaves
That one is expected: contexts without
Right, the membership lives on the contacts, so removing the copies empties the groups on the member instances: your bob and carol case. #4976 looks the group up on the org instance first and reads its members there ( |
de6d822 to
ae3b520
Compare
5ee5d41 to
1a75e14
Compare
…eed fills the org instance Run before the republication was consumed, the fixer deleted the copies with nothing to replace them. It now waits for at least one contact with a carddavPath on the organization instance, which only the feed writes.
An unknown organization, a missing organization instance and an organization instance that is not ready all came back as a 500.
1a75e14 to
09c37d3
Compare
Summary
cozy-stack fix member-copies <org-id>andPOST /instances/fixers/member-copies/:org_idto remove replicated directory contacts after centralization.centralized_org_directory, independently ofcommon_contacts. B2B events or the contacts service can populate the organization instance.Part of linagora/twake-workplace-private#1779.