diff --git a/changelog/unreleased/fix-share-notifications.md b/changelog/unreleased/fix-share-notifications.md new file mode 100644 index 000000000..0931b6c1a --- /dev/null +++ b/changelog/unreleased/fix-share-notifications.md @@ -0,0 +1,8 @@ +Bugfix: Mail notifications for group shares + +We fixed multiple issues in the notifications service, which broke notifcation +mails new shares with groups. + +https://github.com/owncloud/ocis/pull/4714 +https://github.com/owncloud/ocis/issues/4703 +https://github.com/owncloud/ocis/issues/4688 diff --git a/ocis-pkg/config/defaultconfig.go b/ocis-pkg/config/defaultconfig.go index b0546c7af..90144d3b0 100644 --- a/ocis-pkg/config/defaultconfig.go +++ b/ocis-pkg/config/defaultconfig.go @@ -35,6 +35,7 @@ import ( func DefaultConfig() *Config { return &Config{ + OcisURL: "https://localhost:9200", Runtime: Runtime{ Port: "9250", Host: "localhost", diff --git a/ocis-pkg/config/parser/parse.go b/ocis-pkg/config/parser/parse.go index 3ffe25b07..5e25b2b9d 100644 --- a/ocis-pkg/config/parser/parse.go +++ b/ocis-pkg/config/parser/parse.go @@ -124,6 +124,10 @@ func EnsureCommons(cfg *config.Config) { if cfg.AdminUserID != "" { cfg.Commons.AdminUserID = cfg.AdminUserID } + + if cfg.OcisURL != "" { + cfg.Commons.OcisURL = cfg.OcisURL + } } func Validate(cfg *config.Config) error { diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index 892205355..6fcdb31e7 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -55,7 +55,7 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Str("addr", cfg.Notifications.RevaGateway).Msg("could not get reva client") } - svc := service.NewEventsNotifier(evts, channel, logger, gwclient, cfg.Notifications.MachineAuthAPIKey, cfg.Notifications.EmailTemplatePath) + svc := service.NewEventsNotifier(evts, channel, logger, gwclient, cfg.Notifications.MachineAuthAPIKey, cfg.Notifications.EmailTemplatePath, cfg.Commons.OcisURL) return svc.Run() }, } diff --git a/services/notifications/pkg/email/templates/shareCreated.email.tmpl b/services/notifications/pkg/email/templates/shareCreated.email.tmpl index 5c0b3fca0..f33ccde48 100644 --- a/services/notifications/pkg/email/templates/shareCreated.email.tmpl +++ b/services/notifications/pkg/email/templates/shareCreated.email.tmpl @@ -1,6 +1,6 @@ Hello {{ .ShareGrantee }}, -{{ .ShareSharer }} has shared {{ .ShareFolder }} with you. +{{ .ShareSharer }} has shared "{{ .ShareFolder }}" with you. Click here to view it: {{ .ShareLink }} @@ -8,11 +8,11 @@ Click here to view it: {{ .ShareLink }} Hallo {{ .Grantee }}, -{{ .ShareSharer }} hat dich zu {{ .ShareFolder }} eingeladen. +{{ .ShareSharer }} hat dich zu "{{ .ShareFolder }}" eingeladen. Klicke hier zum Anzeigen: {{ .ShareLink }} --- ownCloud - Store. Share. Work. -https://owncloud.com \ No newline at end of file +https://owncloud.com diff --git a/services/notifications/pkg/email/templates/sharedSpace.email.tmpl b/services/notifications/pkg/email/templates/sharedSpace.email.tmpl index 16bef45f6..897e4eb66 100644 --- a/services/notifications/pkg/email/templates/sharedSpace.email.tmpl +++ b/services/notifications/pkg/email/templates/sharedSpace.email.tmpl @@ -1,6 +1,6 @@ Hello {{ .SpaceGrantee }}, -{{ .SpaceSharer }} has invited you to join {{ .SpaceName }}. +{{ .SpaceSharer }} has invited you to join "{{ .SpaceName }}". Click here to view it: {{ .ShareLink }} @@ -8,11 +8,11 @@ Click here to view it: {{ .ShareLink }} Hallo {{ .SpaceGrantee }}, -{{ .SpaceSharer }} hat dich in den Space {{ .SpaceName }} eingeladen. +{{ .SpaceSharer }} hat dich in den Space "{{ .SpaceName }}" eingeladen. Klicke hier zum Anzeigen: {{ .ShareLink }} --- ownCloud - Store. Share. Work. -https://owncloud.com \ No newline at end of file +https://owncloud.com diff --git a/services/notifications/pkg/service/service.go b/services/notifications/pkg/service/service.go index c34c884dc..c16b48ee2 100644 --- a/services/notifications/pkg/service/service.go +++ b/services/notifications/pkg/service/service.go @@ -29,7 +29,12 @@ type Service interface { } // NewEventsNotifier provides a new eventsNotifier -func NewEventsNotifier(events <-chan interface{}, channel channels.Channel, logger log.Logger, gwClient gateway.GatewayAPIClient, machineAuthAPIKey, emailTemplatePath string) Service { +func NewEventsNotifier( + events <-chan interface{}, + channel channels.Channel, + logger log.Logger, + gwClient gateway.GatewayAPIClient, + machineAuthAPIKey, emailTemplatePath, ocisURL string) Service { return eventsNotifier{ logger: logger, channel: channel, @@ -38,6 +43,7 @@ func NewEventsNotifier(events <-chan interface{}, channel channels.Channel, logg gwClient: gwClient, machineAuthAPIKey: machineAuthAPIKey, emailTemplatePath: emailTemplatePath, + ocisURL: ocisURL, } } @@ -49,6 +55,7 @@ type eventsNotifier struct { gwClient gateway.GatewayAPIClient machineAuthAPIKey string emailTemplatePath string + ocisURL string } func (s eventsNotifier) Run() error { @@ -147,7 +154,7 @@ func (s eventsNotifier) handleSpaceShared(e events.SpaceShared) { return } - shareLink, err := urlJoinPath(e.Executant.Idp, "files/spaces/projects", storagespace.FormatResourceID(*e.ID)) + shareLink, err := urlJoinPath(s.ocisURL, "files/spaces/projects", storagespace.FormatResourceID(*e.ID)) if err != nil { s.logger.Error(). @@ -284,7 +291,7 @@ func (s eventsNotifier) handleShareCreated(e events.ShareCreated) { return } - shareLink, err := urlJoinPath(e.Executant.Idp, "files/shares/with-me") + shareLink, err := urlJoinPath(s.ocisURL, "files/shares/with-me") if err != nil { s.logger.Error(). @@ -345,7 +352,7 @@ func (s eventsNotifier) handleShareCreated(e events.ShareCreated) { Msg("Could not render E-Mail template for shares") } - emailSubject := fmt.Sprintf("%s shared %s with you", sharerUserResponse.GetUser().DisplayName, md.GetInfo().Name) + emailSubject := fmt.Sprintf("%s shared '%s' with you", sharerUserResponse.GetUser().DisplayName, md.GetInfo().Name) if e.GranteeUserID != nil { err = s.channel.SendMessage(ownerCtx, []string{e.GranteeUserID.OpaqueId}, msg, emailSubject, sharerDisplayName) } else if e.GranteeGroupID != nil {