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

share: anyone with link, not publicly published #648

Merged
merged 1 commit into from
May 19, 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
31 changes: 27 additions & 4 deletions src/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ var reverseRoleResolve = stringToRole()
var reverseAccountTypeResolve = stringToAccountType()

func reverseRolesResolver(roleArgv ...string) (roles []Role) {
alreadySeen := map[Role]bool{}
for _, roleStr := range roleArgv {
roles = append(roles, reverseRoleResolve(roleStr))
role := reverseRoleResolve(roleStr)
if _, seen := alreadySeen[role]; !seen {
roles = append(roles, role)
alreadySeen[role] = true
}
}

return roles
Expand Down Expand Up @@ -238,6 +243,9 @@ func showPromptShareChanges(logy *log.Logger, change *shareChange) Agreement {
if len(change.emails) >= 1 {
logy.Logf("\nAddressees:\n")
for _, email := range change.emails {
if email == "" {
email = "Anyone with the link"
}
logy.Logf("\t\033[92m+\033[00m %s\n", email)
}
}
Expand Down Expand Up @@ -275,9 +283,15 @@ func (c *Commands) playShareChanges(change *shareChange) (err error) {
successes := 0

for _, file := range change.files {
for _, email := range change.emails {
for _, role := range change.roles {
for _, accountType := range change.accountTypes {
for _, accountType := range change.accountTypes {
for _, email := range change.emails {
if accountType == Anyone && email != "" {
// It doesn't make sense to share a file with
// permission "anyone" yet provide an email
continue
}

for _, role := range change.roles {
perm := permission{
fileId: file.Id,
value: email,
Expand Down Expand Up @@ -363,6 +377,15 @@ func (c *Commands) share(revoke, byId bool) (err error) {

notify := (c.opts.TypeMask & Notify) != 0

// Now here we have to match up emails with roles
// See Issue #568. If we've requested say `anyone`, this role needs no email
// address, so we should add an empty "" to the list of emails
for _, accountType := range accountTypes {
if accountType == Anyone {
emails = append(emails, "")
}
}

change := shareChange{
accountTypes: accountTypes,
emailMessage: emailMessage,
Expand Down