From b03aa64c81658bea8763a11b0dde27a03a1903dd Mon Sep 17 00:00:00 2001 From: Bruno Michel Date: Tue, 5 Mar 2024 14:15:43 +0100 Subject: [PATCH] Rename the Removed field of sharing.Group to Revoked --- docs/sharing-design.md | 31 ++++++++++--------- model/sharing/group.go | 4 +-- model/sharing/group_test.go | 16 +++++----- tests/system/tests/sharing_several_members.rb | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/docs/sharing-design.md b/docs/sharing-design.md index bd6bcd10c67..e82c463e882 100644 --- a/docs/sharing-design.md +++ b/docs/sharing-design.md @@ -475,17 +475,17 @@ care of it later. - An identifier (the same for all members of the sharing) - A list of `members`. The first one is the owner. For each member, we have: - `status`, a status that can be: - - `owner` for the member that has created the sharing - - `mail-not-sent` for a member that has been added, but its - invitation has not yet been sent (often, this status is used only - for a few seconds) - - `pending` for a member with an invitation sent, but who has not - clicked on the link - - `seen` for a member that has clicked on the invitation link, but - has not setup the Cozy to Cozy replication for the sharing - - `ready` for a member where the Cozy to Cozy replication has been - set up - - `revoked` for a member who is on longer in the sharing + - `owner` for the member that has created the sharing + - `mail-not-sent` for a member that has been added, but its + invitation has not yet been sent (often, this status is used only + for a few seconds) + - `pending` for a member with an invitation sent, but who has not + clicked on the link + - `seen` for a member that has clicked on the invitation link, but + has not setup the Cozy to Cozy replication for the sharing + - `ready` for a member where the Cozy to Cozy replication has been + set up + - `revoked` for a member who is on longer in the sharing - `name`, a contact name - `public_name`, a public name - `email`, the email address @@ -495,10 +495,11 @@ care of it later. as a single contact - `groups`, a list of indexes of the groups - A list of `groups`, with for each one: - - `id`, the identifier of the io.cozy.contacts.groups - - `name`, the name of the group - - `addedBy`, the index of the member that has added the group - - `removed`, a flag set to true when the group is revoked from the sharing + - `id`, the identifier of the io.cozy.contacts.groups + - `name`, the name of the group + - `addedBy`, the index of the member that has added the group + - `read_only`, a flag to tell if the group is restricted to read-only mode + - `revoked`, a flag set to true when the group is revoked from the sharing - Some `credentials` to authorize the transfer of data between the owner and the recipients - A `description` (one sentence that will help people understand what is diff --git a/model/sharing/group.go b/model/sharing/group.go index ec6f2b299c4..a0c34b97956 100644 --- a/model/sharing/group.go +++ b/model/sharing/group.go @@ -27,7 +27,7 @@ type Group struct { Name string `json:"name"` AddedBy int `json:"addedBy"` // The index of the member who added the group ReadOnly bool `json:"read_only"` - Removed bool `json:"removed,omitempty"` + Revoked bool `json:"revoked,omitempty"` } // AddGroup adds a group of contacts identified by its ID to the members of the @@ -98,7 +98,7 @@ func (s *Sharing) RevokeGroup(inst *instance.Instance, index int) error { } } - s.Groups[index].Removed = true + s.Groups[index].Revoked = true if err := couchdb.UpdateDoc(inst, s); err != nil { errm = multierror.Append(errm, err) } diff --git a/model/sharing/group_test.go b/model/sharing/group_test.go index 1576029589a..90d1e966aa5 100644 --- a/model/sharing/group_test.go +++ b/model/sharing/group_test.go @@ -76,9 +76,9 @@ func TestGroups(t *testing.T) { require.Len(t, s.Groups, 2) require.Equal(t, s.Groups[0].Name, "Friends") - assert.False(t, s.Groups[0].Removed) + assert.False(t, s.Groups[0].Revoked) require.Equal(t, s.Groups[1].Name, "Football") - assert.False(t, s.Groups[1].Removed) + assert.False(t, s.Groups[1].Revoked) require.NoError(t, s.RevokeGroup(inst, 1)) // Revoke the football group @@ -91,8 +91,8 @@ func TestGroups(t *testing.T) { assert.Empty(t, s.Members[3].Groups) require.Len(t, s.Groups, 2) - assert.False(t, s.Groups[0].Removed) - assert.True(t, s.Groups[1].Removed) + assert.False(t, s.Groups[0].Revoked) + assert.True(t, s.Groups[1].Revoked) require.NoError(t, s.RevokeGroup(inst, 0)) // Revoke the fiends group @@ -105,8 +105,8 @@ func TestGroups(t *testing.T) { assert.Empty(t, s.Members[3].Groups) require.Len(t, s.Groups, 2) - assert.True(t, s.Groups[0].Removed) - assert.True(t, s.Groups[1].Removed) + assert.True(t, s.Groups[0].Revoked) + assert.True(t, s.Groups[1].Revoked) }) t.Run("UpdateGroups", func(t *testing.T) { @@ -158,9 +158,9 @@ func TestGroups(t *testing.T) { require.Len(t, s.Groups, 2) require.Equal(t, s.Groups[0].Name, "Friends") - assert.False(t, s.Groups[0].Removed) + assert.False(t, s.Groups[0].Revoked) require.Equal(t, s.Groups[1].Name, "Football") - assert.False(t, s.Groups[1].Removed) + assert.False(t, s.Groups[1].Revoked) // Charlie is added to the friends group msg1 := job.ShareGroupMessage{ diff --git a/tests/system/tests/sharing_several_members.rb b/tests/system/tests/sharing_several_members.rb index 521409487b1..113a80a1e53 100644 --- a/tests/system/tests/sharing_several_members.rb +++ b/tests/system/tests/sharing_several_members.rb @@ -100,7 +100,7 @@ info = Sharing.get_sharing_info inst, sharing.couch_id, Folder.doctype members = [contact_bob, contact_charlie, contact_dave, contact_emily, contact_gaby, contact_hugo] revoked = [5] - assert info.dig("attributes", "groups", 0, "removed") + assert info.dig("attributes", "groups", 0, "revoked") check_sharing_has_groups_and_members info, [g1, g2], members, revoked # Check that the files are the same on disk