Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unshare: use by default accountType User #771

Merged
merged 1 commit into from
Oct 16, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,8 @@ func (c *Commands) playShareChanges(change *shareChange) (err error) {
withLink: change.withLink,
}

if err := fn(&perm); err != nil {
err = reComposeError(err, fmt.Sprintf("%s err %s: %v\n", fnName, file.Name, err))
if ferr := fn(&perm); ferr != nil {
err = reComposeError(err, fmt.Sprintf("%s err %s: %v\n", fnName, file.Name, ferr))
} else {
successes += 1
if c.opts.Verbose {
Expand All @@ -323,11 +323,15 @@ func (c *Commands) playShareChanges(change *shareChange) (err error) {
}
}

if err != nil {
return err
}

if successes < 1 {
return noMatchesFoundErr(fmt.Errorf("no matches found!"))
}

return err
return nil
}

func (c *Commands) share(revoke, byId bool) (err error) {
Expand All @@ -337,15 +341,18 @@ func (c *Commands) share(revoke, byId bool) (err error) {
var emailMessage string

roles := []Role{}
accountTypes := []AccountType{}

// By default, if they don't specify any
// account types to invoke, let's assume User.
// See Issue https://github.com/odeke-em/drive/issues/747.
accountTypes := []AccountType{User}

if revoke {
// In case of unsharing, when a user doesn't specify the
// roles, the addressee should be removed from all roles
roles = append(roles, Reader, Writer, Commenter)
} else {
roles = append(roles, Reader)
accountTypes = append(accountTypes, User)
}

meta := *c.opts.Meta
Expand Down