Skip to content

Commit

Permalink
Rename the Removed field of sharing.Group to Revoked
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed Mar 5, 2024
1 parent e14c54c commit b03aa64
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
31 changes: 16 additions & 15 deletions docs/sharing-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions model/sharing/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
16 changes: 8 additions & 8 deletions model/sharing/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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) {
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion tests/system/tests/sharing_several_members.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b03aa64

Please sign in to comment.