Tracking Push Notifications in a structured logger (notifications.log) (#10823)
* Remove NotificationRegistry table and use structured logging * Fix ackId for notification sent * Notification logger at server level * Remove unused i18n strings
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
30061df036
Коммит
5b252e8736
106
model/config.go
106
model/config.go
@@ -912,6 +912,46 @@ func (s *LogSettings) SetDefaults() {
|
||||
}
|
||||
}
|
||||
|
||||
type NotificationLogSettings struct {
|
||||
EnableConsole *bool `restricted:"true"`
|
||||
ConsoleLevel *string `restricted:"true"`
|
||||
ConsoleJson *bool `restricted:"true"`
|
||||
EnableFile *bool `restricted:"true"`
|
||||
FileLevel *string `restricted:"true"`
|
||||
FileJson *bool `restricted:"true"`
|
||||
FileLocation *string `restricted:"true"`
|
||||
}
|
||||
|
||||
func (s *NotificationLogSettings) SetDefaults() {
|
||||
if s.EnableConsole == nil {
|
||||
s.EnableConsole = NewBool(true)
|
||||
}
|
||||
|
||||
if s.ConsoleLevel == nil {
|
||||
s.ConsoleLevel = NewString("DEBUG")
|
||||
}
|
||||
|
||||
if s.EnableFile == nil {
|
||||
s.EnableFile = NewBool(true)
|
||||
}
|
||||
|
||||
if s.FileLevel == nil {
|
||||
s.FileLevel = NewString("INFO")
|
||||
}
|
||||
|
||||
if s.FileLocation == nil {
|
||||
s.FileLocation = NewString("")
|
||||
}
|
||||
|
||||
if s.ConsoleJson == nil {
|
||||
s.ConsoleJson = NewBool(true)
|
||||
}
|
||||
|
||||
if s.FileJson == nil {
|
||||
s.FileJson = NewBool(true)
|
||||
}
|
||||
}
|
||||
|
||||
type PasswordSettings struct {
|
||||
MinimumLength *int
|
||||
Lowercase *bool
|
||||
@@ -2241,38 +2281,39 @@ func (ips *ImageProxySettings) SetDefaults(ss ServiceSettings) {
|
||||
type ConfigFunc func() *Config
|
||||
|
||||
type Config struct {
|
||||
ServiceSettings ServiceSettings
|
||||
TeamSettings TeamSettings
|
||||
ClientRequirements ClientRequirements
|
||||
SqlSettings SqlSettings
|
||||
LogSettings LogSettings
|
||||
PasswordSettings PasswordSettings
|
||||
FileSettings FileSettings
|
||||
EmailSettings EmailSettings
|
||||
RateLimitSettings RateLimitSettings
|
||||
PrivacySettings PrivacySettings
|
||||
SupportSettings SupportSettings
|
||||
AnnouncementSettings AnnouncementSettings
|
||||
ThemeSettings ThemeSettings
|
||||
GitLabSettings SSOSettings
|
||||
GoogleSettings SSOSettings
|
||||
Office365Settings SSOSettings
|
||||
LdapSettings LdapSettings
|
||||
ComplianceSettings ComplianceSettings
|
||||
LocalizationSettings LocalizationSettings
|
||||
SamlSettings SamlSettings
|
||||
NativeAppSettings NativeAppSettings
|
||||
ClusterSettings ClusterSettings
|
||||
MetricsSettings MetricsSettings
|
||||
ExperimentalSettings ExperimentalSettings
|
||||
AnalyticsSettings AnalyticsSettings
|
||||
ElasticsearchSettings ElasticsearchSettings
|
||||
DataRetentionSettings DataRetentionSettings
|
||||
MessageExportSettings MessageExportSettings
|
||||
JobSettings JobSettings
|
||||
PluginSettings PluginSettings
|
||||
DisplaySettings DisplaySettings
|
||||
ImageProxySettings ImageProxySettings
|
||||
ServiceSettings ServiceSettings
|
||||
TeamSettings TeamSettings
|
||||
ClientRequirements ClientRequirements
|
||||
SqlSettings SqlSettings
|
||||
LogSettings LogSettings
|
||||
NotificationLogSettings NotificationLogSettings
|
||||
PasswordSettings PasswordSettings
|
||||
FileSettings FileSettings
|
||||
EmailSettings EmailSettings
|
||||
RateLimitSettings RateLimitSettings
|
||||
PrivacySettings PrivacySettings
|
||||
SupportSettings SupportSettings
|
||||
AnnouncementSettings AnnouncementSettings
|
||||
ThemeSettings ThemeSettings
|
||||
GitLabSettings SSOSettings
|
||||
GoogleSettings SSOSettings
|
||||
Office365Settings SSOSettings
|
||||
LdapSettings LdapSettings
|
||||
ComplianceSettings ComplianceSettings
|
||||
LocalizationSettings LocalizationSettings
|
||||
SamlSettings SamlSettings
|
||||
NativeAppSettings NativeAppSettings
|
||||
ClusterSettings ClusterSettings
|
||||
MetricsSettings MetricsSettings
|
||||
ExperimentalSettings ExperimentalSettings
|
||||
AnalyticsSettings AnalyticsSettings
|
||||
ElasticsearchSettings ElasticsearchSettings
|
||||
DataRetentionSettings DataRetentionSettings
|
||||
MessageExportSettings MessageExportSettings
|
||||
JobSettings JobSettings
|
||||
PluginSettings PluginSettings
|
||||
DisplaySettings DisplaySettings
|
||||
ImageProxySettings ImageProxySettings
|
||||
}
|
||||
|
||||
func (o *Config) Clone() *Config {
|
||||
@@ -2344,6 +2385,7 @@ func (o *Config) SetDefaults() {
|
||||
o.DataRetentionSettings.SetDefaults()
|
||||
o.RateLimitSettings.SetDefaults()
|
||||
o.LogSettings.SetDefaults()
|
||||
o.NotificationLogSettings.SetDefaults()
|
||||
o.JobSettings.SetDefaults()
|
||||
o.MessageExportSettings.SetDefaults()
|
||||
o.DisplaySettings.SetDefaults()
|
||||
|
||||
@@ -6,7 +6,6 @@ package model
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -26,22 +25,12 @@ const (
|
||||
|
||||
MHPNS = "https://push.mattermost.com"
|
||||
|
||||
PUSH_SEND_PREPARE = "Prepared to send"
|
||||
PUSH_SEND_SUCCESS = "Successful"
|
||||
PUSH_SEND_ERROR = "Error"
|
||||
PUSH_NOT_SENT = "Not Sent due to preferences"
|
||||
PUSH_RECEIVED = "Received by device"
|
||||
)
|
||||
|
||||
type NotificationRegistry struct {
|
||||
AckId string
|
||||
CreateAt int64
|
||||
UserId string
|
||||
DeviceId string
|
||||
PostId string
|
||||
SendStatus string
|
||||
Type string
|
||||
ReceiveAt int64
|
||||
}
|
||||
|
||||
type PushNotificationAck struct {
|
||||
Id string `json:"id"`
|
||||
ClientReceivedAt int64 `json:"received_at"`
|
||||
@@ -104,44 +93,3 @@ func (ack *PushNotificationAck) ToJson() string {
|
||||
b, _ := json.Marshal(ack)
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func (o *NotificationRegistry) IsValid() *AppError {
|
||||
|
||||
if len(o.AckId) != 26 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.ack_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if o.CreateAt == 0 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.create_at.app_error", nil, "AckId="+o.AckId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.UserId) != 26 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.user_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.PostId) > 0 && len(o.PostId) != 26 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.post_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.DeviceId) > 512 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.device_id.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if len(o.SendStatus) > 4096 {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.status.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if o.Type != PUSH_TYPE_CLEAR && o.Type != PUSH_TYPE_MESSAGE {
|
||||
return NewAppError("NotificationRegistry.IsValid", "model.notification_registry.type.app_error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *NotificationRegistry) PreSave() {
|
||||
if o.AckId == "" {
|
||||
o.AckId = NewId()
|
||||
}
|
||||
|
||||
o.CreateAt = GetMillis()
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user