aboutsummaryrefslogtreecommitdiffstats
path: root/drive/share.go
diff options
context:
space:
mode:
authorTeddy Wing2022-08-19 12:11:45 +0200
committerTeddy Wing2022-08-19 12:11:45 +0200
commit07a3ecb0afd958b20522e93f066f3accb9f089b1 (patch)
tree6a1f2c4bb83382348e380baa4956b7229fd83489 /drive/share.go
parent9d35763b636e5db894507349cfc2f5f201198a08 (diff)
parent6e62183b1ea60eaa1fb9051a5cdcdaa5dd88416b (diff)
downloadgdrive-07a3ecb0afd958b20522e93f066f3accb9f089b1.tar.bz2
Merge branch 'pr/337' into tw
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)
}