Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion drive/share.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ShareArgs struct {
Email string
Domain string
Discoverable bool
NotificationMessage string
}

func (self *Drive) Share(args ShareArgs) error {
Expand All @@ -26,7 +27,14 @@ func (self *Drive) Share(args ShareArgs) error {
Domain: args.Domain,
}

_, err := self.service.Permissions.Create(args.FileId, permission).Do()
call := self.service.Permissions.Create(args.FileId, permission)

if args.NotificationMessage != "" {
call = call.EmailMessage(args.NotificationMessage);
}

_, err := call.Do()

if err != nil {
return fmt.Errorf("Failed to share file: %s", err)
}
Expand Down
5 changes: 5 additions & 0 deletions gdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ func main() {
Description: "Delete all sharing permissions (owner roles will be skipped)",
OmitValue: true,
},
cli.StringFlag{
Name: "notificationMessage",
Patterns: []string{"--notification-message"},
Description: "A custom message to include in the notification email.",
},
),
},
},
Expand Down
1 change: 1 addition & 0 deletions handlers_drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ func shareHandler(ctx cli.Context) {
Email: args.String("email"),
Domain: args.String("domain"),
Discoverable: args.Bool("discoverable"),
NotificationMessage: args.String("notificationMessage"),
})
checkErr(err)
}
Expand Down