-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Grouped email notifications #10838
Merged
Merged
Grouped email notifications #10838
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
db3d49a
feat: Add cli command to trigger grouped emails
bastianbeier 151c9cc
fix: Default value for email sending interval
bastianbeier 9af84f0
feat: Send emails when retrieval of setting fails
bastianbeier 9849e74
feat: Persist events for grouped emails based on settings
bastianbeier 6566192
feat: Add job to create grouped email on event
bastianbeier 5f1b193
refactor: Remove unused struct field
bastianbeier 7697e6d
refactor: Use zerolog.Logger instead of log.Logger
bastianbeier 6c2ab07
docs: Add changelog and readme entry
bastianbeier 8e89a34
fix: Missing return statement after error on getting service user con…
bastianbeier 4b76453
refactor: Make sonar happy
bastianbeier 34e74e4
docs: Improve readme for grouped email notifications
bastianbeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
changelog/unreleased/enhancement-mail-notifications-grouping.md
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,6 @@ | ||
Enhancement: Part IV: Grouping of mail notifications | ||
|
||
Part IV: Mail notifications can now be grouped on a daily or weekly basis | ||
|
||
https://github.com/owncloud/ocis/pull/10838 | ||
https://github.com/owncloud/ocis/issues/10793 |
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,57 @@ | ||
package command | ||
|
||
import ( | ||
"github.com/cs3org/reva/v2/pkg/events" | ||
"github.com/cs3org/reva/v2/pkg/events/stream" | ||
"github.com/owncloud/ocis/v2/services/notifications/pkg/config" | ||
"github.com/pkg/errors" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
// SendEmail triggers the sending of grouped email notifications for daily or weekly emails. | ||
func SendEmail(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "send-email", | ||
Usage: "Send grouped email notifications with daily or weekly interval. Specify at least one of the flags '--daily' or '--weekly'.", | ||
Flags: []cli.Flag{ | ||
&cli.BoolFlag{ | ||
Name: "daily", | ||
Aliases: []string{"d"}, | ||
Usage: "Sends grouped daily email notifications.", | ||
}, | ||
&cli.BoolFlag{ | ||
Name: "weekly", | ||
Aliases: []string{"w"}, | ||
Usage: "Sends grouped weekly email notifications.", | ||
}, | ||
}, | ||
Action: func(c *cli.Context) error { | ||
daily := c.Bool("daily") | ||
weekly := c.Bool("weekly") | ||
if !daily && !weekly { | ||
return errors.New("at least one of '--daily' or '--weekly' must be set") | ||
} | ||
s, err := stream.NatsFromConfig(cfg.Service.Name, false, stream.NatsConfig(cfg.Notifications.Events)) | ||
if err != nil { | ||
return err | ||
} | ||
if daily { | ||
err = events.Publish(c.Context, s, events.SendEmailsEvent{ | ||
Interval: "daily", | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
if weekly { | ||
err = events.Publish(c.Context, s, events.SendEmailsEvent{ | ||
Interval: "weekly", | ||
}) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does weekly mean in this context? I'd expect notifications with a creation date within the "last 7 days" / last 168 hours!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
daily
andweekly
are just groups. You can trigger the sending of a group using thenotifications send-email --daily
ornotifications send-email --weekly
cli command.You could also trigger the weekly job every 4 days or every 8 days but you have to consider the TTL of the events in the store when triggering not that often.