aboutsummaryrefslogtreecommitdiffstats
path: root/drive/share.go
diff options
context:
space:
mode:
authorDusan Stloukal2017-08-14 00:27:20 +0200
committerDusan Stloukal2017-08-14 01:27:21 +0200
commit6e62183b1ea60eaa1fb9051a5cdcdaa5dd88416b (patch)
tree574d51af757e84103776b52cd97ae8e0312b1cb1 /drive/share.go
parente14e24acf7cf437d73046b49a126ff3787c74269 (diff)
downloadgdrive-6e62183b1ea60eaa1fb9051a5cdcdaa5dd88416b.tar.bz2
Possibility to disable notification when sharing to user or group
Added the parameter --no-notification to the action "share" to not send notification e-mails to users or groups. Not allowed for other requests. It must not be disabled for ownership transfers.
Diffstat (limited to 'drive/share.go')
-rw-r--r--drive/share.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/drive/share.go b/drive/share.go
index e942c17..36ffb47 100644
--- a/drive/share.go
+++ b/drive/share.go
@@ -2,6 +2,7 @@ package drive
import (
"fmt"
+ "strings"
"google.golang.org/api/drive/v3"
"io"
"text/tabwriter"
@@ -15,18 +16,28 @@ type ShareArgs struct {
Email string
Domain string
Discoverable bool
+ DisableNotification bool
}
func (self *Drive) Share(args ShareArgs) error {
permission := &drive.Permission{
AllowFileDiscovery: args.Discoverable,
Role: args.Role,
- Type: args.Type,
+ Type: strings.ToLower(args.Type),
EmailAddress: args.Email,
Domain: args.Domain,
}
- _, err := self.service.Permissions.Create(args.FileId, permission).Do()
+ call := self.service.Permissions.Create(args.FileId, permission)
+
+ if permission.Type == "user" || permission.Type == "group" {
+ if args.DisableNotification {
+ call = call.SendNotificationEmail(false);
+ }
+ }
+
+ _, err := call.Do()
+
if err != nil {
return fmt.Errorf("Failed to share file: %s", err)
}