generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into daily-summary-batch
- Loading branch information
Showing
5 changed files
with
52 additions
and
114 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
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,42 @@ | ||
// Copyright (c) 2019-present Mattermost, Inc. All Rights Reserved. | ||
// See License for license information. | ||
|
||
package jobs | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/mattermost/mattermost-plugin-mscalendar/server/mscalendar" | ||
) | ||
|
||
// Unique id for the daily summary job | ||
const dailySummaryJobID = "daily_summary" | ||
|
||
const dailySummaryJobInterval = mscalendar.DailySummaryJobInterval | ||
|
||
// NewDailySummaryJob creates a RegisteredJob with the parameters specific to the DailySummaryJob | ||
func NewDailySummaryJob() RegisteredJob { | ||
return RegisteredJob{ | ||
id: dailySummaryJobID, | ||
interval: dailySummaryJobInterval, | ||
work: runDailySummaryJob, | ||
isEnabledByConfig: isDailySummaryJobEnabled, | ||
} | ||
} | ||
|
||
// runDailySummaryJob delivers the daily calendar summary to all users who have their settings configured to receive it now | ||
func runDailySummaryJob(env mscalendar.Env) { | ||
env.Logger.Debugf("Daily summary job beginning") | ||
|
||
err := mscalendar.New(env, "").ProcessAllDailySummary(time.Now()) | ||
if err != nil { | ||
env.Logger.Errorf("Error during daily summary job", "error", err.Error()) | ||
} | ||
|
||
env.Logger.Debugf("Daily summary job finished") | ||
} | ||
|
||
// isDailySummaryJobEnabled uses current config to determine whether the job is enabled. | ||
func isDailySummaryJobEnabled(env mscalendar.Env) bool { | ||
return env.EnableDailySummary | ||
} |
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 was deleted.
Oops, something went wrong.
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