mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-10-31 02:28:31 -04:00
Merge pull request #3739 from aduffeck/guestlink-renewal-mail-without-pin
Make renewal mails without PINs work
This commit is contained in:
3 files changed
+51
-3
No files matched your search
@@ -86,6 +86,23 @@ The link and the PIN are only valid for 30 minutes.`),
|
||||
CallToAction: l10n.Template(`Click here to view it: {ShareLink}`),
|
||||
}
|
||||
|
||||
GuestLinkShareRenewedWithoutPin = MessageTemplate{
|
||||
textTemplate: _textTemplate,
|
||||
htmlTemplate: _htmlTemplate,
|
||||
// GuestLinkShareRenewedWithoutPin email template, Subject field (resolves directly)
|
||||
Subject: l10n.Template(`Your new link to '{ShareFolder}'`),
|
||||
// GuestLinkShareRenewedWithoutPin email template, resolves via {{ .Greeting }}
|
||||
Greeting: l10n.Template(`Hello,`),
|
||||
// GuestLinkShareRenewedWithoutPin email template, resolves via {{ .MessageBody }}
|
||||
MessageBody: l10n.Template(`A new link to "{ShareFolder}", shared with you by {ShareSharer}, has been requested.
|
||||
|
||||
The link below is personal and can only be used once. Please do not forward it.
|
||||
|
||||
The link is only valid for 30 minutes.`),
|
||||
// GuestLinkShareRenewedWithoutPin email template, resolves via {{ .CallToAction }}
|
||||
CallToAction: l10n.Template(`Click here to view it: {ShareLink}`),
|
||||
}
|
||||
|
||||
// Spaces templates
|
||||
SharedSpace = MessageTemplate{
|
||||
textTemplate: _textTemplate,
|
||||
|
||||
@@ -29,8 +29,9 @@ func (s eventsNotifier) handleGuestTokenCreated(e ocevents.GuestTokenCreated) {
|
||||
s.sendGuestLinkMail(logger, email.GuestLinkShareCreated, e.Sharer, e.GranteeEmail, e.ItemID, e.ResourceName, e.Token, nil)
|
||||
}
|
||||
|
||||
// handleGuestTokenRenewed sends the renewed guest link and the PIN to the
|
||||
// guest's email address, like handleGuestTokenCreated.
|
||||
// handleGuestTokenRenewed sends the renewed guest link to the guest's email
|
||||
// address, like handleGuestTokenCreated. The event only carries a PIN when the
|
||||
// renewal was authorized by a guest session; otherwise just the link is sent.
|
||||
func (s eventsNotifier) handleGuestTokenRenewed(e ocevents.GuestTokenRenewed) {
|
||||
logger := s.logger.With().
|
||||
Str("event", "GuestTokenRenewed").
|
||||
@@ -38,7 +39,7 @@ func (s eventsNotifier) handleGuestTokenRenewed(e ocevents.GuestTokenRenewed) {
|
||||
Logger()
|
||||
|
||||
if e.Pin == "" {
|
||||
logger.Error().Msg("guest pin is empty")
|
||||
s.sendGuestLinkMail(logger, email.GuestLinkShareRenewedWithoutPin, e.Sharer, e.GranteeEmail, e.ItemID, "", e.Token, nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -371,6 +371,36 @@ https://opencloud.eu
|
||||
Pin: "123456",
|
||||
},
|
||||
}),
|
||||
|
||||
Entry("Guest Token Renewed without PIN", testChannel{
|
||||
expectedReceipients: []string{"guest@example.com"},
|
||||
expectedSubject: "Your new link to 'secrets of the board'",
|
||||
expectedTextBody: `Hello,
|
||||
|
||||
A new link to "secrets of the board", shared with you by Dr. S. Harer, has been requested.
|
||||
|
||||
The link below is personal and can only be used once. Please do not forward it.
|
||||
|
||||
The link is only valid for 30 minutes.
|
||||
|
||||
Click here to view it: https://cloud.example.com/g/v1.sharehash.newsecret
|
||||
|
||||
|
||||
---
|
||||
OpenCloud - a safe home for all your data
|
||||
https://opencloud.eu
|
||||
`,
|
||||
expectedSender: sharer.GetDisplayName(),
|
||||
expectedLink: testOpenCloudURL + "/g/v1.sharehash.newsecret",
|
||||
done: make(chan struct{}),
|
||||
}, events.Event{
|
||||
Event: ocEvents.GuestTokenRenewed{
|
||||
Sharer: sharer.GetId(),
|
||||
GranteeEmail: "guest@example.com",
|
||||
ItemID: resourceid,
|
||||
Token: "v1.sharehash.newsecret",
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user