* [MM-45564] - Notify Admin v2

* add dummy data

* update dummy data

* add store methods

* experiment with recurring task

* complete saving of the notification

* make improvements

* make improvements

* add store layer tests

* fix lint

* update store layer tests

* add app layer unit tests

* add store layers

* add app layer tests

* fix lint

* fix lint

* fix tests

* fix tests lint

* fix lint

* fix lint

* fix retry layer test

* add notifications manual trigger

* filter notifications based on current plan

* add test case

* temp change

* feedback impl

* fix translations

* change job scheduler

* refactor job

* fix store layer tests

* extract i18n

* fix lint

* fix translations

* fix translations

* add license statement for new file

* feedback impl-2

* fix lint

* update make file

* add intl ids

* improve

* fix lint

* feedback impl

* move code and rename files

* fix lint

* feedback impl

* add config for trigger notifications api

* fix tests

* tmp change

* undo temp changes

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Allan Guwatudde
2022-09-02 13:52:48 +03:00
коммит произвёл GitHub
родитель c11ad8995f
Коммит bd42f0cd8c
39 изменённых файлов: 1789 добавлений и 278 удалений

Просмотреть файл

@@ -32,6 +32,7 @@ type TimerLayer struct {
JobStore store.JobStore
LicenseStore store.LicenseStore
LinkMetadataStore store.LinkMetadataStore
NotifyAdminStore store.NotifyAdminStore
OAuthStore store.OAuthStore
PluginStore store.PluginStore
PostStore store.PostStore
@@ -113,6 +114,10 @@ func (s *TimerLayer) LinkMetadata() store.LinkMetadataStore {
return s.LinkMetadataStore
}
func (s *TimerLayer) NotifyAdmin() store.NotifyAdminStore {
return s.NotifyAdminStore
}
func (s *TimerLayer) OAuth() store.OAuthStore {
return s.OAuthStore
}
@@ -275,6 +280,11 @@ type TimerLayerLinkMetadataStore struct {
Root *TimerLayer
}
type TimerLayerNotifyAdminStore struct {
store.NotifyAdminStore
Root *TimerLayer
}
type TimerLayerOAuthStore struct {
store.OAuthStore
Root *TimerLayer
@@ -4507,6 +4517,70 @@ func (s *TimerLayerLinkMetadataStore) Save(linkMetadata *model.LinkMetadata) (*m
return result, err
}
func (s *TimerLayerNotifyAdminStore) DeleteBefore(trial bool, now int64) error {
start := time.Now()
err := s.NotifyAdminStore.DeleteBefore(trial, now)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("NotifyAdminStore.DeleteBefore", success, elapsed)
}
return err
}
func (s *TimerLayerNotifyAdminStore) Get(trial bool) ([]*model.NotifyAdminData, error) {
start := time.Now()
result, err := s.NotifyAdminStore.Get(trial)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("NotifyAdminStore.Get", success, elapsed)
}
return result, err
}
func (s *TimerLayerNotifyAdminStore) GetDataByUserIdAndFeature(userId string, feature model.MattermostPaidFeature) ([]*model.NotifyAdminData, error) {
start := time.Now()
result, err := s.NotifyAdminStore.GetDataByUserIdAndFeature(userId, feature)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("NotifyAdminStore.GetDataByUserIdAndFeature", success, elapsed)
}
return result, err
}
func (s *TimerLayerNotifyAdminStore) Save(data *model.NotifyAdminData) (*model.NotifyAdminData, error) {
start := time.Now()
result, err := s.NotifyAdminStore.Save(data)
elapsed := float64(time.Since(start)) / float64(time.Second)
if s.Root.Metrics != nil {
success := "false"
if err == nil {
success = "true"
}
s.Root.Metrics.ObserveStoreMethodDuration("NotifyAdminStore.Save", success, elapsed)
}
return result, err
}
func (s *TimerLayerOAuthStore) DeleteApp(id string) error {
start := time.Now()
@@ -11112,6 +11186,7 @@ func New(childStore store.Store, metrics einterfaces.MetricsInterface) *TimerLay
newStore.JobStore = &TimerLayerJobStore{JobStore: childStore.Job(), Root: &newStore}
newStore.LicenseStore = &TimerLayerLicenseStore{LicenseStore: childStore.License(), Root: &newStore}
newStore.LinkMetadataStore = &TimerLayerLinkMetadataStore{LinkMetadataStore: childStore.LinkMetadata(), Root: &newStore}
newStore.NotifyAdminStore = &TimerLayerNotifyAdminStore{NotifyAdminStore: childStore.NotifyAdmin(), Root: &newStore}
newStore.OAuthStore = &TimerLayerOAuthStore{OAuthStore: childStore.OAuth(), Root: &newStore}
newStore.PluginStore = &TimerLayerPluginStore{PluginStore: childStore.Plugin(), Root: &newStore}
newStore.PostStore = &TimerLayerPostStore{PostStore: childStore.Post(), Root: &newStore}