* [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 удалений

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

@@ -4,8 +4,6 @@
package model
import (
"os"
"strconv"
"strings"
)
@@ -42,9 +40,6 @@ const (
SubscriptionFamilyOnPrem = SubscriptionFamily("on-prem")
)
const defaultCloudNotifyAdminCoolOffDays = 30
const CloudNotifyAdminInfo = "cloud_notify_admin_info"
// Product model represents a product on the cloud system.
type Product struct {
ID string `json:"id"`
@@ -258,23 +253,3 @@ type ProductLimits struct {
Messages *MessagesLimits `json:"messages,omitempty"`
Teams *TeamsLimits `json:"teams,omitempty"`
}
type NotifyAdminToUpgradeRequest struct {
CurrentTeamId string `json:"current_team_id"`
}
type AdminNotificationUserInfo struct {
LastUserIDToNotify string
LastNotificationTimestamp int64
}
func CanNotify(lastNotificationTimestamp int64) bool {
coolOffPeriodDaysEnv := os.Getenv("MM_CLOUD_NOTIFY_ADMIN_COOL_OFF_DAYS")
coolOffPeriodDays, parseError := strconv.ParseFloat(coolOffPeriodDaysEnv, 64)
if parseError != nil {
coolOffPeriodDays = defaultCloudNotifyAdminCoolOffDays
}
daysToMillis := coolOffPeriodDays * 24 * 60 * 60 * 1000
timeDiff := GetMillis() - lastNotificationTimestamp
return timeDiff >= int64(daysToMillis)
}