Fix share/space link in notification mail

Use OCIS_URL as the link base. This change also makes sure that the
top-level OcisURL config value gets a default assigned, even when
OCIS_URL is unset.

Fixes: #4688
This commit is contained in:
Ralf Haferkamp
2022-09-29 14:59:16 +02:00
committed by Ralf Haferkamp
parent de1588843a
commit c6664cfe61
7 changed files with 31 additions and 11 deletions

View File

@@ -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

View File

@@ -35,6 +35,7 @@ import (
func DefaultConfig() *Config {
return &Config{
OcisURL: "https://localhost:9200",
Runtime: Runtime{
Port: "9250",
Host: "localhost",

View File

@@ -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 {

View File

@@ -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()
},
}

View File

@@ -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
https://owncloud.com

View File

@@ -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
https://owncloud.com

View File

@@ -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 {