Enforce use of any instead of interface{} (#30588)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9aa4818c71
Коммит
166a676fe5
@@ -46,7 +46,7 @@ func NewFromAPI(api common.LogAPI, dmer poster.DMer, logLevel logger.LogLevel, i
|
||||
return New(logger.New(api), dmer, logLevel, includeContext, userIDs...)
|
||||
}
|
||||
|
||||
func (l *adminCCLogger) Debugf(format string, args ...interface{}) {
|
||||
func (l *adminCCLogger) Debugf(format string, args ...any) {
|
||||
l.Logger.Debugf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 4 {
|
||||
@@ -54,7 +54,7 @@ func (l *adminCCLogger) Debugf(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *adminCCLogger) Errorf(format string, args ...interface{}) {
|
||||
func (l *adminCCLogger) Errorf(format string, args ...any) {
|
||||
l.Logger.Errorf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 1 {
|
||||
@@ -62,7 +62,7 @@ func (l *adminCCLogger) Errorf(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *adminCCLogger) Infof(format string, args ...interface{}) {
|
||||
func (l *adminCCLogger) Infof(format string, args ...any) {
|
||||
l.Logger.Infof(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 3 {
|
||||
@@ -70,7 +70,7 @@ func (l *adminCCLogger) Infof(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *adminCCLogger) Warnf(format string, args ...interface{}) {
|
||||
func (l *adminCCLogger) Warnf(format string, args ...any) {
|
||||
l.Logger.Warnf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 2 {
|
||||
@@ -86,7 +86,7 @@ func (l *adminCCLogger) logToAdmins(level, message string) {
|
||||
_ = l.dmAdmins("(log " + level + ") " + message)
|
||||
}
|
||||
|
||||
func (l *adminCCLogger) dmAdmins(format string, args ...interface{}) error {
|
||||
func (l *adminCCLogger) dmAdmins(format string, args ...any) error {
|
||||
for _, id := range l.userIDs {
|
||||
_, err := l.dmer.DM(id, format, args)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,7 +30,7 @@ func New(api common.LogAPI) Logger {
|
||||
func (l *defaultLogger) With(logContext LogContext) Logger {
|
||||
newLogger := *l
|
||||
if len(newLogger.logContext) == 0 {
|
||||
newLogger.logContext = map[string]interface{}{}
|
||||
newLogger.logContext = map[string]any{}
|
||||
}
|
||||
for k, v := range logContext {
|
||||
newLogger.logContext[k] = v
|
||||
@@ -41,7 +41,7 @@ func (l *defaultLogger) With(logContext LogContext) Logger {
|
||||
func (l *defaultLogger) WithError(err error) Logger {
|
||||
newLogger := *l
|
||||
if len(newLogger.logContext) == 0 {
|
||||
newLogger.logContext = map[string]interface{}{}
|
||||
newLogger.logContext = map[string]any{}
|
||||
}
|
||||
newLogger.logContext[ErrorKey] = err.Error()
|
||||
return &newLogger
|
||||
@@ -57,25 +57,25 @@ func (l *defaultLogger) Timed() Logger {
|
||||
})
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Debugf(format string, args ...interface{}) {
|
||||
func (l *defaultLogger) Debugf(format string, args ...any) {
|
||||
measure(l.logContext)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
l.logAPI.LogDebug(message, toKeyValuePairs(l.logContext)...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Errorf(format string, args ...interface{}) {
|
||||
func (l *defaultLogger) Errorf(format string, args ...any) {
|
||||
measure(l.logContext)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
l.logAPI.LogError(message, toKeyValuePairs(l.logContext)...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Infof(format string, args ...interface{}) {
|
||||
func (l *defaultLogger) Infof(format string, args ...any) {
|
||||
measure(l.logContext)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
l.logAPI.LogInfo(message, toKeyValuePairs(l.logContext)...)
|
||||
}
|
||||
|
||||
func (l *defaultLogger) Warnf(format string, args ...interface{}) {
|
||||
func (l *defaultLogger) Warnf(format string, args ...any) {
|
||||
measure(l.logContext)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
l.logAPI.LogWarn(message, toKeyValuePairs(l.logContext)...)
|
||||
|
||||
@@ -24,7 +24,7 @@ const (
|
||||
)
|
||||
|
||||
// LogContext defines the context for the logs.
|
||||
type LogContext map[string]interface{}
|
||||
type LogContext map[string]any
|
||||
|
||||
// Logger defines an object able to log messages.
|
||||
type Logger interface {
|
||||
@@ -37,13 +37,13 @@ type Logger interface {
|
||||
// Timed add a timed log context.
|
||||
Timed() Logger
|
||||
// Debugf logs a formatted string as a debug message.
|
||||
Debugf(format string, args ...interface{})
|
||||
Debugf(format string, args ...any)
|
||||
// Errorf logs a formatted string as an error message.
|
||||
Errorf(format string, args ...interface{})
|
||||
Errorf(format string, args ...any)
|
||||
// Infof logs a formatted string as an info message.
|
||||
Infof(format string, args ...interface{})
|
||||
Infof(format string, args ...any)
|
||||
// Warnf logs a formatted string as an warning message.
|
||||
Warnf(format string, args ...interface{})
|
||||
Warnf(format string, args ...any)
|
||||
}
|
||||
|
||||
func measure(lc LogContext) {
|
||||
@@ -70,7 +70,7 @@ func Level(l LogLevel) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func toKeyValuePairs(in map[string]interface{}) (out []interface{}) {
|
||||
func toKeyValuePairs(in map[string]any) (out []any) {
|
||||
for k, v := range in {
|
||||
out = append(out, k, v)
|
||||
}
|
||||
|
||||
@@ -7,11 +7,11 @@ func NewNilLogger() Logger {
|
||||
return &nilLogger{}
|
||||
}
|
||||
|
||||
func (l *nilLogger) With(LogContext) Logger { return l }
|
||||
func (l *nilLogger) WithError(error) Logger { return l }
|
||||
func (l *nilLogger) Context() LogContext { return nil }
|
||||
func (l *nilLogger) Timed() Logger { return l }
|
||||
func (l *nilLogger) Debugf(string, ...interface{}) {}
|
||||
func (l *nilLogger) Errorf(string, ...interface{}) {}
|
||||
func (l *nilLogger) Infof(string, ...interface{}) {}
|
||||
func (l *nilLogger) Warnf(string, ...interface{}) {}
|
||||
func (l *nilLogger) With(LogContext) Logger { return l }
|
||||
func (l *nilLogger) WithError(error) Logger { return l }
|
||||
func (l *nilLogger) Context() LogContext { return nil }
|
||||
func (l *nilLogger) Timed() Logger { return l }
|
||||
func (l *nilLogger) Debugf(string, ...any) {}
|
||||
func (l *nilLogger) Errorf(string, ...any) {}
|
||||
func (l *nilLogger) Infof(string, ...any) {}
|
||||
func (l *nilLogger) Warnf(string, ...any) {}
|
||||
|
||||
@@ -37,7 +37,7 @@ func NewFromAPI(api common.LogAPI, logLevel logger.LogLevel, tracker telemetry.T
|
||||
return New(logger.New(api), logLevel, tracker)
|
||||
}
|
||||
|
||||
func (l *telemetryLogger) Debugf(format string, args ...interface{}) {
|
||||
func (l *telemetryLogger) Debugf(format string, args ...any) {
|
||||
l.Logger.Debugf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 4 {
|
||||
@@ -45,7 +45,7 @@ func (l *telemetryLogger) Debugf(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *telemetryLogger) Errorf(format string, args ...interface{}) {
|
||||
func (l *telemetryLogger) Errorf(format string, args ...any) {
|
||||
l.Logger.Errorf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 1 {
|
||||
@@ -53,7 +53,7 @@ func (l *telemetryLogger) Errorf(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *telemetryLogger) Infof(format string, args ...interface{}) {
|
||||
func (l *telemetryLogger) Infof(format string, args ...any) {
|
||||
l.Logger.Infof(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 3 {
|
||||
@@ -61,7 +61,7 @@ func (l *telemetryLogger) Infof(format string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (l *telemetryLogger) Warnf(format string, args ...interface{}) {
|
||||
func (l *telemetryLogger) Warnf(format string, args ...any) {
|
||||
l.Logger.Warnf(format, args...)
|
||||
message := fmt.Sprintf(format, args...)
|
||||
if logger.Level(l.logLevel) >= 2 {
|
||||
@@ -70,7 +70,7 @@ func (l *telemetryLogger) Warnf(format string, args ...interface{}) {
|
||||
}
|
||||
|
||||
func (l *telemetryLogger) logToTelemetry(level, message string) {
|
||||
properties := map[string]interface{}{}
|
||||
properties := map[string]any{}
|
||||
properties["message"] = message
|
||||
for k, v := range l.Context() {
|
||||
properties["context_"+k] = fmt.Sprintf("%v", v)
|
||||
|
||||
@@ -19,7 +19,7 @@ func NewTestLogger() Logger {
|
||||
func (l *testLogger) With(logContext LogContext) Logger {
|
||||
newl := *l
|
||||
if len(newl.logContext) == 0 {
|
||||
newl.logContext = map[string]interface{}{}
|
||||
newl.logContext = map[string]any{}
|
||||
}
|
||||
for k, v := range logContext {
|
||||
newl.logContext[k] = v
|
||||
@@ -30,7 +30,7 @@ func (l *testLogger) With(logContext LogContext) Logger {
|
||||
func (l *testLogger) WithError(err error) Logger {
|
||||
newl := *l
|
||||
if len(newl.logContext) == 0 {
|
||||
newl.logContext = map[string]interface{}{}
|
||||
newl.logContext = map[string]any{}
|
||||
}
|
||||
newl.logContext[ErrorKey] = err.Error()
|
||||
return &newl
|
||||
@@ -46,7 +46,7 @@ func (l *testLogger) Timed() Logger {
|
||||
})
|
||||
}
|
||||
|
||||
func (l *testLogger) logf(prefix, format string, args ...interface{}) {
|
||||
func (l *testLogger) logf(prefix, format string, args ...any) {
|
||||
out := fmt.Sprintf(prefix+": "+format, args...)
|
||||
if len(l.logContext) > 0 {
|
||||
measure(l.logContext)
|
||||
@@ -55,7 +55,7 @@ func (l *testLogger) logf(prefix, format string, args ...interface{}) {
|
||||
l.TB.Log(out)
|
||||
}
|
||||
|
||||
func (l *testLogger) Debugf(format string, args ...interface{}) { l.logf("DEBUG", format, args...) }
|
||||
func (l *testLogger) Errorf(format string, args ...interface{}) { l.logf("ERROR", format, args...) }
|
||||
func (l *testLogger) Infof(format string, args ...interface{}) { l.logf("INFO", format, args...) }
|
||||
func (l *testLogger) Warnf(format string, args ...interface{}) { l.logf("WARN", format, args...) }
|
||||
func (l *testLogger) Debugf(format string, args ...any) { l.logf("DEBUG", format, args...) }
|
||||
func (l *testLogger) Errorf(format string, args ...any) { l.logf("ERROR", format, args...) }
|
||||
func (l *testLogger) Infof(format string, args ...any) { l.logf("INFO", format, args...) }
|
||||
func (l *testLogger) Warnf(format string, args ...any) { l.logf("WARN", format, args...) }
|
||||
|
||||
@@ -20,7 +20,7 @@ func NewPoster(postAPI PostAPI, id string) Poster {
|
||||
}
|
||||
|
||||
// DM posts a simple Direct Message to the specified user
|
||||
func (p *defaultPoster) DM(mattermostUserID, format string, args ...interface{}) (string, error) {
|
||||
func (p *defaultPoster) DM(mattermostUserID, format string, args ...any) (string, error) {
|
||||
post := &model.Post{
|
||||
Message: fmt.Sprintf(format, args...),
|
||||
}
|
||||
@@ -44,7 +44,7 @@ func (p *defaultPoster) DMWithAttachments(mattermostUserID string, attachments .
|
||||
}
|
||||
|
||||
// Ephemeral sends an ephemeral message to a user
|
||||
func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...interface{}) {
|
||||
func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...any) {
|
||||
post := &model.Post{
|
||||
UserId: p.id,
|
||||
ChannelId: channelID,
|
||||
@@ -53,7 +53,7 @@ func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...inte
|
||||
p.postAPI.SendEphemeralPost(userID, post)
|
||||
}
|
||||
|
||||
func (p *defaultPoster) UpdatePostByID(postID, format string, args ...interface{}) error {
|
||||
func (p *defaultPoster) UpdatePostByID(postID, format string, args ...any) error {
|
||||
post, err := p.postAPI.GetPost(postID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -30,7 +30,7 @@ func TestInterface(t *testing.T) {
|
||||
|
||||
func TestDM(t *testing.T) {
|
||||
format := "test format, string: %s int: %d value: %v"
|
||||
args := []interface{}{"some string", 5, 8.423}
|
||||
args := []any{"some string", 5, 8.423}
|
||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||
|
||||
expectedPostID := "expected-post-id"
|
||||
@@ -153,7 +153,7 @@ func TestDMWithAttachments(t *testing.T) {
|
||||
|
||||
func TestEphemeral(t *testing.T) {
|
||||
format := "test format, string: %s int: %d value: %v"
|
||||
args := []interface{}{"some string", 5, 8.423}
|
||||
args := []any{"some string", 5, 8.423}
|
||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||
|
||||
channelID := "some-channel"
|
||||
@@ -194,7 +194,7 @@ func TestEphemeral(t *testing.T) {
|
||||
|
||||
func TestUpdatePostByID(t *testing.T) {
|
||||
format := "test format, string: %s int: %d value: %v"
|
||||
args := []interface{}{"some string", 5, 8.423}
|
||||
args := []any{"some string", 5, 8.423}
|
||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||
|
||||
postID := "some-post-id"
|
||||
@@ -364,7 +364,7 @@ func TestUpdatePost(t *testing.T) {
|
||||
|
||||
func TestUpdatePosterID(t *testing.T) {
|
||||
format := "test format, string: %s int: %d value: %v"
|
||||
args := []interface{}{"some string", 5, 8.423}
|
||||
args := []any{"some string", 5, 8.423}
|
||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||
|
||||
expectedPostID := "expected-post-id"
|
||||
|
||||
@@ -16,10 +16,10 @@ type Poster interface {
|
||||
DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error)
|
||||
|
||||
// Ephemeral sends an ephemeral message to a user
|
||||
Ephemeral(mattermostUserID, channelID, format string, args ...interface{})
|
||||
Ephemeral(mattermostUserID, channelID, format string, args ...any)
|
||||
|
||||
// UpdatePostByID updates the post with postID with the formatted message
|
||||
UpdatePostByID(postID, format string, args ...interface{}) error
|
||||
UpdatePostByID(postID, format string, args ...any) error
|
||||
|
||||
// DeletePost deletes a single post
|
||||
DeletePost(postID string) error
|
||||
@@ -34,5 +34,5 @@ type Poster interface {
|
||||
// DMer defines an entity that can send Direct Messages
|
||||
type DMer interface {
|
||||
// DM posts a simple Direct Message to the specified user
|
||||
DM(mattermostUserID, format string, args ...interface{}) (string, error)
|
||||
DM(mattermostUserID, format string, args ...any) (string, error)
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
var ErrNotFound = errors.New("not found")
|
||||
|
||||
type KVStore interface {
|
||||
Set(key string, value interface{}, options ...pluginapi.KVSetOption) (bool, error)
|
||||
Get(key string, o interface{}) error
|
||||
Set(key string, value any, options ...pluginapi.KVSetOption) (bool, error)
|
||||
Get(key string, o any) error
|
||||
Delete(key string) error
|
||||
DeleteAll() error
|
||||
ListKeys(page, count int, options ...pluginapi.ListKeysOption) ([]string, error)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package common
|
||||
|
||||
type LogAPI interface {
|
||||
LogError(message string, keyValuePairs ...interface{})
|
||||
LogWarn(message string, keyValuePairs ...interface{})
|
||||
LogInfo(message string, keyValuePairs ...interface{})
|
||||
LogDebug(message string, keyValuePairs ...interface{})
|
||||
LogError(message string, keyValuePairs ...any)
|
||||
LogWarn(message string, keyValuePairs ...any)
|
||||
LogInfo(message string, keyValuePairs ...any)
|
||||
LogDebug(message string, keyValuePairs ...any)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func JSON(ref interface{}) string {
|
||||
func JSON(ref any) string {
|
||||
bb, _ := json.MarshalIndent(ref, "", " ")
|
||||
return string(bb)
|
||||
}
|
||||
@@ -17,6 +17,6 @@ func CodeBlock(in string) string {
|
||||
return fmt.Sprintf("\n```\n%s\n```\n", in)
|
||||
}
|
||||
|
||||
func JSONBlock(ref interface{}) string {
|
||||
func JSONBlock(ref any) string {
|
||||
return fmt.Sprintf("\n```json\n%s\n```\n", JSON(ref))
|
||||
}
|
||||
|
||||
@@ -259,8 +259,8 @@ func Goto(toName Name) func(*Flow) (Name, State, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func DialogGoto(toName Name) func(*Flow, map[string]interface{}) (Name, State, map[string]string, error) {
|
||||
return func(_ *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error) {
|
||||
func DialogGoto(toName Name) func(*Flow, map[string]any) (Name, State, map[string]string, error) {
|
||||
return func(_ *Flow, submitted map[string]any) (Name, State, map[string]string, error) {
|
||||
stateUpdate := State{}
|
||||
for k, v := range submitted {
|
||||
stateUpdate[k] = fmt.Sprintf("%v", v)
|
||||
|
||||
@@ -97,7 +97,7 @@ func (f *Flow) handleButton(fromName Name, selectedButton int, triggerID string)
|
||||
}
|
||||
|
||||
func (f *Flow) handleDialog(
|
||||
fromName Name, selectedButton int, submission map[string]interface{},
|
||||
fromName Name, selectedButton int, submission map[string]any,
|
||||
) (
|
||||
*model.Post, map[string]string, error,
|
||||
) {
|
||||
@@ -105,7 +105,7 @@ func (f *Flow) handleDialog(
|
||||
}
|
||||
|
||||
func (f *Flow) handle(
|
||||
fromName Name, selectedButton int, submission map[string]interface{}, triggerID string, asButton bool,
|
||||
fromName Name, selectedButton int, submission map[string]any, triggerID string, asButton bool,
|
||||
) (
|
||||
*model.Post, map[string]string, error,
|
||||
) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
var errStateNotFound = errors.New("flow state not found")
|
||||
|
||||
// State is the "app"'s state
|
||||
type State map[string]interface{}
|
||||
type State map[string]any
|
||||
|
||||
func (s State) MergeWith(update State) State {
|
||||
n := State{}
|
||||
|
||||
@@ -50,7 +50,7 @@ type Button struct {
|
||||
// Function that is called when the dialog box is submitted. It can return a
|
||||
// general error, or field-specific errors. On success it returns the name
|
||||
// of the next step, and the state updates to apply.
|
||||
OnDialogSubmit func(f *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error)
|
||||
OnDialogSubmit func(f *Flow, submitted map[string]any) (Name, State, map[string]string, error)
|
||||
}
|
||||
|
||||
func NewStep(name Name) Step {
|
||||
@@ -229,7 +229,7 @@ func renderButton(b Button, stepName Name, i int, state State) *model.PostAction
|
||||
Disabled: b.Disabled,
|
||||
Style: string(b.Color),
|
||||
Integration: &model.PostActionIntegration{
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
contextStepKey: string(stepName),
|
||||
contextButtonKey: strconv.Itoa(i),
|
||||
},
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
type Panel interface {
|
||||
Set(userID, settingID string, value interface{}) error
|
||||
Set(userID, settingID string, value any) error
|
||||
Print(userID string)
|
||||
ToPost(userID string) (*model.Post, error)
|
||||
Clear(userID string) error
|
||||
@@ -57,7 +57,7 @@ func NewSettingsPanel(
|
||||
return panel
|
||||
}
|
||||
|
||||
func (p *panel) Set(userID, settingID string, value interface{}) error {
|
||||
func (p *panel) Set(userID, settingID string, value any) error {
|
||||
s, ok := p.settings[settingID]
|
||||
if !ok {
|
||||
return errors.New("cannot find setting " + settingID)
|
||||
|
||||
@@ -23,6 +23,6 @@ func (s *baseSetting) GetDependency() string {
|
||||
return s.dependsOn
|
||||
}
|
||||
|
||||
func (s *baseSetting) IsDisabled(foreignValue interface{}) bool {
|
||||
func (s *baseSetting) IsDisabled(foreignValue any) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewBoolSetting(id, title, description, dependsOn string, store SettingStore
|
||||
}
|
||||
}
|
||||
|
||||
func (s *boolSetting) Set(userID string, value interface{}) error {
|
||||
func (s *boolSetting) Set(userID string, value any) error {
|
||||
boolValue := false
|
||||
if value == TrueString {
|
||||
boolValue = true
|
||||
@@ -39,7 +39,7 @@ func (s *boolSetting) Set(userID string, value interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *boolSetting) Get(userID string) (interface{}, error) {
|
||||
func (s *boolSetting) Get(userID string) (any, error) {
|
||||
value, err := s.store.GetSetting(userID, s.id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -79,7 +79,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
||||
Name: "Yes",
|
||||
Integration: &model.PostActionIntegration{
|
||||
URL: settingHandler,
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
ContextIDKey: s.id,
|
||||
ContextButtonValueKey: TrueString,
|
||||
},
|
||||
@@ -91,7 +91,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
||||
Name: "No",
|
||||
Integration: &model.PostActionIntegration{
|
||||
URL: settingHandler,
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
ContextIDKey: s.id,
|
||||
ContextButtonValueKey: FalseString,
|
||||
},
|
||||
@@ -111,6 +111,6 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
||||
return &sa, nil
|
||||
}
|
||||
|
||||
func (s *boolSetting) IsDisabled(foreignValue interface{}) bool {
|
||||
func (s *boolSetting) IsDisabled(foreignValue any) bool {
|
||||
return foreignValue == FalseString
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ func (s *emptySetting) GetSlackAttachments(userID, settingHandler string, disabl
|
||||
return &sa, nil
|
||||
}
|
||||
|
||||
func (s *emptySetting) Get(userID string) (interface{}, error) {
|
||||
func (s *emptySetting) Get(userID string) (any, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *emptySetting) Set(userID string, value interface{}) error {
|
||||
func (s *emptySetting) Set(userID string, value any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewOptionSetting(id, title, description, dependsOn string, options []string
|
||||
}
|
||||
}
|
||||
|
||||
func (s *optionSetting) Set(userID string, value interface{}) error {
|
||||
func (s *optionSetting) Set(userID string, value any) error {
|
||||
err := s.store.SetSetting(userID, s.id, value)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -36,7 +36,7 @@ func (s *optionSetting) Set(userID string, value interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *optionSetting) Get(userID string) (interface{}, error) {
|
||||
func (s *optionSetting) Get(userID string) (any, error) {
|
||||
value, err := s.store.GetSetting(userID, s.id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -66,7 +66,7 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab
|
||||
Name: "Select an option:",
|
||||
Integration: &model.PostActionIntegration{
|
||||
URL: settingHandler + "?" + s.id + "=true",
|
||||
Context: map[string]interface{}{
|
||||
Context: map[string]any{
|
||||
ContextIDKey: s.id,
|
||||
},
|
||||
},
|
||||
@@ -86,6 +86,6 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab
|
||||
return &sa, nil
|
||||
}
|
||||
|
||||
func (s *optionSetting) IsDisabled(foreignValue interface{}) bool {
|
||||
func (s *optionSetting) IsDisabled(foreignValue any) bool {
|
||||
return foreignValue == FalseString
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewReadOnlySetting(id, title, description, dependsOn string, store SettingS
|
||||
}
|
||||
}
|
||||
|
||||
func (s *readOnlySetting) Get(userID string) (interface{}, error) {
|
||||
func (s *readOnlySetting) Get(userID string) (any, error) {
|
||||
value, err := s.store.GetSetting(userID, s.id)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -38,7 +38,7 @@ func (s *readOnlySetting) Get(userID string) (interface{}, error) {
|
||||
return stringValue, nil
|
||||
}
|
||||
|
||||
func (s *readOnlySetting) Set(userID string, value interface{}) error {
|
||||
func (s *readOnlySetting) Set(userID string, value any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -64,6 +64,6 @@ func (s *readOnlySetting) GetSlackAttachments(userID, settingHandler string, dis
|
||||
return &sa, nil
|
||||
}
|
||||
|
||||
func (s *readOnlySetting) IsDisabled(foreignValue interface{}) bool {
|
||||
func (s *readOnlySetting) IsDisabled(foreignValue any) bool {
|
||||
return foreignValue == FalseString
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ const (
|
||||
|
||||
// Setting defines the behavior of each element a the panel
|
||||
type Setting interface {
|
||||
Set(userID string, value interface{}) error
|
||||
Get(userID string) (interface{}, error)
|
||||
Set(userID string, value any) error
|
||||
Get(userID string) (any, error)
|
||||
GetID() string
|
||||
GetDependency() string
|
||||
IsDisabled(foreignValue interface{}) bool
|
||||
IsDisabled(foreignValue any) bool
|
||||
GetTitle() string
|
||||
GetDescription() string
|
||||
GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error)
|
||||
|
||||
@@ -2,6 +2,6 @@ package settings
|
||||
|
||||
// SettingStore defines the behavior needed to set and get settings
|
||||
type SettingStore interface {
|
||||
SetSetting(userID, settingID string, value interface{}) error
|
||||
GetSetting(userID, settingID string) (interface{}, error)
|
||||
SetSetting(userID, settingID string, value any) error
|
||||
GetSetting(userID, settingID string) (any, error)
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ func NewTrackerConfig(config *model.Config) TrackerConfig {
|
||||
// Tracker defines a telemetry tracker
|
||||
type Tracker interface {
|
||||
// TrackEvent registers an event through the configured telemetry client
|
||||
TrackEvent(event string, properties map[string]interface{}) error
|
||||
TrackEvent(event string, properties map[string]any) error
|
||||
// TrackUserEvent registers an event through the configured telemetry client associated to a user
|
||||
TrackUserEvent(event string, userID string, properties map[string]interface{}) error
|
||||
TrackUserEvent(event string, userID string, properties map[string]any) error
|
||||
// Reload Config re-evaluates tracker config to determine if tracking behavior should change
|
||||
ReloadConfig(config TrackerConfig)
|
||||
}
|
||||
@@ -58,7 +58,7 @@ type Client interface {
|
||||
type Track struct {
|
||||
UserID string
|
||||
Event string
|
||||
Properties map[string]interface{}
|
||||
Properties map[string]any
|
||||
InstallationID string
|
||||
}
|
||||
|
||||
@@ -126,14 +126,14 @@ func (t *tracker) ReloadConfig(config TrackerConfig) {
|
||||
}
|
||||
|
||||
// Note that config lock is handled by the caller.
|
||||
func (t *tracker) debugf(message string, args ...interface{}) {
|
||||
func (t *tracker) debugf(message string, args ...any) {
|
||||
if t.logger == nil || !t.config.EnabledLogging {
|
||||
return
|
||||
}
|
||||
t.logger.Debugf(message, args...)
|
||||
}
|
||||
|
||||
func (t *tracker) TrackEvent(event string, properties map[string]interface{}) error {
|
||||
func (t *tracker) TrackEvent(event string, properties map[string]any) error {
|
||||
t.configLock.RLock()
|
||||
defer t.configLock.RUnlock()
|
||||
|
||||
@@ -144,7 +144,7 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er
|
||||
}
|
||||
|
||||
if properties == nil {
|
||||
properties = map[string]interface{}{}
|
||||
properties = map[string]any{}
|
||||
}
|
||||
properties["PluginID"] = t.pluginID
|
||||
properties["PluginVersion"] = t.pluginVersion
|
||||
@@ -169,9 +169,9 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *tracker) TrackUserEvent(event, userID string, properties map[string]interface{}) error {
|
||||
func (t *tracker) TrackUserEvent(event, userID string, properties map[string]any) error {
|
||||
if properties == nil {
|
||||
properties = map[string]interface{}{}
|
||||
properties = map[string]any{}
|
||||
}
|
||||
|
||||
properties["UserActualID"] = userID
|
||||
|
||||
Ссылка в новой задаче
Block a user