PLT-7 adding loc for db calls audits and prefs
Этот коммит содержится в:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/go-gorp/gorp"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
goi18n "github.com/nicksnyder/go-i18n/i18n"
|
||||
)
|
||||
|
||||
type SqlPreferenceStore struct {
|
||||
@@ -41,7 +42,7 @@ func (s SqlPreferenceStore) CreateIndexesIfNotExists() {
|
||||
s.CreateIndexIfNotExists("idx_preferences_name", "Preferences", "Name")
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) DeleteUnusedFeatures() {
|
||||
func (s SqlPreferenceStore) DeleteUnusedFeatures(T goi18n.TranslateFunc) {
|
||||
l4g.Debug("Deleting any unused pre-release features")
|
||||
|
||||
sql := `DELETE
|
||||
@@ -58,7 +59,7 @@ func (s SqlPreferenceStore) DeleteUnusedFeatures() {
|
||||
s.GetMaster().Exec(sql, queryParams)
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel {
|
||||
func (s SqlPreferenceStore) Save(T goi18n.TranslateFunc, preferences *model.Preferences) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -70,7 +71,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel {
|
||||
result.Err = model.NewAppError("SqlPreferenceStore.Save", "Unable to open transaction to save preferences", err.Error())
|
||||
} else {
|
||||
for _, preference := range *preferences {
|
||||
if upsertResult := s.save(transaction, &preference); upsertResult.Err != nil {
|
||||
if upsertResult := s.save(T, transaction, &preference); upsertResult.Err != nil {
|
||||
result = upsertResult
|
||||
break
|
||||
}
|
||||
@@ -97,7 +98,7 @@ func (s SqlPreferenceStore) Save(preferences *model.Preferences) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
func (s SqlPreferenceStore) save(T goi18n.TranslateFunc, transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
result := StoreResult{}
|
||||
|
||||
if result.Err = preference.IsValid(); result.Err != nil {
|
||||
@@ -139,9 +140,9 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode
|
||||
}
|
||||
|
||||
if count == 1 {
|
||||
s.update(transaction, preference)
|
||||
s.update(T, transaction, preference)
|
||||
} else {
|
||||
s.insert(transaction, preference)
|
||||
s.insert(T, transaction, preference)
|
||||
}
|
||||
} else {
|
||||
result.Err = model.NewAppError("SqlPreferenceStore.save", "We encountered an error while updating preferences",
|
||||
@@ -151,7 +152,7 @@ func (s SqlPreferenceStore) save(transaction *gorp.Transaction, preference *mode
|
||||
return result
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) insert(transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
func (s SqlPreferenceStore) insert(T goi18n.TranslateFunc, transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
result := StoreResult{}
|
||||
|
||||
if err := transaction.Insert(preference); err != nil {
|
||||
@@ -167,7 +168,7 @@ func (s SqlPreferenceStore) insert(transaction *gorp.Transaction, preference *mo
|
||||
return result
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) update(transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
func (s SqlPreferenceStore) update(T goi18n.TranslateFunc, transaction *gorp.Transaction, preference *model.Preference) StoreResult {
|
||||
result := StoreResult{}
|
||||
|
||||
if _, err := transaction.Update(preference); err != nil {
|
||||
@@ -178,7 +179,7 @@ func (s SqlPreferenceStore) update(transaction *gorp.Transaction, preference *mo
|
||||
return result
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) Get(userId string, category string, name string) StoreChannel {
|
||||
func (s SqlPreferenceStore) Get(T goi18n.TranslateFunc, userId string, category string, name string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -207,7 +208,7 @@ func (s SqlPreferenceStore) Get(userId string, category string, name string) Sto
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) GetCategory(userId string, category string) StoreChannel {
|
||||
func (s SqlPreferenceStore) GetCategory(T goi18n.TranslateFunc, userId string, category string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -235,7 +236,7 @@ func (s SqlPreferenceStore) GetCategory(userId string, category string) StoreCha
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) GetAll(userId string) StoreChannel {
|
||||
func (s SqlPreferenceStore) GetAll(T goi18n.TranslateFunc, userId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -262,7 +263,7 @@ func (s SqlPreferenceStore) GetAll(userId string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) PermanentDeleteByUser(userId string) StoreChannel {
|
||||
func (s SqlPreferenceStore) PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
@@ -280,7 +281,7 @@ func (s SqlPreferenceStore) PermanentDeleteByUser(userId string) StoreChannel {
|
||||
return storeChannel
|
||||
}
|
||||
|
||||
func (s SqlPreferenceStore) IsFeatureEnabled(feature, userId string) StoreChannel {
|
||||
func (s SqlPreferenceStore) IsFeatureEnabled(T goi18n.TranslateFunc, feature, userId string) StoreChannel {
|
||||
storeChannel := make(StoreChannel)
|
||||
|
||||
go func() {
|
||||
|
||||
Ссылка в новой задаче
Block a user