-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4564 from dragonchaser/email-template
Add email templating
- Loading branch information
Showing
9 changed files
with
377 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Enhancement: Add Email templating | ||
|
||
We have added email templating to ocis. Which are send on the SpaceShared and ShareCreated event. | ||
|
||
https://github.com/owncloud/ocis/pull/4564 | ||
https://github.com/owncloud/ocis/issues/4303 | ||
https://github.com/cs3org/reva/pull/3252 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package email | ||
|
||
import ( | ||
"bytes" | ||
"embed" | ||
"html/template" | ||
"path/filepath" | ||
) | ||
|
||
var ( | ||
//go:embed templates | ||
templatesFS embed.FS | ||
) | ||
|
||
// RenderEmailTemplate renders the email template for a new share | ||
func RenderEmailTemplate(templateName string, templateVariables map[string]string, emailTemplatePath string) (string, error) { | ||
var err error | ||
var tpl *template.Template | ||
// try to lookup the files in the filesystem | ||
tpl, err = template.ParseFiles(filepath.Join(emailTemplatePath, templateName)) | ||
if err != nil { | ||
// template has not been found in the fs, or path has not been specified => use embed templates | ||
tpl, err = template.ParseFS(templatesFS, filepath.Join("templates/", templateName)) | ||
if err != nil { | ||
return "", err | ||
} | ||
} | ||
var writer bytes.Buffer | ||
err = tpl.Execute(&writer, templateVariables) | ||
if err != nil { | ||
return "", err | ||
} | ||
return writer.String(), nil | ||
} |
18 changes: 18 additions & 0 deletions
18
services/notifications/pkg/email/templates/shareCreated.email.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Hello {{ .ShareGrantee }}, | ||
|
||
{{ .ShareSharer }} has shared {{ .ShareFolder }} with you. | ||
|
||
Click here to view it: {{ .ShareLink }} | ||
|
||
---------------------------------------------------------- | ||
|
||
Hallo {{ .Grantee }}, | ||
|
||
{{ .ShareSharer }} hat dich zu {{ .ShareFolder }} eingeladen. | ||
|
||
Klicke hier zum Anzeigen: {{ .ShareLink }} | ||
|
||
|
||
--- | ||
ownCloud - Store. Share. Work. | ||
https://owncloud.com |
18 changes: 18 additions & 0 deletions
18
services/notifications/pkg/email/templates/sharedSpace.email.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Hello {{ .SpaceGrantee }}, | ||
|
||
{{ .SpaceSharer }} has invited you to join {{ .SpaceName }}. | ||
|
||
Click here to view it: {{ .ShareLink }} | ||
|
||
---------------------------------------------------------- | ||
|
||
Hallo {{ .SpaceGrantee }}, | ||
|
||
{{ .SpaceSharer }} hat dich in den Space {{ .SpaceName }} eingeladen. | ||
|
||
Klicke hier zum Anzeigen: {{ .ShareLink }} | ||
|
||
|
||
--- | ||
ownCloud - Store. Share. Work. | ||
https://owncloud.com |
Oops, something went wrong.