summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-01-20 13:12:19 -0600
committerCorey Hulen <corey@hulen.com>2016-01-20 13:12:19 -0600
commit0b1aff3b24b4ac2df8e963c83d6e52b127c603f9 (patch)
tree47735a3dd609e025837df4460b0d030454358cf1 /store
parent1acd38b7b19521d06d274c42c00ce7072cd92196 (diff)
parent75f8729e2d25467500778e633c45c97e78a8f7a0 (diff)
downloadchat-0b1aff3b24b4ac2df8e963c83d6e52b127c603f9.tar.gz
chat-0b1aff3b24b4ac2df8e963c83d6e52b127c603f9.tar.bz2
chat-0b1aff3b24b4ac2df8e963c83d6e52b127c603f9.zip
Merge pull request #1930 from mattermost/PLT-7-server-db
PLT-7 adding loc for db calls
Diffstat (limited to 'store')
-rw-r--r--store/sql_audit_store.go7
-rw-r--r--store/sql_audit_store_test.go15
-rw-r--r--store/sql_channel_store.go83
-rw-r--r--store/sql_channel_store_test.go215
-rw-r--r--store/sql_oauth_store.go25
-rw-r--r--store/sql_oauth_store_test.go45
-rw-r--r--store/sql_post_store.go53
-rw-r--r--store/sql_post_store_test.go236
-rw-r--r--store/sql_preference_store.go27
-rw-r--r--store/sql_preference_store_test.go43
-rw-r--r--store/sql_session_store.go23
-rw-r--r--store/sql_session_store_test.go53
-rw-r--r--store/sql_store.go12
-rw-r--r--store/sql_system_store.go7
-rw-r--r--store/sql_system_store_test.go9
-rw-r--r--store/sql_team_store.go21
-rw-r--r--store/sql_team_store_test.go65
-rw-r--r--store/sql_user_store.go46
-rw-r--r--store/sql_user_store_test.go113
-rw-r--r--store/sql_webhook_store.go29
-rw-r--r--store/sql_webhook_store_test.go81
-rw-r--r--store/store.go242
22 files changed, 736 insertions, 714 deletions
diff --git a/store/sql_audit_store.go b/store/sql_audit_store.go
index f4fd29aab..720e4f483 100644
--- a/store/sql_audit_store.go
+++ b/store/sql_audit_store.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlAuditStore struct {
@@ -34,7 +35,7 @@ func (s SqlAuditStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_audits_user_id", "Audits", "UserId")
}
-func (s SqlAuditStore) Save(audit *model.Audit) StoreChannel {
+func (s SqlAuditStore) Save(T goi18n.TranslateFunc, audit *model.Audit) StoreChannel {
storeChannel := make(StoreChannel)
@@ -57,7 +58,7 @@ func (s SqlAuditStore) Save(audit *model.Audit) StoreChannel {
return storeChannel
}
-func (s SqlAuditStore) Get(user_id string, limit int) StoreChannel {
+func (s SqlAuditStore) Get(T goi18n.TranslateFunc, user_id string, limit int) StoreChannel {
storeChannel := make(StoreChannel)
@@ -87,7 +88,7 @@ func (s SqlAuditStore) Get(user_id string, limit int) StoreChannel {
return storeChannel
}
-func (s SqlAuditStore) PermanentDeleteByUser(userId string) StoreChannel {
+func (s SqlAuditStore) PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/sql_audit_store_test.go b/store/sql_audit_store_test.go
index b395631f1..55147ad6f 100644
--- a/store/sql_audit_store_test.go
+++ b/store/sql_audit_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
"time"
)
@@ -13,19 +14,19 @@ func TestSqlAuditStore(t *testing.T) {
Setup()
audit := &model.Audit{UserId: model.NewId(), IpAddress: "ipaddress", Action: "Action"}
- Must(store.Audit().Save(audit))
+ Must(store.Audit().Save(utils.T, audit))
time.Sleep(100 * time.Millisecond)
- Must(store.Audit().Save(audit))
+ Must(store.Audit().Save(utils.T, audit))
time.Sleep(100 * time.Millisecond)
- Must(store.Audit().Save(audit))
+ Must(store.Audit().Save(utils.T, audit))
time.Sleep(100 * time.Millisecond)
audit.ExtraInfo = "extra"
time.Sleep(100 * time.Millisecond)
- Must(store.Audit().Save(audit))
+ Must(store.Audit().Save(utils.T, audit))
time.Sleep(100 * time.Millisecond)
- c := store.Audit().Get(audit.UserId, 100)
+ c := store.Audit().Get(utils.T, audit.UserId, 100)
result := <-c
audits := result.Data.(model.Audits)
@@ -37,7 +38,7 @@ func TestSqlAuditStore(t *testing.T) {
t.Fatal("Failed to save property for extra info")
}
- c = store.Audit().Get("missing", 100)
+ c = store.Audit().Get(utils.T, "missing", 100)
result = <-c
audits = result.Data.(model.Audits)
@@ -45,7 +46,7 @@ func TestSqlAuditStore(t *testing.T) {
t.Fatal("Should have returned empty because user_id is missing")
}
- if r2 := <-store.Audit().PermanentDeleteByUser(audit.UserId); r2.Err != nil {
+ if r2 := <-store.Audit().PermanentDeleteByUser(utils.T, audit.UserId); r2.Err != nil {
t.Fatal(r2.Err)
}
}
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 4585647de..d85969b21 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -7,6 +7,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 SqlChannelStore struct {
@@ -49,7 +50,7 @@ func (s SqlChannelStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_channelmembers_user_id", "ChannelMembers", "UserId")
}
-func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel {
+func (s SqlChannelStore) Save(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -60,7 +61,7 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel {
if transaction, err := s.GetMaster().Begin(); err != nil {
result.Err = model.NewAppError("SqlChannelStore.Save", "Unable to open transaction", err.Error())
} else {
- result = s.saveChannelT(transaction, channel)
+ result = s.saveChannelT(T, transaction, channel)
if result.Err != nil {
transaction.Rollback()
} else {
@@ -78,7 +79,7 @@ func (s SqlChannelStore) Save(channel *model.Channel) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel {
+func (s SqlChannelStore) SaveDirectChannel(T goi18n.TranslateFunc, directchannel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -90,7 +91,7 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
if transaction, err := s.GetMaster().Begin(); err != nil {
result.Err = model.NewAppError("SqlChannelStore.SaveDirectChannel", "Unable to open transaction", err.Error())
} else {
- channelResult := s.saveChannelT(transaction, directchannel)
+ channelResult := s.saveChannelT(T, transaction, directchannel)
if channelResult.Err != nil {
transaction.Rollback()
@@ -101,8 +102,8 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
member1.ChannelId = newChannel.Id
member2.ChannelId = newChannel.Id
- member1Result := s.saveMemberT(transaction, member1, newChannel)
- member2Result := s.saveMemberT(transaction, member2, newChannel)
+ member1Result := s.saveMemberT(T, transaction, member1, newChannel)
+ member2Result := s.saveMemberT(T, transaction, member2, newChannel)
if member1Result.Err != nil || member2Result.Err != nil {
transaction.Rollback()
@@ -132,7 +133,7 @@ func (s SqlChannelStore) SaveDirectChannel(directchannel *model.Channel, member1
return storeChannel
}
-func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *model.Channel) StoreResult {
+func (s SqlChannelStore) saveChannelT(T goi18n.TranslateFunc, transaction *gorp.Transaction, channel *model.Channel) StoreResult {
result := StoreResult{}
if len(channel.Id) > 0 {
@@ -174,7 +175,7 @@ func (s SqlChannelStore) saveChannelT(transaction *gorp.Transaction, channel *mo
return result
}
-func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel {
+func (s SqlChannelStore) Update(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel {
storeChannel := make(StoreChannel)
@@ -214,7 +215,7 @@ func (s SqlChannelStore) Update(channel *model.Channel) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel {
+func (s SqlChannelStore) extraUpdated(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -242,15 +243,15 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) Get(id string) StoreChannel {
- return s.get(id, false)
+func (s SqlChannelStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
+ return s.get(T, id, false)
}
-func (s SqlChannelStore) GetFromMaster(id string) StoreChannel {
- return s.get(id, true)
+func (s SqlChannelStore) GetFromMaster(T goi18n.TranslateFunc, id string) StoreChannel {
+ return s.get(T, id, true)
}
-func (s SqlChannelStore) get(id string, master bool) StoreChannel {
+func (s SqlChannelStore) get(T goi18n.TranslateFunc, id string, master bool) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -278,7 +279,7 @@ func (s SqlChannelStore) get(id string, master bool) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel {
+func (s SqlChannelStore) Delete(T goi18n.TranslateFunc, channelId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -296,7 +297,7 @@ func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) PermanentDeleteByTeam(teamId string) StoreChannel {
+func (s SqlChannelStore) PermanentDeleteByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -318,7 +319,7 @@ type channelWithMember struct {
model.ChannelMember
}
-func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel {
+func (s SqlChannelStore) GetChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -351,7 +352,7 @@ func (s SqlChannelStore) GetChannels(teamId string, userId string) StoreChannel
return storeChannel
}
-func (s SqlChannelStore) GetMoreChannels(teamId string, userId string) StoreChannel {
+func (s SqlChannelStore) GetMoreChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -399,7 +400,7 @@ type channelIdWithCountAndUpdateAt struct {
UpdateAt int64
}
-func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreChannel {
+func (s SqlChannelStore) GetChannelCounts(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -428,7 +429,7 @@ func (s SqlChannelStore) GetChannelCounts(teamId string, userId string) StoreCha
return storeChannel
}
-func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel {
+func (s SqlChannelStore) GetByName(T goi18n.TranslateFunc, teamId string, name string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -449,13 +450,13 @@ func (s SqlChannelStore) GetByName(teamId string, name string) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel {
+func (s SqlChannelStore) SaveMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
var result StoreResult
// Grab the channel we are saving this member to
- if cr := <-s.GetFromMaster(member.ChannelId); cr.Err != nil {
+ if cr := <-s.GetFromMaster(T, member.ChannelId); cr.Err != nil {
result.Err = cr.Err
} else {
channel := cr.Data.(*model.Channel)
@@ -463,7 +464,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel {
if transaction, err := s.GetMaster().Begin(); err != nil {
result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to open transaction", err.Error())
} else {
- result = s.saveMemberT(transaction, member, channel)
+ result = s.saveMemberT(T, transaction, member, channel)
if result.Err != nil {
transaction.Rollback()
} else {
@@ -471,7 +472,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel {
result.Err = model.NewAppError("SqlChannelStore.SaveMember", "Unable to commit transaction", err.Error())
}
// If sucessfull record members have changed in channel
- if mu := <-s.extraUpdated(channel); mu.Err != nil {
+ if mu := <-s.extraUpdated(T, channel); mu.Err != nil {
result.Err = mu.Err
}
}
@@ -485,7 +486,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *model.ChannelMember, channel *model.Channel) StoreResult {
+func (s SqlChannelStore) saveMemberT(T goi18n.TranslateFunc, transaction *gorp.Transaction, member *model.ChannelMember, channel *model.Channel) StoreResult {
result := StoreResult{}
member.PreSave()
@@ -506,7 +507,7 @@ func (s SqlChannelStore) saveMemberT(transaction *gorp.Transaction, member *mode
return result
}
-func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel {
+func (s SqlChannelStore) UpdateMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -534,7 +535,7 @@ func (s SqlChannelStore) UpdateMember(member *model.ChannelMember) StoreChannel
return storeChannel
}
-func (s SqlChannelStore) GetMembers(channelId string) StoreChannel {
+func (s SqlChannelStore) GetMembers(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -555,7 +556,7 @@ func (s SqlChannelStore) GetMembers(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel {
+func (s SqlChannelStore) GetMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -576,7 +577,7 @@ func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel
return storeChannel
}
-func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel {
+func (s SqlChannelStore) GetMemberCount(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -596,7 +597,7 @@ func (s SqlChannelStore) GetMemberCount(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChannel {
+func (s SqlChannelStore) GetExtraMembers(T goi18n.TranslateFunc, channelId string, limit int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -627,14 +628,14 @@ func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChann
return storeChannel
}
-func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChannel {
+func (s SqlChannelStore) RemoveMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
// Grab the channel we are saving this member to
- if cr := <-s.Get(channelId); cr.Err != nil {
+ if cr := <-s.Get(T, channelId); cr.Err != nil {
result.Err = cr.Err
} else {
channel := cr.Data.(*model.Channel)
@@ -644,7 +645,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChan
result.Err = model.NewAppError("SqlChannelStore.RemoveMember", "We couldn't remove the channel member", "channel_id="+channelId+", user_id="+userId+", "+err.Error())
} else {
// If sucessfull record members have changed in channel
- if mu := <-s.extraUpdated(channel); mu.Err != nil {
+ if mu := <-s.extraUpdated(T, channel); mu.Err != nil {
result.Err = mu.Err
}
}
@@ -657,7 +658,7 @@ func (s SqlChannelStore) RemoveMember(channelId string, userId string) StoreChan
return storeChannel
}
-func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) StoreChannel {
+func (s SqlChannelStore) PermanentDeleteMembersByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -674,7 +675,7 @@ func (s SqlChannelStore) PermanentDeleteMembersByUser(userId string) StoreChanne
return storeChannel
}
-func (s SqlChannelStore) CheckPermissionsTo(teamId string, channelId string, userId string) StoreChannel {
+func (s SqlChannelStore) CheckPermissionsTo(T goi18n.TranslateFunc, teamId string, channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -706,7 +707,7 @@ func (s SqlChannelStore) CheckPermissionsTo(teamId string, channelId string, use
return storeChannel
}
-func (s SqlChannelStore) CheckPermissionsToByName(teamId string, channelName string, userId string) StoreChannel {
+func (s SqlChannelStore) CheckPermissionsToByName(T goi18n.TranslateFunc, teamId string, channelName string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -738,7 +739,7 @@ func (s SqlChannelStore) CheckPermissionsToByName(teamId string, channelName str
return storeChannel
}
-func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId string) StoreChannel {
+func (s SqlChannelStore) CheckOpenChannelPermissions(T goi18n.TranslateFunc, teamId string, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -767,7 +768,7 @@ func (s SqlChannelStore) CheckOpenChannelPermissions(teamId string, channelId st
return storeChannel
}
-func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) StoreChannel {
+func (s SqlChannelStore) UpdateLastViewedAt(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -815,7 +816,7 @@ func (s SqlChannelStore) UpdateLastViewedAt(channelId string, userId string) Sto
return storeChannel
}
-func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string) StoreChannel {
+func (s SqlChannelStore) IncrementMentionCount(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -841,7 +842,7 @@ func (s SqlChannelStore) IncrementMentionCount(channelId string, userId string)
return storeChannel
}
-func (s SqlChannelStore) GetForExport(teamId string) StoreChannel {
+func (s SqlChannelStore) GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -863,7 +864,7 @@ func (s SqlChannelStore) GetForExport(teamId string) StoreChannel {
return storeChannel
}
-func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) StoreChannel {
+func (s SqlChannelStore) AnalyticsTypeCount(T goi18n.TranslateFunc, teamId string, channelType string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 8b22fbb7a..079fab92b 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
"time"
)
@@ -20,23 +21,23 @@ func TestChannelStoreSave(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- if err := (<-store.Channel().Save(&o1)).Err; err != nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
- if err := (<-store.Channel().Save(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
o1.Id = ""
- if err := (<-store.Channel().Save(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("should be unique name")
}
o1.Id = ""
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_DIRECT
- if err := (<-store.Channel().Save(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("Should not be able to save direct channel")
}
@@ -44,14 +45,14 @@ func TestChannelStoreSave(t *testing.T) {
for i := 0; i < 1000; i++ {
o1.Id = ""
o1.Name = "a" + model.NewId() + "b"
- if err := (<-store.Channel().Save(&o1)).Err; err != nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
}
o1.Id = ""
o1.Name = "a" + model.NewId() + "b"
- if err := (<-store.Channel().Save(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("should be the limit")
}
}
@@ -71,13 +72,13 @@ func TestChannelStoreSaveDirectChannel(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
@@ -89,23 +90,23 @@ func TestChannelStoreSaveDirectChannel(t *testing.T) {
m2.UserId = u2.Id
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- if err := (<-store.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err != nil {
+ if err := (<-store.Channel().SaveDirectChannel(utils.T, &o1, &m1, &m2)).Err; err != nil {
t.Fatal("couldn't save direct channel", err)
}
- members := (<-store.Channel().GetMembers(o1.Id)).Data.([]model.ChannelMember)
+ members := (<-store.Channel().GetMembers(utils.T, o1.Id)).Data.([]model.ChannelMember)
if len(members) != 2 {
t.Fatal("should have saved 2 members")
}
- if err := (<-store.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err == nil {
+ if err := (<-store.Channel().SaveDirectChannel(utils.T, &o1, &m1, &m2)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
o1.Id = ""
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- if err := (<-store.Channel().SaveDirectChannel(&o1, &m1, &m2)).Err; err == nil {
+ if err := (<-store.Channel().SaveDirectChannel(utils.T, &o1, &m1, &m2)).Err; err == nil {
t.Fatal("Should not be able to save non-direct channel")
}
@@ -120,23 +121,23 @@ func TestChannelStoreUpdate(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- if err := (<-store.Channel().Save(&o1)).Err; err != nil {
+ if err := (<-store.Channel().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)
- if err := (<-store.Channel().Update(&o1)).Err; err != nil {
+ if err := (<-store.Channel().Update(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
o1.Id = "missing"
- if err := (<-store.Channel().Update(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have failed because of missing key")
}
o1.Id = model.NewId()
- if err := (<-store.Channel().Update(&o1)).Err; err == nil {
+ if err := (<-store.Channel().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have faile because id change")
}
}
@@ -149,9 +150,9 @@ func TestChannelStoreGet(t *testing.T) {
o1.DisplayName = "Name"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
- if r1 := <-store.Channel().Get(o1.Id); r1.Err != nil {
+ if r1 := <-store.Channel().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Channel).ToJson() != o1.ToJson() {
@@ -159,7 +160,7 @@ func TestChannelStoreGet(t *testing.T) {
}
}
- if err := (<-store.Channel().Get("")).Err; err == nil {
+ if err := (<-store.Channel().Get(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
@@ -167,13 +168,13 @@ func TestChannelStoreGet(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o2 := model.Channel{}
o2.TeamId = model.NewId()
@@ -191,9 +192,9 @@ func TestChannelStoreGet(t *testing.T) {
m2.UserId = u2.Id
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveDirectChannel(&o2, &m1, &m2))
+ Must(store.Channel().SaveDirectChannel(utils.T, &o2, &m1, &m2))
- if r2 := <-store.Channel().Get(o2.Id); r2.Err != nil {
+ if r2 := <-store.Channel().Get(utils.T, o2.Id); r2.Err != nil {
t.Fatal(r2.Err)
} else {
if r2.Data.(*model.Channel).ToJson() != o2.ToJson() {
@@ -210,61 +211,61 @@ func TestChannelStoreDelete(t *testing.T) {
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
o2 := model.Channel{}
o2.TeamId = o1.TeamId
o2.DisplayName = "Channel2"
o2.Name = "a" + model.NewId() + "b"
o2.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o2))
+ Must(store.Channel().Save(utils.T, &o2))
o3 := model.Channel{}
o3.TeamId = o1.TeamId
o3.DisplayName = "Channel3"
o3.Name = "a" + model.NewId() + "b"
o3.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o3))
+ Must(store.Channel().Save(utils.T, &o3))
o4 := model.Channel{}
o4.TeamId = o1.TeamId
o4.DisplayName = "Channel4"
o4.Name = "a" + model.NewId() + "b"
o4.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o4))
+ Must(store.Channel().Save(utils.T, &o4))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
m2 := model.ChannelMember{}
m2.ChannelId = o2.Id
m2.UserId = m1.UserId
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m2))
+ Must(store.Channel().SaveMember(utils.T, &m2))
- if r := <-store.Channel().Delete(o1.Id, model.GetMillis()); r.Err != nil {
+ if r := <-store.Channel().Delete(utils.T, o1.Id, model.GetMillis()); r.Err != nil {
t.Fatal(r.Err)
}
- if r := <-store.Channel().Get(o1.Id); r.Data.(*model.Channel).DeleteAt == 0 {
+ if r := <-store.Channel().Get(utils.T, o1.Id); r.Data.(*model.Channel).DeleteAt == 0 {
t.Fatal("should have been deleted")
}
- if r := <-store.Channel().Delete(o3.Id, model.GetMillis()); r.Err != nil {
+ if r := <-store.Channel().Delete(utils.T, o3.Id, model.GetMillis()); r.Err != nil {
t.Fatal(r.Err)
}
- cresult := <-store.Channel().GetChannels(o1.TeamId, m1.UserId)
+ cresult := <-store.Channel().GetChannels(utils.T, o1.TeamId, m1.UserId)
list := cresult.Data.(*model.ChannelList)
if len(list.Channels) != 1 {
t.Fatal("invalid number of channels")
}
- cresult = <-store.Channel().GetMoreChannels(o1.TeamId, m1.UserId)
+ cresult = <-store.Channel().GetMoreChannels(utils.T, o1.TeamId, m1.UserId)
list = cresult.Data.(*model.ChannelList)
if len(list.Channels) != 1 {
@@ -280,9 +281,9 @@ func TestChannelStoreGetByName(t *testing.T) {
o1.DisplayName = "Name"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
- if r1 := <-store.Channel().GetByName(o1.TeamId, o1.Name); r1.Err != nil {
+ if r1 := <-store.Channel().GetByName(utils.T, o1.TeamId, o1.Name); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Channel).ToJson() != o1.ToJson() {
@@ -290,7 +291,7 @@ func TestChannelStoreGetByName(t *testing.T) {
}
}
- if err := (<-store.Channel().GetByName(o1.TeamId, "")).Err; err == nil {
+ if err := (<-store.Channel().GetByName(utils.T, o1.TeamId, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -303,76 +304,76 @@ func TestChannelMemberStore(t *testing.T) {
c1.DisplayName = "NameName"
c1.Name = "a" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
- c1 = *Must(store.Channel().Save(&c1)).(*model.Channel)
+ c1 = *Must(store.Channel().Save(utils.T, &c1)).(*model.Channel)
- c1t1 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t1 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t1 := c1t1.ExtraUpdateAt
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
o1.UserId = u1.Id
o1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&o1))
+ Must(store.Channel().SaveMember(utils.T, &o1))
o2 := model.ChannelMember{}
o2.ChannelId = c1.Id
o2.UserId = u2.Id
o2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&o2))
+ Must(store.Channel().SaveMember(utils.T, &o2))
- c1t2 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t2 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t2 := c1t2.ExtraUpdateAt
if t2 <= t1 {
t.Fatal("Member update time incorrect")
}
- count := (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ count := (<-store.Channel().GetMemberCount(utils.T, o1.ChannelId)).Data.(int64)
if count != 2 {
t.Fatal("should have saved 2 members")
}
- Must(store.Channel().RemoveMember(o2.ChannelId, o2.UserId))
+ Must(store.Channel().RemoveMember(utils.T, o2.ChannelId, o2.UserId))
- count = (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ count = (<-store.Channel().GetMemberCount(utils.T, o1.ChannelId)).Data.(int64)
if count != 1 {
t.Fatal("should have removed 1 member")
}
- c1t3 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t3 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t3 := c1t3.ExtraUpdateAt
if t3 <= t2 || t3 <= t1 {
t.Fatal("Member update time incorrect on delete")
}
- member := (<-store.Channel().GetMember(o1.ChannelId, o1.UserId)).Data.(model.ChannelMember)
+ member := (<-store.Channel().GetMember(utils.T, o1.ChannelId, o1.UserId)).Data.(model.ChannelMember)
if member.ChannelId != o1.ChannelId {
t.Fatal("should have go member")
}
- extraMembers := (<-store.Channel().GetExtraMembers(o1.ChannelId, 20)).Data.([]model.ExtraMember)
+ extraMembers := (<-store.Channel().GetExtraMembers(utils.T, o1.ChannelId, 20)).Data.([]model.ExtraMember)
if len(extraMembers) != 1 {
t.Fatal("should have 1 extra members")
}
- if err := (<-store.Channel().SaveMember(&o1)).Err; err == nil {
+ if err := (<-store.Channel().SaveMember(utils.T, &o1)).Err; err == nil {
t.Fatal("Should have been a duplicate")
}
- c1t4 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t4 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t4 := c1t4.ExtraUpdateAt
if t4 != t3 {
t.Fatal("Should not update time upon failure")
@@ -387,50 +388,50 @@ func TestChannelDeleteMemberStore(t *testing.T) {
c1.DisplayName = "NameName"
c1.Name = "a" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
- c1 = *Must(store.Channel().Save(&c1)).(*model.Channel)
+ c1 = *Must(store.Channel().Save(utils.T, &c1)).(*model.Channel)
- c1t1 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t1 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t1 := c1t1.ExtraUpdateAt
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Nickname = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = model.NewId()
u2.Email = model.NewId()
u2.Nickname = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
o1 := model.ChannelMember{}
o1.ChannelId = c1.Id
o1.UserId = u1.Id
o1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&o1))
+ Must(store.Channel().SaveMember(utils.T, &o1))
o2 := model.ChannelMember{}
o2.ChannelId = c1.Id
o2.UserId = u2.Id
o2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&o2))
+ Must(store.Channel().SaveMember(utils.T, &o2))
- c1t2 := (<-store.Channel().Get(c1.Id)).Data.(*model.Channel)
+ c1t2 := (<-store.Channel().Get(utils.T, c1.Id)).Data.(*model.Channel)
t2 := c1t2.ExtraUpdateAt
if t2 <= t1 {
t.Fatal("Member update time incorrect")
}
- count := (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ count := (<-store.Channel().GetMemberCount(utils.T, o1.ChannelId)).Data.(int64)
if count != 2 {
t.Fatal("should have saved 2 members")
}
- Must(store.Channel().PermanentDeleteMembersByUser(o2.UserId))
+ Must(store.Channel().PermanentDeleteMembersByUser(utils.T, o2.UserId))
- count = (<-store.Channel().GetMemberCount(o1.ChannelId)).Data.(int64)
+ count = (<-store.Channel().GetMemberCount(utils.T, o1.ChannelId)).Data.(int64)
if count != 1 {
t.Fatal("should have removed 1 member")
}
@@ -444,40 +445,40 @@ func TestChannelStorePermissionsTo(t *testing.T) {
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
- count := (<-store.Channel().CheckPermissionsTo(o1.TeamId, o1.Id, m1.UserId)).Data.(int64)
+ count := (<-store.Channel().CheckPermissionsTo(utils.T, o1.TeamId, o1.Id, m1.UserId)).Data.(int64)
if count != 1 {
t.Fatal("should have permissions")
}
- count = (<-store.Channel().CheckPermissionsTo("junk", o1.Id, m1.UserId)).Data.(int64)
+ count = (<-store.Channel().CheckPermissionsTo(utils.T, "junk", o1.Id, m1.UserId)).Data.(int64)
if count != 0 {
t.Fatal("shouldn't have permissions")
}
- count = (<-store.Channel().CheckPermissionsTo(o1.TeamId, "junk", m1.UserId)).Data.(int64)
+ count = (<-store.Channel().CheckPermissionsTo(utils.T, o1.TeamId, "junk", m1.UserId)).Data.(int64)
if count != 0 {
t.Fatal("shouldn't have permissions")
}
- count = (<-store.Channel().CheckPermissionsTo(o1.TeamId, o1.Id, "junk")).Data.(int64)
+ count = (<-store.Channel().CheckPermissionsTo(utils.T, o1.TeamId, o1.Id, "junk")).Data.(int64)
if count != 0 {
t.Fatal("shouldn't have permissions")
}
- channelId := (<-store.Channel().CheckPermissionsToByName(o1.TeamId, o1.Name, m1.UserId)).Data.(string)
+ channelId := (<-store.Channel().CheckPermissionsToByName(utils.T, o1.TeamId, o1.Name, m1.UserId)).Data.(string)
if channelId != o1.Id {
t.Fatal("should have permissions")
}
- channelId = (<-store.Channel().CheckPermissionsToByName(o1.TeamId, "missing", m1.UserId)).Data.(string)
+ channelId = (<-store.Channel().CheckPermissionsToByName(utils.T, o1.TeamId, "missing", m1.UserId)).Data.(string)
if channelId != "" {
t.Fatal("should not have permissions")
}
@@ -491,19 +492,19 @@ func TestChannelStoreOpenChannelPermissionsTo(t *testing.T) {
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
- count := (<-store.Channel().CheckOpenChannelPermissions(o1.TeamId, o1.Id)).Data.(int64)
+ count := (<-store.Channel().CheckOpenChannelPermissions(utils.T, o1.TeamId, o1.Id)).Data.(int64)
if count != 1 {
t.Fatal("should have permissions")
}
- count = (<-store.Channel().CheckOpenChannelPermissions("junk", o1.Id)).Data.(int64)
+ count = (<-store.Channel().CheckOpenChannelPermissions(utils.T, "junk", o1.Id)).Data.(int64)
if count != 0 {
t.Fatal("shouldn't have permissions")
}
- count = (<-store.Channel().CheckOpenChannelPermissions(o1.TeamId, "junk")).Data.(int64)
+ count = (<-store.Channel().CheckOpenChannelPermissions(utils.T, o1.TeamId, "junk")).Data.(int64)
if count != 0 {
t.Fatal("shouldn't have permissions")
}
@@ -517,34 +518,34 @@ func TestChannelStoreGetChannels(t *testing.T) {
o2.DisplayName = "Channel2"
o2.Name = "a" + model.NewId() + "b"
o2.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o2))
+ Must(store.Channel().Save(utils.T, &o2))
o1 := model.Channel{}
o1.TeamId = model.NewId()
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
m2 := model.ChannelMember{}
m2.ChannelId = o1.Id
m2.UserId = model.NewId()
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m2))
+ Must(store.Channel().SaveMember(utils.T, &m2))
m3 := model.ChannelMember{}
m3.ChannelId = o2.Id
m3.UserId = model.NewId()
m3.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m3))
+ Must(store.Channel().SaveMember(utils.T, &m3))
- cresult := <-store.Channel().GetChannels(o1.TeamId, m1.UserId)
+ cresult := <-store.Channel().GetChannels(utils.T, o1.TeamId, m1.UserId)
list := cresult.Data.(*model.ChannelList)
if list.Channels[0].Id != o1.Id {
@@ -560,55 +561,55 @@ func TestChannelStoreGetMoreChannels(t *testing.T) {
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
o2 := model.Channel{}
o2.TeamId = model.NewId()
o2.DisplayName = "Channel2"
o2.Name = "a" + model.NewId() + "b"
o2.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o2))
+ Must(store.Channel().Save(utils.T, &o2))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
m2 := model.ChannelMember{}
m2.ChannelId = o1.Id
m2.UserId = model.NewId()
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m2))
+ Must(store.Channel().SaveMember(utils.T, &m2))
m3 := model.ChannelMember{}
m3.ChannelId = o2.Id
m3.UserId = model.NewId()
m3.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m3))
+ Must(store.Channel().SaveMember(utils.T, &m3))
o3 := model.Channel{}
o3.TeamId = o1.TeamId
o3.DisplayName = "ChannelA"
o3.Name = "a" + model.NewId() + "b"
o3.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o3))
+ Must(store.Channel().Save(utils.T, &o3))
o4 := model.Channel{}
o4.TeamId = o1.TeamId
o4.DisplayName = "ChannelB"
o4.Name = "a" + model.NewId() + "b"
o4.Type = model.CHANNEL_PRIVATE
- Must(store.Channel().Save(&o4))
+ Must(store.Channel().Save(utils.T, &o4))
o5 := model.Channel{}
o5.TeamId = o1.TeamId
o5.DisplayName = "ChannelC"
o5.Name = "a" + model.NewId() + "b"
o5.Type = model.CHANNEL_PRIVATE
- Must(store.Channel().Save(&o5))
+ Must(store.Channel().Save(utils.T, &o5))
- cresult := <-store.Channel().GetMoreChannels(o1.TeamId, m1.UserId)
+ cresult := <-store.Channel().GetMoreChannels(utils.T, o1.TeamId, m1.UserId)
list := cresult.Data.(*model.ChannelList)
if len(list.Channels) != 1 {
@@ -619,7 +620,7 @@ func TestChannelStoreGetMoreChannels(t *testing.T) {
t.Fatal("missing channel")
}
- if r1 := <-store.Channel().AnalyticsTypeCount(o1.TeamId, model.CHANNEL_OPEN); r1.Err != nil {
+ if r1 := <-store.Channel().AnalyticsTypeCount(utils.T, o1.TeamId, model.CHANNEL_OPEN); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(int64) != 2 {
@@ -628,7 +629,7 @@ func TestChannelStoreGetMoreChannels(t *testing.T) {
}
}
- if r1 := <-store.Channel().AnalyticsTypeCount(o1.TeamId, model.CHANNEL_PRIVATE); r1.Err != nil {
+ if r1 := <-store.Channel().AnalyticsTypeCount(utils.T, o1.TeamId, model.CHANNEL_PRIVATE); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(int64) != 2 {
@@ -646,34 +647,34 @@ func TestChannelStoreGetChannelCounts(t *testing.T) {
o2.DisplayName = "Channel2"
o2.Name = "a" + model.NewId() + "b"
o2.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o2))
+ Must(store.Channel().Save(utils.T, &o2))
o1 := model.Channel{}
o1.TeamId = model.NewId()
o1.DisplayName = "Channel1"
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
m2 := model.ChannelMember{}
m2.ChannelId = o1.Id
m2.UserId = model.NewId()
m2.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m2))
+ Must(store.Channel().SaveMember(utils.T, &m2))
m3 := model.ChannelMember{}
m3.ChannelId = o2.Id
m3.UserId = model.NewId()
m3.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m3))
+ Must(store.Channel().SaveMember(utils.T, &m3))
- cresult := <-store.Channel().GetChannelCounts(o1.TeamId, m1.UserId)
+ cresult := <-store.Channel().GetChannelCounts(utils.T, o1.TeamId, m1.UserId)
counts := cresult.Data.(*model.ChannelCounts)
if len(counts.Counts) != 1 {
@@ -694,20 +695,20 @@ func TestChannelStoreUpdateLastViewedAt(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
o1.TotalMsgCount = 25
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
- err := (<-store.Channel().UpdateLastViewedAt(m1.ChannelId, m1.UserId)).Err
+ err := (<-store.Channel().UpdateLastViewedAt(utils.T, m1.ChannelId, m1.UserId)).Err
if err != nil {
t.Fatal("failed to update", err)
}
- err = (<-store.Channel().UpdateLastViewedAt(m1.ChannelId, "missing id")).Err
+ err = (<-store.Channel().UpdateLastViewedAt(utils.T, m1.ChannelId, "missing id")).Err
if err != nil {
t.Fatal("failed to update")
}
@@ -722,30 +723,30 @@ func TestChannelStoreIncrementMentionCount(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Type = model.CHANNEL_OPEN
o1.TotalMsgCount = 25
- Must(store.Channel().Save(&o1))
+ Must(store.Channel().Save(utils.T, &o1))
m1 := model.ChannelMember{}
m1.ChannelId = o1.Id
m1.UserId = model.NewId()
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
- err := (<-store.Channel().IncrementMentionCount(m1.ChannelId, m1.UserId)).Err
+ err := (<-store.Channel().IncrementMentionCount(utils.T, m1.ChannelId, m1.UserId)).Err
if err != nil {
t.Fatal("failed to update")
}
- err = (<-store.Channel().IncrementMentionCount(m1.ChannelId, "missing id")).Err
+ err = (<-store.Channel().IncrementMentionCount(utils.T, m1.ChannelId, "missing id")).Err
if err != nil {
t.Fatal("failed to update")
}
- err = (<-store.Channel().IncrementMentionCount("missing id", m1.UserId)).Err
+ err = (<-store.Channel().IncrementMentionCount(utils.T, "missing id", m1.UserId)).Err
if err != nil {
t.Fatal("failed to update")
}
- err = (<-store.Channel().IncrementMentionCount("missing id", "missing id")).Err
+ err = (<-store.Channel().IncrementMentionCount(utils.T, "missing id", "missing id")).Err
if err != nil {
t.Fatal("failed to update")
}
diff --git a/store/sql_oauth_store.go b/store/sql_oauth_store.go
index 43a5bee31..20184e6a4 100644
--- a/store/sql_oauth_store.go
+++ b/store/sql_oauth_store.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
"strings"
)
@@ -52,7 +53,7 @@ func (as SqlOAuthStore) CreateIndexesIfNotExists() {
as.CreateIndexIfNotExists("idx_oauthauthdata_client_id", "OAuthAuthData", "Code")
}
-func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) StoreChannel {
+func (as SqlOAuthStore) SaveApp(T goi18n.TranslateFunc, app *model.OAuthApp) StoreChannel {
storeChannel := make(StoreChannel)
@@ -86,7 +87,7 @@ func (as SqlOAuthStore) SaveApp(app *model.OAuthApp) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) StoreChannel {
+func (as SqlOAuthStore) UpdateApp(T goi18n.TranslateFunc, app *model.OAuthApp) StoreChannel {
storeChannel := make(StoreChannel)
@@ -127,7 +128,7 @@ func (as SqlOAuthStore) UpdateApp(app *model.OAuthApp) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) GetApp(id string) StoreChannel {
+func (as SqlOAuthStore) GetApp(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -150,7 +151,7 @@ func (as SqlOAuthStore) GetApp(id string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) GetAppByUser(userId string) StoreChannel {
+func (as SqlOAuthStore) GetAppByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -172,7 +173,7 @@ func (as SqlOAuthStore) GetAppByUser(userId string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) SaveAccessData(accessData *model.AccessData) StoreChannel {
+func (as SqlOAuthStore) SaveAccessData(T goi18n.TranslateFunc, accessData *model.AccessData) StoreChannel {
storeChannel := make(StoreChannel)
@@ -198,7 +199,7 @@ func (as SqlOAuthStore) SaveAccessData(accessData *model.AccessData) StoreChanne
return storeChannel
}
-func (as SqlOAuthStore) GetAccessData(token string) StoreChannel {
+func (as SqlOAuthStore) GetAccessData(T goi18n.TranslateFunc, token string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -221,7 +222,7 @@ func (as SqlOAuthStore) GetAccessData(token string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) GetAccessDataByAuthCode(authCode string) StoreChannel {
+func (as SqlOAuthStore) GetAccessDataByAuthCode(T goi18n.TranslateFunc, authCode string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -248,7 +249,7 @@ func (as SqlOAuthStore) GetAccessDataByAuthCode(authCode string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) RemoveAccessData(token string) StoreChannel {
+func (as SqlOAuthStore) RemoveAccessData(T goi18n.TranslateFunc, token string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -265,7 +266,7 @@ func (as SqlOAuthStore) RemoveAccessData(token string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) SaveAuthData(authData *model.AuthData) StoreChannel {
+func (as SqlOAuthStore) SaveAuthData(T goi18n.TranslateFunc, authData *model.AuthData) StoreChannel {
storeChannel := make(StoreChannel)
@@ -292,7 +293,7 @@ func (as SqlOAuthStore) SaveAuthData(authData *model.AuthData) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) GetAuthData(code string) StoreChannel {
+func (as SqlOAuthStore) GetAuthData(T goi18n.TranslateFunc, code string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -315,7 +316,7 @@ func (as SqlOAuthStore) GetAuthData(code string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) RemoveAuthData(code string) StoreChannel {
+func (as SqlOAuthStore) RemoveAuthData(T goi18n.TranslateFunc, code string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -333,7 +334,7 @@ func (as SqlOAuthStore) RemoveAuthData(code string) StoreChannel {
return storeChannel
}
-func (as SqlOAuthStore) PermanentDeleteAuthDataByUser(userId string) StoreChannel {
+func (as SqlOAuthStore) PermanentDeleteAuthDataByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_oauth_store_test.go b/store/sql_oauth_store_test.go
index c3f6ea7ac..f8d035a0c 100644
--- a/store/sql_oauth_store_test.go
+++ b/store/sql_oauth_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
)
@@ -17,7 +18,7 @@ func TestOAuthStoreSaveApp(t *testing.T) {
a1.CallbackUrls = []string{"https://nowhere.com"}
a1.Homepage = "https://nowhere.com"
- if err := (<-store.OAuth().SaveApp(&a1)).Err; err != nil {
+ if err := (<-store.OAuth().SaveApp(utils.T, &a1)).Err; err != nil {
t.Fatal(err)
}
}
@@ -30,13 +31,13 @@ func TestOAuthStoreGetApp(t *testing.T) {
a1.Name = "TestApp" + model.NewId()
a1.CallbackUrls = []string{"https://nowhere.com"}
a1.Homepage = "https://nowhere.com"
- Must(store.OAuth().SaveApp(&a1))
+ Must(store.OAuth().SaveApp(utils.T, &a1))
- if err := (<-store.OAuth().GetApp(a1.Id)).Err; err != nil {
+ if err := (<-store.OAuth().GetApp(utils.T, a1.Id)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.OAuth().GetAppByUser(a1.CreatorId)).Err; err != nil {
+ if err := (<-store.OAuth().GetAppByUser(utils.T, a1.CreatorId)).Err; err != nil {
t.Fatal(err)
}
}
@@ -49,13 +50,13 @@ func TestOAuthStoreUpdateApp(t *testing.T) {
a1.Name = "TestApp" + model.NewId()
a1.CallbackUrls = []string{"https://nowhere.com"}
a1.Homepage = "https://nowhere.com"
- Must(store.OAuth().SaveApp(&a1))
+ Must(store.OAuth().SaveApp(utils.T, &a1))
a1.CreateAt = 1
a1.ClientSecret = "pwd"
a1.CreatorId = "12345678901234567890123456"
a1.Name = "NewName"
- if result := <-store.OAuth().UpdateApp(&a1); result.Err != nil {
+ if result := <-store.OAuth().UpdateApp(utils.T, &a1); result.Err != nil {
t.Fatal(result.Err)
} else {
ua1 := (result.Data.([2]*model.OAuthApp)[0])
@@ -82,7 +83,7 @@ func TestOAuthStoreSaveAccessData(t *testing.T) {
a1.Token = model.NewId()
a1.RefreshToken = model.NewId()
- if err := (<-store.OAuth().SaveAccessData(&a1)).Err; err != nil {
+ if err := (<-store.OAuth().SaveAccessData(utils.T, &a1)).Err; err != nil {
t.Fatal(err)
}
}
@@ -94,9 +95,9 @@ func TestOAuthStoreGetAccessData(t *testing.T) {
a1.AuthCode = model.NewId()
a1.Token = model.NewId()
a1.RefreshToken = model.NewId()
- Must(store.OAuth().SaveAccessData(&a1))
+ Must(store.OAuth().SaveAccessData(utils.T, &a1))
- if result := <-store.OAuth().GetAccessData(a1.Token); result.Err != nil {
+ if result := <-store.OAuth().GetAccessData(utils.T, a1.Token); result.Err != nil {
t.Fatal(result.Err)
} else {
ra1 := result.Data.(*model.AccessData)
@@ -105,11 +106,11 @@ func TestOAuthStoreGetAccessData(t *testing.T) {
}
}
- if err := (<-store.OAuth().GetAccessDataByAuthCode(a1.AuthCode)).Err; err != nil {
+ if err := (<-store.OAuth().GetAccessDataByAuthCode(utils.T, a1.AuthCode)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.OAuth().GetAccessDataByAuthCode("junk")).Err; err != nil {
+ if err := (<-store.OAuth().GetAccessDataByAuthCode(utils.T, "junk")).Err; err != nil {
t.Fatal(err)
}
}
@@ -121,13 +122,13 @@ func TestOAuthStoreRemoveAccessData(t *testing.T) {
a1.AuthCode = model.NewId()
a1.Token = model.NewId()
a1.RefreshToken = model.NewId()
- Must(store.OAuth().SaveAccessData(&a1))
+ Must(store.OAuth().SaveAccessData(utils.T, &a1))
- if err := (<-store.OAuth().RemoveAccessData(a1.Token)).Err; err != nil {
+ if err := (<-store.OAuth().RemoveAccessData(utils.T, a1.Token)).Err; err != nil {
t.Fatal(err)
}
- if result := <-store.OAuth().GetAccessDataByAuthCode(a1.AuthCode); result.Err != nil {
+ if result := <-store.OAuth().GetAccessDataByAuthCode(utils.T, a1.AuthCode); result.Err != nil {
t.Fatal(result.Err)
} else {
if result.Data != nil {
@@ -144,7 +145,7 @@ func TestOAuthStoreSaveAuthData(t *testing.T) {
a1.UserId = model.NewId()
a1.Code = model.NewId()
- if err := (<-store.OAuth().SaveAuthData(&a1)).Err; err != nil {
+ if err := (<-store.OAuth().SaveAuthData(utils.T, &a1)).Err; err != nil {
t.Fatal(err)
}
}
@@ -156,9 +157,9 @@ func TestOAuthStoreGetAuthData(t *testing.T) {
a1.ClientId = model.NewId()
a1.UserId = model.NewId()
a1.Code = model.NewId()
- Must(store.OAuth().SaveAuthData(&a1))
+ Must(store.OAuth().SaveAuthData(utils.T, &a1))
- if err := (<-store.OAuth().GetAuthData(a1.Code)).Err; err != nil {
+ if err := (<-store.OAuth().GetAuthData(utils.T, a1.Code)).Err; err != nil {
t.Fatal(err)
}
}
@@ -170,13 +171,13 @@ func TestOAuthStoreRemoveAuthData(t *testing.T) {
a1.ClientId = model.NewId()
a1.UserId = model.NewId()
a1.Code = model.NewId()
- Must(store.OAuth().SaveAuthData(&a1))
+ Must(store.OAuth().SaveAuthData(utils.T, &a1))
- if err := (<-store.OAuth().RemoveAuthData(a1.Code)).Err; err != nil {
+ if err := (<-store.OAuth().RemoveAuthData(utils.T, a1.Code)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.OAuth().GetAuthData(a1.Code)).Err; err == nil {
+ if err := (<-store.OAuth().GetAuthData(utils.T, a1.Code)).Err; err == nil {
t.Fatal("should have errored - auth code removed")
}
}
@@ -188,9 +189,9 @@ func TestOAuthStoreRemoveAuthDataByUser(t *testing.T) {
a1.ClientId = model.NewId()
a1.UserId = model.NewId()
a1.Code = model.NewId()
- Must(store.OAuth().SaveAuthData(&a1))
+ Must(store.OAuth().SaveAuthData(utils.T, &a1))
- if err := (<-store.OAuth().PermanentDeleteAuthDataByUser(a1.UserId)).Err; err != nil {
+ if err := (<-store.OAuth().PermanentDeleteAuthDataByUser(utils.T, a1.UserId)).Err; err != nil {
t.Fatal(err)
}
}
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 40dca9930..b48406261 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -11,6 +11,7 @@ import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlPostStore struct {
@@ -50,7 +51,7 @@ func (s SqlPostStore) CreateIndexesIfNotExists() {
s.CreateFullTextIndexIfNotExists("idx_posts_hashtags_txt", "Posts", "Hashtags")
}
-func (s SqlPostStore) Save(post *model.Post) StoreChannel {
+func (s SqlPostStore) Save(T goi18n.TranslateFunc, post *model.Post) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -97,7 +98,7 @@ func (s SqlPostStore) Save(post *model.Post) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) Update(oldPost *model.Post, newMessage string, newHashtags string) StoreChannel {
+func (s SqlPostStore) Update(T goi18n.TranslateFunc, oldPost *model.Post, newMessage string, newHashtags string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -142,7 +143,7 @@ func (s SqlPostStore) Update(oldPost *model.Post, newMessage string, newHashtags
return storeChannel
}
-func (s SqlPostStore) Get(id string) StoreChannel {
+func (s SqlPostStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -188,7 +189,7 @@ type etagPosts struct {
UpdateAt int64
}
-func (s SqlPostStore) GetEtag(channelId string) StoreChannel {
+func (s SqlPostStore) GetEtag(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -209,7 +210,7 @@ func (s SqlPostStore) GetEtag(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) Delete(postId string, time int64) StoreChannel {
+func (s SqlPostStore) Delete(T goi18n.TranslateFunc, postId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -227,7 +228,7 @@ func (s SqlPostStore) Delete(postId string, time int64) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) permanentDelete(postId string) StoreChannel {
+func (s SqlPostStore) permanentDelete(T goi18n.TranslateFunc, postId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -245,7 +246,7 @@ func (s SqlPostStore) permanentDelete(postId string) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) permanentDeleteAllCommentByUser(userId string) StoreChannel {
+func (s SqlPostStore) permanentDeleteAllCommentByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -263,14 +264,14 @@ func (s SqlPostStore) permanentDeleteAllCommentByUser(userId string) StoreChanne
return storeChannel
}
-func (s SqlPostStore) PermanentDeleteByUser(userId string) StoreChannel {
+func (s SqlPostStore) PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
// First attempt to delete all the comments for a user
- if r := <-s.permanentDeleteAllCommentByUser(userId); r.Err != nil {
+ if r := <-s.permanentDeleteAllCommentByUser(T, userId); r.Err != nil {
result.Err = r.Err
storeChannel <- result
close(storeChannel)
@@ -294,7 +295,7 @@ func (s SqlPostStore) PermanentDeleteByUser(userId string) StoreChannel {
found = false
for _, id := range ids {
found = true
- if r := <-s.permanentDelete(id); r.Err != nil {
+ if r := <-s.permanentDelete(T, id); r.Err != nil {
result.Err = r.Err
storeChannel <- result
close(storeChannel)
@@ -320,7 +321,7 @@ func (s SqlPostStore) PermanentDeleteByUser(userId string) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) GetPosts(channelId string, offset int, limit int) StoreChannel {
+func (s SqlPostStore) GetPosts(T goi18n.TranslateFunc, channelId string, offset int, limit int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -333,8 +334,8 @@ func (s SqlPostStore) GetPosts(channelId string, offset int, limit int) StoreCha
return
}
- rpc := s.getRootPosts(channelId, offset, limit)
- cpc := s.getParentsPosts(channelId, offset, limit)
+ rpc := s.getRootPosts(T, channelId, offset, limit)
+ cpc := s.getParentsPosts(T, channelId, offset, limit)
if rpr := <-rpc; rpr.Err != nil {
result.Err = rpr.Err
@@ -367,7 +368,7 @@ func (s SqlPostStore) GetPosts(channelId string, offset int, limit int) StoreCha
return storeChannel
}
-func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel {
+func (s SqlPostStore) GetPostsSince(T goi18n.TranslateFunc, channelId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -425,15 +426,15 @@ func (s SqlPostStore) GetPostsSince(channelId string, time int64) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) GetPostsBefore(channelId string, postId string, numPosts int, offset int) StoreChannel {
- return s.getPostsAround(channelId, postId, numPosts, offset, true)
+func (s SqlPostStore) GetPostsBefore(T goi18n.TranslateFunc, channelId string, postId string, numPosts int, offset int) StoreChannel {
+ return s.getPostsAround(T, channelId, postId, numPosts, offset, true)
}
-func (s SqlPostStore) GetPostsAfter(channelId string, postId string, numPosts int, offset int) StoreChannel {
- return s.getPostsAround(channelId, postId, numPosts, offset, false)
+func (s SqlPostStore) GetPostsAfter(T goi18n.TranslateFunc, channelId string, postId string, numPosts int, offset int) StoreChannel {
+ return s.getPostsAround(T, channelId, postId, numPosts, offset, false)
}
-func (s SqlPostStore) getPostsAround(channelId string, postId string, numPosts int, offset int, before bool) StoreChannel {
+func (s SqlPostStore) getPostsAround(T goi18n.TranslateFunc, channelId string, postId string, numPosts int, offset int, before bool) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -523,7 +524,7 @@ func (s SqlPostStore) getPostsAround(channelId string, postId string, numPosts i
return storeChannel
}
-func (s SqlPostStore) getRootPosts(channelId string, offset int, limit int) StoreChannel {
+func (s SqlPostStore) getRootPosts(T goi18n.TranslateFunc, channelId string, offset int, limit int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -544,7 +545,7 @@ func (s SqlPostStore) getRootPosts(channelId string, offset int, limit int) Stor
return storeChannel
}
-func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) StoreChannel {
+func (s SqlPostStore) getParentsPosts(T goi18n.TranslateFunc, channelId string, offset int, limit int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -600,7 +601,7 @@ var specialSearchChar = []string{
"@",
}
-func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchParams) StoreChannel {
+func (s SqlPostStore) Search(T goi18n.TranslateFunc, teamId string, userId string, params *model.SearchParams) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -765,7 +766,7 @@ func (s SqlPostStore) Search(teamId string, userId string, params *model.SearchP
return storeChannel
}
-func (s SqlPostStore) GetForExport(channelId string) StoreChannel {
+func (s SqlPostStore) GetForExport(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -789,7 +790,7 @@ func (s SqlPostStore) GetForExport(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel {
+func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -853,7 +854,7 @@ func (s SqlPostStore) AnalyticsUserCountsWithPostsByDay(teamId string) StoreChan
return storeChannel
}
-func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) StoreChannel {
+func (s SqlPostStore) AnalyticsPostCountsByDay(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -918,7 +919,7 @@ func (s SqlPostStore) AnalyticsPostCountsByDay(teamId string) StoreChannel {
return storeChannel
}
-func (s SqlPostStore) AnalyticsPostCount(teamId string) StoreChannel {
+func (s SqlPostStore) AnalyticsPostCount(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index a3e3e10dd..5144924be 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -20,11 +20,11 @@ func TestPostStoreSave(t *testing.T) {
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- if err := (<-store.Post().Save(&o1)).Err; err != nil {
+ if err := (<-store.Post().Save(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
- if err := (<-store.Post().Save(&o1)).Err; err == nil {
+ if err := (<-store.Post().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
}
@@ -37,19 +37,19 @@ func TestPostStoreGet(t *testing.T) {
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
+ etag1 := (<-store.Post().GetEtag(utils.T, o1.ChannelId)).Data.(string)
if strings.Index(etag1, model.CurrentVersion+".0.") != 0 {
t.Fatal("Invalid Etag")
}
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
- etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
+ etag2 := (<-store.Post().GetEtag(utils.T, o1.ChannelId)).Data.(string)
if strings.Index(etag2, model.CurrentVersion+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
- if r1 := <-store.Post().Get(o1.Id); r1.Err != nil {
+ if r1 := <-store.Post().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.PostList).Posts[o1.Id].CreateAt != o1.CreateAt {
@@ -57,7 +57,7 @@ func TestPostStoreGet(t *testing.T) {
}
}
- if err := (<-store.Post().Get("123")).Err; err == nil {
+ if err := (<-store.Post().Get(utils.T, "123")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -69,7 +69,7 @@ func TestPostStoreUpdate(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "AAAAAAAAAAA"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -77,50 +77,50 @@ func TestPostStoreUpdate(t *testing.T) {
o2.Message = "a" + model.NewId() + "CCCCCCCCC"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = o1.ChannelId
o3.UserId = model.NewId()
o3.Message = "a" + model.NewId() + "QQQQQQQQQQ"
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
- ro1 := (<-store.Post().Get(o1.Id)).Data.(*model.PostList).Posts[o1.Id]
- ro2 := (<-store.Post().Get(o1.Id)).Data.(*model.PostList).Posts[o2.Id]
- ro6 := (<-store.Post().Get(o3.Id)).Data.(*model.PostList).Posts[o3.Id]
+ ro1 := (<-store.Post().Get(utils.T, o1.Id)).Data.(*model.PostList).Posts[o1.Id]
+ ro2 := (<-store.Post().Get(utils.T, o1.Id)).Data.(*model.PostList).Posts[o2.Id]
+ ro6 := (<-store.Post().Get(utils.T, o3.Id)).Data.(*model.PostList).Posts[o3.Id]
if ro1.Message != o1.Message {
t.Fatal("Failed to save/get")
}
msg := o1.Message + "BBBBBBBBBB"
- if result := <-store.Post().Update(ro1, msg, ""); result.Err != nil {
+ if result := <-store.Post().Update(utils.T, ro1, msg, ""); result.Err != nil {
t.Fatal(result.Err)
}
msg2 := o2.Message + "DDDDDDD"
- if result := <-store.Post().Update(ro2, msg2, ""); result.Err != nil {
+ if result := <-store.Post().Update(utils.T, ro2, msg2, ""); result.Err != nil {
t.Fatal(result.Err)
}
msg3 := o3.Message + "WWWWWWW"
- if result := <-store.Post().Update(ro6, msg3, "#hashtag"); result.Err != nil {
+ if result := <-store.Post().Update(utils.T, ro6, msg3, "#hashtag"); result.Err != nil {
t.Fatal(result.Err)
}
- ro3 := (<-store.Post().Get(o1.Id)).Data.(*model.PostList).Posts[o1.Id]
+ ro3 := (<-store.Post().Get(utils.T, o1.Id)).Data.(*model.PostList).Posts[o1.Id]
if ro3.Message != msg {
t.Fatal("Failed to update/get")
}
- ro4 := (<-store.Post().Get(o1.Id)).Data.(*model.PostList).Posts[o2.Id]
+ ro4 := (<-store.Post().Get(utils.T, o1.Id)).Data.(*model.PostList).Posts[o2.Id]
if ro4.Message != msg2 {
t.Fatal("Failed to update/get")
}
- ro5 := (<-store.Post().Get(o3.Id)).Data.(*model.PostList).Posts[o3.Id]
+ ro5 := (<-store.Post().Get(utils.T, o3.Id)).Data.(*model.PostList).Posts[o3.Id]
if ro5.Message != msg3 && ro5.Hashtags != "#hashtag" {
t.Fatal("Failed to update/get")
@@ -136,14 +136,14 @@ func TestPostStoreDelete(t *testing.T) {
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- etag1 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
+ etag1 := (<-store.Post().GetEtag(utils.T, o1.ChannelId)).Data.(string)
if strings.Index(etag1, model.CurrentVersion+".0.") != 0 {
t.Fatal("Invalid Etag")
}
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
- if r1 := <-store.Post().Get(o1.Id); r1.Err != nil {
+ if r1 := <-store.Post().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.PostList).Posts[o1.Id].CreateAt != o1.CreateAt {
@@ -151,16 +151,16 @@ func TestPostStoreDelete(t *testing.T) {
}
}
- if r2 := <-store.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil {
+ if r2 := <-store.Post().Delete(utils.T, o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Post().Get(utils.T, o1.Id)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
}
- etag2 := (<-store.Post().GetEtag(o1.ChannelId)).Data.(string)
+ etag2 := (<-store.Post().GetEtag(utils.T, o1.ChannelId)).Data.(string)
if strings.Index(etag2, model.CurrentVersion+"."+o1.Id) != 0 {
t.Fatal("Invalid Etag")
}
@@ -173,7 +173,7 @@ func TestPostStoreDelete1Level(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -181,17 +181,17 @@ func TestPostStoreDelete1Level(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
- if r2 := <-store.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil {
+ if r2 := <-store.Post().Delete(utils.T, o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Post().Get(utils.T, o1.Id)); r3.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ if r4 := (<-store.Post().Get(utils.T, o2.Id)); r4.Err == nil {
t.Fatal("Deleted id should have failed")
}
}
@@ -203,7 +203,7 @@ func TestPostStoreDelete2Level(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -211,7 +211,7 @@ func TestPostStoreDelete2Level(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = o1.ChannelId
@@ -219,31 +219,31 @@ func TestPostStoreDelete2Level(t *testing.T) {
o3.Message = "a" + model.NewId() + "b"
o3.ParentId = o2.Id
o3.RootId = o1.Id
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
o4 := &model.Post{}
o4.ChannelId = model.NewId()
o4.UserId = model.NewId()
o4.Message = "a" + model.NewId() + "b"
- o4 = (<-store.Post().Save(o4)).Data.(*model.Post)
+ o4 = (<-store.Post().Save(utils.T, o4)).Data.(*model.Post)
- if r2 := <-store.Post().Delete(o1.Id, model.GetMillis()); r2.Err != nil {
+ if r2 := <-store.Post().Delete(utils.T, o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Post().Get(utils.T, o1.Id)); r3.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ if r4 := (<-store.Post().Get(utils.T, o2.Id)); r4.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r5 := (<-store.Post().Get(o3.Id)); r5.Err == nil {
+ if r5 := (<-store.Post().Get(utils.T, o3.Id)); r5.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r6 := <-store.Post().Get(o4.Id); r6.Err != nil {
+ if r6 := <-store.Post().Get(utils.T, o4.Id); r6.Err != nil {
t.Fatal(r6.Err)
}
}
@@ -255,7 +255,7 @@ func TestPostStorePermDelete1Level(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -263,17 +263,17 @@ func TestPostStorePermDelete1Level(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
- if r2 := <-store.Post().PermanentDeleteByUser(o2.UserId); r2.Err != nil {
+ if r2 := <-store.Post().PermanentDeleteByUser(utils.T, o2.UserId); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Post().Get(o1.Id)); r3.Err != nil {
+ if r3 := (<-store.Post().Get(utils.T, o1.Id)); r3.Err != nil {
t.Fatal("Deleted id shouldn't have failed")
}
- if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ if r4 := (<-store.Post().Get(utils.T, o2.Id)); r4.Err == nil {
t.Fatal("Deleted id should have failed")
}
}
@@ -285,7 +285,7 @@ func TestPostStorePermDelete1Level2(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -293,27 +293,27 @@ func TestPostStorePermDelete1Level2(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = model.NewId()
o3.UserId = model.NewId()
o3.Message = "a" + model.NewId() + "b"
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
- if r2 := <-store.Post().PermanentDeleteByUser(o1.UserId); r2.Err != nil {
+ if r2 := <-store.Post().PermanentDeleteByUser(utils.T, o1.UserId); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Post().Get(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Post().Get(utils.T, o1.Id)); r3.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r4 := (<-store.Post().Get(o2.Id)); r4.Err == nil {
+ if r4 := (<-store.Post().Get(utils.T, o2.Id)); r4.Err == nil {
t.Fatal("Deleted id should have failed")
}
- if r5 := (<-store.Post().Get(o3.Id)); r5.Err != nil {
+ if r5 := (<-store.Post().Get(utils.T, o3.Id)); r5.Err != nil {
t.Fatal("Deleted id shouldn't have failed")
}
}
@@ -325,7 +325,7 @@ func TestPostStoreGetWithChildren(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = o1.ChannelId
@@ -333,7 +333,7 @@ func TestPostStoreGetWithChildren(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = o1.ChannelId
@@ -341,9 +341,9 @@ func TestPostStoreGetWithChildren(t *testing.T) {
o3.Message = "a" + model.NewId() + "b"
o3.ParentId = o2.Id
o3.RootId = o1.Id
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
- if r1 := <-store.Post().Get(o1.Id); r1.Err != nil {
+ if r1 := <-store.Post().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
pl := r1.Data.(*model.PostList)
@@ -352,9 +352,9 @@ func TestPostStoreGetWithChildren(t *testing.T) {
}
}
- Must(store.Post().Delete(o3.Id, model.GetMillis()))
+ Must(store.Post().Delete(utils.T, o3.Id, model.GetMillis()))
- if r2 := <-store.Post().Get(o1.Id); r2.Err != nil {
+ if r2 := <-store.Post().Get(utils.T, o1.Id); r2.Err != nil {
t.Fatal(r2.Err)
} else {
pl := r2.Data.(*model.PostList)
@@ -363,9 +363,9 @@ func TestPostStoreGetWithChildren(t *testing.T) {
}
}
- Must(store.Post().Delete(o2.Id, model.GetMillis()))
+ Must(store.Post().Delete(utils.T, o2.Id, model.GetMillis()))
- if r3 := <-store.Post().Get(o1.Id); r3.Err != nil {
+ if r3 := <-store.Post().Get(utils.T, o1.Id); r3.Err != nil {
t.Fatal(r3.Err)
} else {
pl := r3.Data.(*model.PostList)
@@ -382,7 +382,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2 := &model.Post{}
@@ -391,7 +391,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2a := &model.Post{}
@@ -400,7 +400,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o2a.Message = "a" + model.NewId() + "b"
o2a.ParentId = o1.Id
o2a.RootId = o1.Id
- o2a = (<-store.Post().Save(o2a)).Data.(*model.Post)
+ o2a = (<-store.Post().Save(utils.T, o2a)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o3 := &model.Post{}
@@ -409,14 +409,14 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o3.Message = "a" + model.NewId() + "b"
o3.ParentId = o1.Id
o3.RootId = o1.Id
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o4 := &model.Post{}
o4.ChannelId = o1.ChannelId
o4.UserId = model.NewId()
o4.Message = "a" + model.NewId() + "b"
- o4 = (<-store.Post().Save(o4)).Data.(*model.Post)
+ o4 = (<-store.Post().Save(utils.T, o4)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o5 := &model.Post{}
@@ -425,9 +425,9 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
o5.Message = "a" + model.NewId() + "b"
o5.ParentId = o4.Id
o5.RootId = o4.Id
- o5 = (<-store.Post().Save(o5)).Data.(*model.Post)
+ o5 = (<-store.Post().Save(utils.T, o5)).Data.(*model.Post)
- r1 := (<-store.Post().GetPosts(o1.ChannelId, 0, 4)).Data.(*model.PostList)
+ r1 := (<-store.Post().GetPosts(utils.T, o1.ChannelId, 0, 4)).Data.(*model.PostList)
if r1.Order[0] != o5.Id {
t.Fatal("invalid order")
@@ -460,14 +460,14 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
o0.ChannelId = model.NewId()
o0.UserId = model.NewId()
o0.Message = "a" + model.NewId() + "b"
- o0 = (<-store.Post().Save(o0)).Data.(*model.Post)
+ o0 = (<-store.Post().Save(utils.T, o0)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o1 := &model.Post{}
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2 := &model.Post{}
@@ -476,7 +476,7 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2a := &model.Post{}
@@ -485,7 +485,7 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
o2a.Message = "a" + model.NewId() + "b"
o2a.ParentId = o1.Id
o2a.RootId = o1.Id
- o2a = (<-store.Post().Save(o2a)).Data.(*model.Post)
+ o2a = (<-store.Post().Save(utils.T, o2a)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o3 := &model.Post{}
@@ -494,14 +494,14 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
o3.Message = "a" + model.NewId() + "b"
o3.ParentId = o1.Id
o3.RootId = o1.Id
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o4 := &model.Post{}
o4.ChannelId = o1.ChannelId
o4.UserId = model.NewId()
o4.Message = "a" + model.NewId() + "b"
- o4 = (<-store.Post().Save(o4)).Data.(*model.Post)
+ o4 = (<-store.Post().Save(utils.T, o4)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o5 := &model.Post{}
@@ -510,15 +510,15 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
o5.Message = "a" + model.NewId() + "b"
o5.ParentId = o4.Id
o5.RootId = o4.Id
- o5 = (<-store.Post().Save(o5)).Data.(*model.Post)
+ o5 = (<-store.Post().Save(utils.T, o5)).Data.(*model.Post)
- r1 := (<-store.Post().GetPostsBefore(o1.ChannelId, o1.Id, 4, 0)).Data.(*model.PostList)
+ r1 := (<-store.Post().GetPostsBefore(utils.T, o1.ChannelId, o1.Id, 4, 0)).Data.(*model.PostList)
if len(r1.Posts) != 0 {
t.Fatal("Wrong size")
}
- r2 := (<-store.Post().GetPostsAfter(o1.ChannelId, o1.Id, 4, 0)).Data.(*model.PostList)
+ r2 := (<-store.Post().GetPostsAfter(utils.T, o1.ChannelId, o1.Id, 4, 0)).Data.(*model.PostList)
if r2.Order[0] != o4.Id {
t.Fatal("invalid order")
@@ -540,7 +540,7 @@ func TestPostStoreGetPostsBeforeAfter(t *testing.T) {
t.Fatal("wrong size")
}
- r3 := (<-store.Post().GetPostsBefore(o3.ChannelId, o3.Id, 2, 0)).Data.(*model.PostList)
+ r3 := (<-store.Post().GetPostsBefore(utils.T, o3.ChannelId, o3.Id, 2, 0)).Data.(*model.PostList)
if r3.Order[0] != o2a.Id {
t.Fatal("invalid order")
@@ -565,14 +565,14 @@ func TestPostStoreGetPostsSince(t *testing.T) {
o0.ChannelId = model.NewId()
o0.UserId = model.NewId()
o0.Message = "a" + model.NewId() + "b"
- o0 = (<-store.Post().Save(o0)).Data.(*model.Post)
+ o0 = (<-store.Post().Save(utils.T, o0)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o1 := &model.Post{}
o1.ChannelId = model.NewId()
o1.UserId = model.NewId()
o1.Message = "a" + model.NewId() + "b"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2 := &model.Post{}
@@ -581,7 +581,7 @@ func TestPostStoreGetPostsSince(t *testing.T) {
o2.Message = "a" + model.NewId() + "b"
o2.ParentId = o1.Id
o2.RootId = o1.Id
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o2a := &model.Post{}
@@ -590,7 +590,7 @@ func TestPostStoreGetPostsSince(t *testing.T) {
o2a.Message = "a" + model.NewId() + "b"
o2a.ParentId = o1.Id
o2a.RootId = o1.Id
- o2a = (<-store.Post().Save(o2a)).Data.(*model.Post)
+ o2a = (<-store.Post().Save(utils.T, o2a)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o3 := &model.Post{}
@@ -599,14 +599,14 @@ func TestPostStoreGetPostsSince(t *testing.T) {
o3.Message = "a" + model.NewId() + "b"
o3.ParentId = o1.Id
o3.RootId = o1.Id
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o4 := &model.Post{}
o4.ChannelId = o1.ChannelId
o4.UserId = model.NewId()
o4.Message = "a" + model.NewId() + "b"
- o4 = (<-store.Post().Save(o4)).Data.(*model.Post)
+ o4 = (<-store.Post().Save(utils.T, o4)).Data.(*model.Post)
time.Sleep(2 * time.Millisecond)
o5 := &model.Post{}
@@ -615,9 +615,9 @@ func TestPostStoreGetPostsSince(t *testing.T) {
o5.Message = "a" + model.NewId() + "b"
o5.ParentId = o4.Id
o5.RootId = o4.Id
- o5 = (<-store.Post().Save(o5)).Data.(*model.Post)
+ o5 = (<-store.Post().Save(utils.T, o5)).Data.(*model.Post)
- r1 := (<-store.Post().GetPostsSince(o1.ChannelId, o1.CreateAt)).Data.(*model.PostList)
+ r1 := (<-store.Post().GetPostsSince(utils.T, o1.ChannelId, o1.CreateAt)).Data.(*model.PostList)
if r1.Order[0] != o5.Id {
t.Fatal("invalid order")
@@ -655,103 +655,103 @@ func TestPostStoreSearch(t *testing.T) {
c1.DisplayName = "Channel1"
c1.Name = "a" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
- c1 = (<-store.Channel().Save(c1)).Data.(*model.Channel)
+ c1 = (<-store.Channel().Save(utils.T, c1)).Data.(*model.Channel)
m1 := model.ChannelMember{}
m1.ChannelId = c1.Id
m1.UserId = userId
m1.NotifyProps = model.GetDefaultChannelNotifyProps()
- Must(store.Channel().SaveMember(&m1))
+ Must(store.Channel().SaveMember(utils.T, &m1))
c2 := &model.Channel{}
c2.TeamId = teamId
c2.DisplayName = "Channel1"
c2.Name = "a" + model.NewId() + "b"
c2.Type = model.CHANNEL_OPEN
- c2 = (<-store.Channel().Save(c2)).Data.(*model.Channel)
+ c2 = (<-store.Channel().Save(utils.T, c2)).Data.(*model.Channel)
o1 := &model.Post{}
o1.ChannelId = c1.Id
o1.UserId = model.NewId()
o1.Message = "corey mattermost new york"
- o1 = (<-store.Post().Save(o1)).Data.(*model.Post)
+ o1 = (<-store.Post().Save(utils.T, o1)).Data.(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = model.NewId()
o2.Message = "New Jersey is where John is from"
- o2 = (<-store.Post().Save(o2)).Data.(*model.Post)
+ o2 = (<-store.Post().Save(utils.T, o2)).Data.(*model.Post)
o3 := &model.Post{}
o3.ChannelId = c2.Id
o3.UserId = model.NewId()
o3.Message = "New Jersey is where John is from corey new york"
- o3 = (<-store.Post().Save(o3)).Data.(*model.Post)
+ o3 = (<-store.Post().Save(utils.T, o3)).Data.(*model.Post)
o4 := &model.Post{}
o4.ChannelId = c1.Id
o4.UserId = model.NewId()
o4.Hashtags = "#hashtag"
o4.Message = "(message)blargh"
- o4 = (<-store.Post().Save(o4)).Data.(*model.Post)
+ o4 = (<-store.Post().Save(utils.T, o4)).Data.(*model.Post)
o5 := &model.Post{}
o5.ChannelId = c1.Id
o5.UserId = model.NewId()
o5.Hashtags = "#secret #howdy"
- o5 = (<-store.Post().Save(o5)).Data.(*model.Post)
+ o5 = (<-store.Post().Save(utils.T, o5)).Data.(*model.Post)
- r1 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "corey", IsHashtag: false})).Data.(*model.PostList)
+ r1 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "corey", IsHashtag: false})).Data.(*model.PostList)
if len(r1.Order) != 1 || r1.Order[0] != o1.Id {
t.Fatal("returned wrong search result")
}
- r3 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "new", IsHashtag: false})).Data.(*model.PostList)
+ r3 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "new", IsHashtag: false})).Data.(*model.PostList)
if len(r3.Order) != 2 || (r3.Order[0] != o1.Id && r3.Order[1] != o1.Id) {
t.Fatal("returned wrong search result")
}
- r4 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "john", IsHashtag: false})).Data.(*model.PostList)
+ r4 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "john", IsHashtag: false})).Data.(*model.PostList)
if len(r4.Order) != 1 || r4.Order[0] != o2.Id {
t.Fatal("returned wrong search result")
}
- r5 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "matter*", IsHashtag: false})).Data.(*model.PostList)
+ r5 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "matter*", IsHashtag: false})).Data.(*model.PostList)
if len(r5.Order) != 1 || r5.Order[0] != o1.Id {
t.Fatal("returned wrong search result")
}
- r6 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "#hashtag", IsHashtag: true})).Data.(*model.PostList)
+ r6 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "#hashtag", IsHashtag: true})).Data.(*model.PostList)
if len(r6.Order) != 1 || r6.Order[0] != o4.Id {
t.Fatal("returned wrong search result")
}
- r7 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "#secret", IsHashtag: true})).Data.(*model.PostList)
+ r7 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "#secret", IsHashtag: true})).Data.(*model.PostList)
if len(r7.Order) != 1 || r7.Order[0] != o5.Id {
t.Fatal("returned wrong search result")
}
- r8 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "@thisshouldmatchnothing", IsHashtag: true})).Data.(*model.PostList)
+ r8 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "@thisshouldmatchnothing", IsHashtag: true})).Data.(*model.PostList)
if len(r8.Order) != 0 {
t.Fatal("returned wrong search result")
}
- r9 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "mattermost jersey", IsHashtag: false})).Data.(*model.PostList)
+ r9 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "mattermost jersey", IsHashtag: false})).Data.(*model.PostList)
if len(r9.Order) != 2 {
t.Fatal("returned wrong search result")
}
- r10 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "matter* jer*", IsHashtag: false})).Data.(*model.PostList)
+ r10 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "matter* jer*", IsHashtag: false})).Data.(*model.PostList)
if len(r10.Order) != 2 {
t.Fatal("returned wrong search result")
}
- r11 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "message blargh", IsHashtag: false})).Data.(*model.PostList)
+ r11 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "message blargh", IsHashtag: false})).Data.(*model.PostList)
if len(r11.Order) != 1 {
t.Fatal("returned wrong search result")
}
- r12 := (<-store.Post().Search(teamId, userId, &model.SearchParams{Terms: "blargh>", IsHashtag: false})).Data.(*model.PostList)
+ r12 := (<-store.Post().Search(utils.T, teamId, userId, &model.SearchParams{Terms: "blargh>", IsHashtag: false})).Data.(*model.PostList)
if len(r12.Order) != 1 {
t.Fatal("returned wrong search result")
}
@@ -765,44 +765,44 @@ func TestUserCountsWithPostsByDay(t *testing.T) {
t1.Name = "a" + model.NewId() + "b"
t1.Email = model.NewId() + "@nowhere.com"
t1.Type = model.TEAM_OPEN
- t1 = Must(store.Team().Save(t1)).(*model.Team)
+ t1 = Must(store.Team().Save(utils.T, t1)).(*model.Team)
c1 := &model.Channel{}
c1.TeamId = t1.Id
c1.DisplayName = "Channel2"
c1.Name = "a" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
- c1 = Must(store.Channel().Save(c1)).(*model.Channel)
+ c1 = Must(store.Channel().Save(utils.T, c1)).(*model.Channel)
o1 := &model.Post{}
o1.ChannelId = c1.Id
o1.UserId = model.NewId()
o1.CreateAt = utils.MillisFromTime(utils.Yesterday())
o1.Message = "a" + model.NewId() + "b"
- o1 = Must(store.Post().Save(o1)).(*model.Post)
+ o1 = Must(store.Post().Save(utils.T, o1)).(*model.Post)
o1a := &model.Post{}
o1a.ChannelId = c1.Id
o1a.UserId = model.NewId()
o1a.CreateAt = o1.CreateAt
o1a.Message = "a" + model.NewId() + "b"
- o1a = Must(store.Post().Save(o1a)).(*model.Post)
+ o1a = Must(store.Post().Save(utils.T, o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = model.NewId()
o2.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24)
o2.Message = "a" + model.NewId() + "b"
- o2 = Must(store.Post().Save(o2)).(*model.Post)
+ o2 = Must(store.Post().Save(utils.T, o2)).(*model.Post)
o2a := &model.Post{}
o2a.ChannelId = c1.Id
o2a.UserId = o2.UserId
o2a.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24)
o2a.Message = "a" + model.NewId() + "b"
- o2a = Must(store.Post().Save(o2a)).(*model.Post)
+ o2a = Must(store.Post().Save(utils.T, o2a)).(*model.Post)
- if r1 := <-store.Post().AnalyticsUserCountsWithPostsByDay(t1.Id); r1.Err != nil {
+ if r1 := <-store.Post().AnalyticsUserCountsWithPostsByDay(utils.T, t1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
row1 := r1.Data.(model.AnalyticsRows)[0]
@@ -825,47 +825,47 @@ func TestPostCountsByDay(t *testing.T) {
t1.Name = "a" + model.NewId() + "b"
t1.Email = model.NewId() + "@nowhere.com"
t1.Type = model.TEAM_OPEN
- t1 = Must(store.Team().Save(t1)).(*model.Team)
+ t1 = Must(store.Team().Save(utils.T, t1)).(*model.Team)
c1 := &model.Channel{}
c1.TeamId = t1.Id
c1.DisplayName = "Channel2"
c1.Name = "a" + model.NewId() + "b"
c1.Type = model.CHANNEL_OPEN
- c1 = Must(store.Channel().Save(c1)).(*model.Channel)
+ c1 = Must(store.Channel().Save(utils.T, c1)).(*model.Channel)
o1 := &model.Post{}
o1.ChannelId = c1.Id
o1.UserId = model.NewId()
o1.CreateAt = utils.MillisFromTime(utils.Yesterday())
o1.Message = "a" + model.NewId() + "b"
- o1 = Must(store.Post().Save(o1)).(*model.Post)
+ o1 = Must(store.Post().Save(utils.T, o1)).(*model.Post)
o1a := &model.Post{}
o1a.ChannelId = c1.Id
o1a.UserId = model.NewId()
o1a.CreateAt = o1.CreateAt
o1a.Message = "a" + model.NewId() + "b"
- o1a = Must(store.Post().Save(o1a)).(*model.Post)
+ o1a = Must(store.Post().Save(utils.T, o1a)).(*model.Post)
o2 := &model.Post{}
o2.ChannelId = c1.Id
o2.UserId = model.NewId()
o2.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24 * 2)
o2.Message = "a" + model.NewId() + "b"
- o2 = Must(store.Post().Save(o2)).(*model.Post)
+ o2 = Must(store.Post().Save(utils.T, o2)).(*model.Post)
o2a := &model.Post{}
o2a.ChannelId = c1.Id
o2a.UserId = o2.UserId
o2a.CreateAt = o1.CreateAt - (1000 * 60 * 60 * 24 * 2)
o2a.Message = "a" + model.NewId() + "b"
- o2a = Must(store.Post().Save(o2a)).(*model.Post)
+ o2a = Must(store.Post().Save(utils.T, o2a)).(*model.Post)
time.Sleep(1 * time.Second)
t.Log(t1.Id)
- if r1 := <-store.Post().AnalyticsPostCountsByDay(t1.Id); r1.Err != nil {
+ if r1 := <-store.Post().AnalyticsPostCountsByDay(utils.T, t1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
row1 := r1.Data.(model.AnalyticsRows)[0]
@@ -880,7 +880,7 @@ func TestPostCountsByDay(t *testing.T) {
}
}
- if r1 := <-store.Post().AnalyticsPostCount(t1.Id); r1.Err != nil {
+ if r1 := <-store.Post().AnalyticsPostCount(utils.T, t1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(int64) != 4 {
diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go
index 6302d2f4f..234396058 100644
--- a/store/sql_preference_store.go
+++ b/store/sql_preference_store.go
@@ -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() {
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go
index ec9d1df6c..c93831b37 100644
--- a/store/sql_preference_store_test.go
+++ b/store/sql_preference_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
)
@@ -27,24 +28,24 @@ func TestPreferenceSave(t *testing.T) {
Value: "value1b",
},
}
- if count := Must(store.Preference().Save(&preferences)); count != 2 {
+ if count := Must(store.Preference().Save(utils.T, &preferences)); count != 2 {
t.Fatal("got incorrect number of rows saved")
}
for _, preference := range preferences {
- if data := Must(store.Preference().Get(preference.UserId, preference.Category, preference.Name)).(model.Preference); preference != data {
+ if data := Must(store.Preference().Get(utils.T, preference.UserId, preference.Category, preference.Name)).(model.Preference); preference != data {
t.Fatal("got incorrect preference after first Save")
}
}
preferences[0].Value = "value2a"
preferences[1].Value = "value2b"
- if count := Must(store.Preference().Save(&preferences)); count != 2 {
+ if count := Must(store.Preference().Save(utils.T, &preferences)); count != 2 {
t.Fatal("got incorrect number of rows saved")
}
for _, preference := range preferences {
- if data := Must(store.Preference().Get(preference.UserId, preference.Category, preference.Name)).(model.Preference); preference != data {
+ if data := Must(store.Preference().Get(utils.T, preference.UserId, preference.Category, preference.Name)).(model.Preference); preference != data {
t.Fatal("got incorrect preference after second Save")
}
}
@@ -80,16 +81,16 @@ func TestPreferenceGet(t *testing.T) {
},
}
- Must(store.Preference().Save(&preferences))
+ Must(store.Preference().Save(utils.T, &preferences))
- if result := <-store.Preference().Get(userId, category, name); result.Err != nil {
+ if result := <-store.Preference().Get(utils.T, userId, category, name); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(model.Preference); data != preferences[0] {
t.Fatal("got incorrect preference")
}
// make sure getting a missing preference fails
- if result := <-store.Preference().Get(model.NewId(), model.NewId(), model.NewId()); result.Err == nil {
+ if result := <-store.Preference().Get(utils.T, model.NewId(), model.NewId(), model.NewId()); result.Err == nil {
t.Fatal("no error on getting a missing preference")
}
}
@@ -127,9 +128,9 @@ func TestPreferenceGetCategory(t *testing.T) {
},
}
- Must(store.Preference().Save(&preferences))
+ Must(store.Preference().Save(utils.T, &preferences))
- if result := <-store.Preference().GetCategory(userId, category); result.Err != nil {
+ if result := <-store.Preference().GetCategory(utils.T, userId, category); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(model.Preferences); len(data) != 2 {
t.Fatal("got the wrong number of preferences")
@@ -138,7 +139,7 @@ func TestPreferenceGetCategory(t *testing.T) {
}
// make sure getting a missing preference category doesn't fail
- if result := <-store.Preference().GetCategory(model.NewId(), model.NewId()); result.Err != nil {
+ if result := <-store.Preference().GetCategory(utils.T, model.NewId(), model.NewId()); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(model.Preferences); len(data) != 0 {
t.Fatal("shouldn't have got any preferences")
@@ -178,9 +179,9 @@ func TestPreferenceGetAll(t *testing.T) {
},
}
- Must(store.Preference().Save(&preferences))
+ Must(store.Preference().Save(utils.T, &preferences))
- if result := <-store.Preference().GetAll(userId); result.Err != nil {
+ if result := <-store.Preference().GetAll(utils.T, userId); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(model.Preferences); len(data) != 3 {
t.Fatal("got the wrong number of preferences")
@@ -226,9 +227,9 @@ func TestPreferenceDelete(t *testing.T) {
},
}
- Must(store.Preference().Save(&preferences))
+ Must(store.Preference().Save(utils.T, &preferences))
- if result := <-store.Preference().PermanentDeleteByUser(userId); result.Err != nil {
+ if result := <-store.Preference().PermanentDeleteByUser(utils.T, userId); result.Err != nil {
t.Fatal(result.Err)
}
}
@@ -276,29 +277,29 @@ func TestIsFeatureEnabled(t *testing.T) {
},
}
- Must(store.Preference().Save(&features))
+ Must(store.Preference().Save(utils.T, &features))
- if result := <-store.Preference().IsFeatureEnabled(feature1, userId); result.Err != nil {
+ if result := <-store.Preference().IsFeatureEnabled(utils.T, feature1, userId); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(bool); data != true {
t.Fatalf("got incorrect setting for feature1, %v=%v", true, data)
}
- if result := <-store.Preference().IsFeatureEnabled(feature2, userId); result.Err != nil {
+ if result := <-store.Preference().IsFeatureEnabled(utils.T, feature2, userId); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(bool); data != false {
t.Fatalf("got incorrect setting for feature2, %v=%v", false, data)
}
// make sure we get false if something different than "true" or "false" has been saved to database
- if result := <-store.Preference().IsFeatureEnabled(feature3, userId); result.Err != nil {
+ if result := <-store.Preference().IsFeatureEnabled(utils.T, feature3, userId); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(bool); data != false {
t.Fatalf("got incorrect setting for feature3, %v=%v", false, data)
}
// make sure false is returned if a non-existent feature is queried
- if result := <-store.Preference().IsFeatureEnabled("someOtherFeature", userId); result.Err != nil {
+ if result := <-store.Preference().IsFeatureEnabled(utils.T, "someOtherFeature", userId); result.Err != nil {
t.Fatal(result.Err)
} else if data := result.Data.(bool); data != false {
t.Fatalf("got incorrect setting for non-existent feature 'someOtherFeature', %v=%v", false, data)
@@ -341,9 +342,9 @@ func TestDeleteUnusedFeatures(t *testing.T) {
},
}
- Must(store.Preference().Save(&features))
+ Must(store.Preference().Save(utils.T, &features))
- store.(*SqlStore).preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
+ store.(*SqlStore).preference.(*SqlPreferenceStore).DeleteUnusedFeatures(utils.T)
//make sure features with value "false" have actually been deleted from the database
if val, err := store.(*SqlStore).preference.(*SqlPreferenceStore).GetReplica().SelectInt(`SELECT COUNT(*)
diff --git a/store/sql_session_store.go b/store/sql_session_store.go
index 6b0a31443..e66b8529a 100644
--- a/store/sql_session_store.go
+++ b/store/sql_session_store.go
@@ -6,6 +6,7 @@ package store
import (
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlSessionStore struct {
@@ -37,7 +38,7 @@ func (me SqlSessionStore) CreateIndexesIfNotExists() {
me.CreateIndexIfNotExists("idx_sessions_token", "Sessions", "Token")
}
-func (me SqlSessionStore) Save(session *model.Session) StoreChannel {
+func (me SqlSessionStore) Save(T goi18n.TranslateFunc, session *model.Session) StoreChannel {
storeChannel := make(StoreChannel)
@@ -53,7 +54,7 @@ func (me SqlSessionStore) Save(session *model.Session) StoreChannel {
session.PreSave()
- if cur := <-me.CleanUpExpiredSessions(session.UserId); cur.Err != nil {
+ if cur := <-me.CleanUpExpiredSessions(T, session.UserId); cur.Err != nil {
l4g.Error("Failed to cleanup sessions in Save err=%v", cur.Err)
}
@@ -70,7 +71,7 @@ func (me SqlSessionStore) Save(session *model.Session) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) Get(sessionIdOrToken string) StoreChannel {
+func (me SqlSessionStore) Get(T goi18n.TranslateFunc, sessionIdOrToken string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -95,12 +96,12 @@ func (me SqlSessionStore) Get(sessionIdOrToken string) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) GetSessions(userId string) StoreChannel {
+func (me SqlSessionStore) GetSessions(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
- if cur := <-me.CleanUpExpiredSessions(userId); cur.Err != nil {
+ if cur := <-me.CleanUpExpiredSessions(T, userId); cur.Err != nil {
l4g.Error("Failed to cleanup sessions in getSessions err=%v", cur.Err)
}
@@ -122,7 +123,7 @@ func (me SqlSessionStore) GetSessions(userId string) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel {
+func (me SqlSessionStore) Remove(T goi18n.TranslateFunc, sessionIdOrToken string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -140,7 +141,7 @@ func (me SqlSessionStore) Remove(sessionIdOrToken string) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) RemoveAllSessionsForTeam(teamId string) StoreChannel {
+func (me SqlSessionStore) RemoveAllSessionsForTeam(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -158,7 +159,7 @@ func (me SqlSessionStore) RemoveAllSessionsForTeam(teamId string) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) PermanentDeleteSessionsByUser(userId string) StoreChannel {
+func (me SqlSessionStore) PermanentDeleteSessionsByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -176,7 +177,7 @@ func (me SqlSessionStore) PermanentDeleteSessionsByUser(userId string) StoreChan
return storeChannel
}
-func (me SqlSessionStore) CleanUpExpiredSessions(userId string) StoreChannel {
+func (me SqlSessionStore) CleanUpExpiredSessions(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -195,7 +196,7 @@ func (me SqlSessionStore) CleanUpExpiredSessions(userId string) StoreChannel {
return storeChannel
}
-func (me SqlSessionStore) UpdateLastActivityAt(sessionId string, time int64) StoreChannel {
+func (me SqlSessionStore) UpdateLastActivityAt(T goi18n.TranslateFunc, sessionId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -214,7 +215,7 @@ func (me SqlSessionStore) UpdateLastActivityAt(sessionId string, time int64) Sto
return storeChannel
}
-func (me SqlSessionStore) UpdateRoles(userId, roles string) StoreChannel {
+func (me SqlSessionStore) UpdateRoles(T goi18n.TranslateFunc, userId, roles string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_session_store_test.go b/store/sql_session_store_test.go
index cec8e93b0..73ec59fb0 100644
--- a/store/sql_session_store_test.go
+++ b/store/sql_session_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
)
@@ -15,7 +16,7 @@ func TestSessionStoreSave(t *testing.T) {
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- if err := (<-store.Session().Save(&s1)).Err; err != nil {
+ if err := (<-store.Session().Save(utils.T, &s1)).Err; err != nil {
t.Fatal(err)
}
}
@@ -26,20 +27,20 @@ func TestSessionGet(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
s2 := model.Session{}
s2.UserId = s1.UserId
s2.TeamId = s1.TeamId
- Must(store.Session().Save(&s2))
+ Must(store.Session().Save(utils.T, &s2))
s3 := model.Session{}
s3.UserId = s1.UserId
s3.TeamId = s1.TeamId
s3.ExpiresAt = 1
- Must(store.Session().Save(&s3))
+ Must(store.Session().Save(utils.T, &s3))
- if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
+ if rs1 := (<-store.Session().Get(utils.T, s1.Id)); rs1.Err != nil {
t.Fatal(rs1.Err)
} else {
if rs1.Data.(*model.Session).Id != s1.Id {
@@ -47,7 +48,7 @@ func TestSessionGet(t *testing.T) {
}
}
- if rs2 := (<-store.Session().GetSessions(s1.UserId)); rs2.Err != nil {
+ if rs2 := (<-store.Session().GetSessions(utils.T, s1.UserId)); rs2.Err != nil {
t.Fatal(rs2.Err)
} else {
if len(rs2.Data.([]*model.Session)) != 2 {
@@ -63,9 +64,9 @@ func TestSessionRemove(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
+ if rs1 := (<-store.Session().Get(utils.T, s1.Id)); rs1.Err != nil {
t.Fatal(rs1.Err)
} else {
if rs1.Data.(*model.Session).Id != s1.Id {
@@ -73,9 +74,9 @@ func TestSessionRemove(t *testing.T) {
}
}
- Must(store.Session().Remove(s1.Id))
+ Must(store.Session().Remove(utils.T, s1.Id))
- if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil {
+ if rs2 := (<-store.Session().Get(utils.T, s1.Id)); rs2.Err == nil {
t.Fatal("should have been removed")
}
}
@@ -86,9 +87,9 @@ func TestSessionRemoveAll(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
+ if rs1 := (<-store.Session().Get(utils.T, s1.Id)); rs1.Err != nil {
t.Fatal(rs1.Err)
} else {
if rs1.Data.(*model.Session).Id != s1.Id {
@@ -96,9 +97,9 @@ func TestSessionRemoveAll(t *testing.T) {
}
}
- Must(store.Session().RemoveAllSessionsForTeam(s1.TeamId))
+ Must(store.Session().RemoveAllSessionsForTeam(utils.T, s1.TeamId))
- if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil {
+ if rs2 := (<-store.Session().Get(utils.T, s1.Id)); rs2.Err == nil {
t.Fatal("should have been removed")
}
}
@@ -109,9 +110,9 @@ func TestSessionRemoveByUser(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
+ if rs1 := (<-store.Session().Get(utils.T, s1.Id)); rs1.Err != nil {
t.Fatal(rs1.Err)
} else {
if rs1.Data.(*model.Session).Id != s1.Id {
@@ -119,9 +120,9 @@ func TestSessionRemoveByUser(t *testing.T) {
}
}
- Must(store.Session().PermanentDeleteSessionsByUser(s1.UserId))
+ Must(store.Session().PermanentDeleteSessionsByUser(utils.T, s1.UserId))
- if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil {
+ if rs2 := (<-store.Session().Get(utils.T, s1.Id)); rs2.Err == nil {
t.Fatal("should have been removed")
}
}
@@ -132,9 +133,9 @@ func TestSessionRemoveToken(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if rs1 := (<-store.Session().Get(s1.Id)); rs1.Err != nil {
+ if rs1 := (<-store.Session().Get(utils.T, s1.Id)); rs1.Err != nil {
t.Fatal(rs1.Err)
} else {
if rs1.Data.(*model.Session).Id != s1.Id {
@@ -142,13 +143,13 @@ func TestSessionRemoveToken(t *testing.T) {
}
}
- Must(store.Session().Remove(s1.Token))
+ Must(store.Session().Remove(utils.T, s1.Token))
- if rs2 := (<-store.Session().Get(s1.Id)); rs2.Err == nil {
+ if rs2 := (<-store.Session().Get(utils.T, s1.Id)); rs2.Err == nil {
t.Fatal("should have been removed")
}
- if rs3 := (<-store.Session().GetSessions(s1.UserId)); rs3.Err != nil {
+ if rs3 := (<-store.Session().GetSessions(utils.T, s1.UserId)); rs3.Err != nil {
t.Fatal(rs3.Err)
} else {
if len(rs3.Data.([]*model.Session)) != 0 {
@@ -163,13 +164,13 @@ func TestSessionStoreUpdateLastActivityAt(t *testing.T) {
s1 := model.Session{}
s1.UserId = model.NewId()
s1.TeamId = model.NewId()
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if err := (<-store.Session().UpdateLastActivityAt(s1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.Session().UpdateLastActivityAt(utils.T, s1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.Session().Get(s1.Id); r1.Err != nil {
+ if r1 := <-store.Session().Get(utils.T, s1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Session).LastActivityAt != 1234567890 {
diff --git a/store/sql_store.go b/store/sql_store.go
index d0471fa1e..40d9c7f5a 100644
--- a/store/sql_store.go
+++ b/store/sql_store.go
@@ -15,7 +15,6 @@ import (
"encoding/json"
"errors"
"fmt"
- l4g "github.com/alecthomas/log4go"
"io"
sqltrace "log"
"math/rand"
@@ -23,6 +22,7 @@ import (
"strings"
"time"
+ l4g "github.com/alecthomas/log4go"
"github.com/go-gorp/gorp"
_ "github.com/go-sql-driver/mysql"
_ "github.com/lib/pq"
@@ -148,15 +148,15 @@ func NewSqlStore() Store {
sqlStore.webhook.(*SqlWebhookStore).CreateIndexesIfNotExists()
sqlStore.preference.(*SqlPreferenceStore).CreateIndexesIfNotExists()
- sqlStore.preference.(*SqlPreferenceStore).DeleteUnusedFeatures()
+ sqlStore.preference.(*SqlPreferenceStore).DeleteUnusedFeatures(utils.T)
if model.IsPreviousVersion(schemaVersion) || isSchemaVersion07 || isSchemaVersion10 {
- sqlStore.system.Update(&model.System{Name: "Version", Value: model.CurrentVersion})
+ sqlStore.system.Update(utils.T, &model.System{Name: "Version", Value: model.CurrentVersion})
l4g.Warn("The database schema has been upgraded to version " + model.CurrentVersion)
}
if schemaVersion == "" {
- sqlStore.system.Save(&model.System{Name: "Version", Value: model.CurrentVersion})
+ sqlStore.system.Save(utils.T, &model.System{Name: "Version", Value: model.CurrentVersion})
l4g.Info("The database schema has been set to version " + model.CurrentVersion)
}
@@ -210,12 +210,12 @@ func (ss SqlStore) GetCurrentSchemaVersion() string {
}
func (ss SqlStore) MarkSystemRanUnitTests() {
- if result := <-ss.System().Get(); result.Err == nil {
+ if result := <-ss.System().Get(utils.T); result.Err == nil {
props := result.Data.(model.StringMap)
unitTests := props[model.SYSTEM_RAN_UNIT_TESTS]
if len(unitTests) == 0 {
systemTests := &model.System{Name: model.SYSTEM_RAN_UNIT_TESTS, Value: "1"}
- <-ss.System().Save(systemTests)
+ <-ss.System().Save(utils.T, systemTests)
}
}
}
diff --git a/store/sql_system_store.go b/store/sql_system_store.go
index 1fbdfb333..184e8569f 100644
--- a/store/sql_system_store.go
+++ b/store/sql_system_store.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlSystemStore struct {
@@ -29,7 +30,7 @@ func (s SqlSystemStore) UpgradeSchemaIfNeeded() {
func (s SqlSystemStore) CreateIndexesIfNotExists() {
}
-func (s SqlSystemStore) Save(system *model.System) StoreChannel {
+func (s SqlSystemStore) Save(T goi18n.TranslateFunc, system *model.System) StoreChannel {
storeChannel := make(StoreChannel)
@@ -47,7 +48,7 @@ func (s SqlSystemStore) Save(system *model.System) StoreChannel {
return storeChannel
}
-func (s SqlSystemStore) Update(system *model.System) StoreChannel {
+func (s SqlSystemStore) Update(T goi18n.TranslateFunc, system *model.System) StoreChannel {
storeChannel := make(StoreChannel)
@@ -65,7 +66,7 @@ func (s SqlSystemStore) Update(system *model.System) StoreChannel {
return storeChannel
}
-func (s SqlSystemStore) Get() StoreChannel {
+func (s SqlSystemStore) Get(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/sql_system_store_test.go b/store/sql_system_store_test.go
index 8ff5445cc..5817f9735 100644
--- a/store/sql_system_store_test.go
+++ b/store/sql_system_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
)
@@ -12,9 +13,9 @@ func TestSqlSystemStore(t *testing.T) {
Setup()
system := &model.System{Name: model.NewId(), Value: "value"}
- Must(store.System().Save(system))
+ Must(store.System().Save(utils.T, system))
- result := <-store.System().Get()
+ result := <-store.System().Get(utils.T)
systems := result.Data.(model.StringMap)
if systems[system.Name] != system.Value {
@@ -22,9 +23,9 @@ func TestSqlSystemStore(t *testing.T) {
}
system.Value = "value2"
- Must(store.System().Update(system))
+ Must(store.System().Update(utils.T, system))
- result2 := <-store.System().Get()
+ result2 := <-store.System().Get(utils.T)
systems2 := result2.Data.(model.StringMap)
if systems2[system.Name] != system.Value {
diff --git a/store/sql_team_store.go b/store/sql_team_store.go
index 9578549ca..6c2eb6a21 100644
--- a/store/sql_team_store.go
+++ b/store/sql_team_store.go
@@ -6,6 +6,7 @@ package store
import (
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlTeamStore struct {
@@ -37,7 +38,7 @@ func (s SqlTeamStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_teams_invite_id", "Teams", "InviteId")
}
-func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
+func (s SqlTeamStore) Save(T goi18n.TranslateFunc, team *model.Team) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -76,7 +77,7 @@ func (s SqlTeamStore) Save(team *model.Team) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) Update(team *model.Team) StoreChannel {
+func (s SqlTeamStore) Update(T goi18n.TranslateFunc, team *model.Team) StoreChannel {
storeChannel := make(StoreChannel)
@@ -117,7 +118,7 @@ func (s SqlTeamStore) Update(team *model.Team) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) UpdateDisplayName(name string, teamId string) StoreChannel {
+func (s SqlTeamStore) UpdateDisplayName(T goi18n.TranslateFunc, name string, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -137,7 +138,7 @@ func (s SqlTeamStore) UpdateDisplayName(name string, teamId string) StoreChannel
return storeChannel
}
-func (s SqlTeamStore) Get(id string) StoreChannel {
+func (s SqlTeamStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -163,7 +164,7 @@ func (s SqlTeamStore) Get(id string) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
+func (s SqlTeamStore) GetByInviteId(T goi18n.TranslateFunc, inviteId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -192,7 +193,7 @@ func (s SqlTeamStore) GetByInviteId(inviteId string) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) GetByName(name string) StoreChannel {
+func (s SqlTeamStore) GetByName(T goi18n.TranslateFunc, name string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -217,7 +218,7 @@ func (s SqlTeamStore) GetByName(name string) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
+func (s SqlTeamStore) GetTeamsForEmail(T goi18n.TranslateFunc, email string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -243,7 +244,7 @@ func (s SqlTeamStore) GetTeamsForEmail(email string) StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) GetAll() StoreChannel {
+func (s SqlTeamStore) GetAll(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -269,7 +270,7 @@ func (s SqlTeamStore) GetAll() StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
+func (s SqlTeamStore) GetAllTeamListing(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -301,7 +302,7 @@ func (s SqlTeamStore) GetAllTeamListing() StoreChannel {
return storeChannel
}
-func (s SqlTeamStore) PermanentDelete(teamId string) StoreChannel {
+func (s SqlTeamStore) PermanentDelete(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_team_store_test.go b/store/sql_team_store_test.go
index 7dc31cbe2..90f4772f1 100644
--- a/store/sql_team_store_test.go
+++ b/store/sql_team_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
"time"
)
@@ -18,16 +19,16 @@ func TestTeamStoreSave(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- if err := (<-store.Team().Save(&o1)).Err; err != nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
- if err := (<-store.Team().Save(&o1)).Err; err == nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
o1.Id = ""
- if err := (<-store.Team().Save(&o1)).Err; err == nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err == nil {
t.Fatal("should be unique domain")
}
}
@@ -40,23 +41,23 @@ func TestTeamStoreUpdate(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- if err := (<-store.Team().Save(&o1)).Err; err != nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
time.Sleep(100 * time.Millisecond)
- if err := (<-store.Team().Update(&o1)).Err; err != nil {
+ if err := (<-store.Team().Update(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
o1.Id = "missing"
- if err := (<-store.Team().Update(&o1)).Err; err == nil {
+ if err := (<-store.Team().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have failed because of missing key")
}
o1.Id = model.NewId()
- if err := (<-store.Team().Update(&o1)).Err; err == nil {
+ if err := (<-store.Team().Update(utils.T, &o1)).Err; err == nil {
t.Fatal("Update should have faile because id change")
}
}
@@ -69,15 +70,15 @@ func TestTeamStoreUpdateDisplayName(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- o1 = (<-store.Team().Save(o1)).Data.(*model.Team)
+ o1 = (<-store.Team().Save(utils.T, o1)).Data.(*model.Team)
newDisplayName := "NewDisplayName"
- if err := (<-store.Team().UpdateDisplayName(newDisplayName, o1.Id)).Err; err != nil {
+ if err := (<-store.Team().UpdateDisplayName(utils.T, newDisplayName, o1.Id)).Err; err != nil {
t.Fatal(err)
}
- ro1 := (<-store.Team().Get(o1.Id)).Data.(*model.Team)
+ ro1 := (<-store.Team().Get(utils.T, o1.Id)).Data.(*model.Team)
if ro1.DisplayName != newDisplayName {
t.Fatal("DisplayName not updated")
}
@@ -91,9 +92,9 @@ func TestTeamStoreGet(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- Must(store.Team().Save(&o1))
+ Must(store.Team().Save(utils.T, &o1))
- if r1 := <-store.Team().Get(o1.Id); r1.Err != nil {
+ if r1 := <-store.Team().Get(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
@@ -101,7 +102,7 @@ func TestTeamStoreGet(t *testing.T) {
}
}
- if err := (<-store.Team().Get("")).Err; err == nil {
+ if err := (<-store.Team().Get(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -115,11 +116,11 @@ func TestTeamStoreGetByName(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- if err := (<-store.Team().Save(&o1)).Err; err != nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.Team().GetByName(o1.Name); r1.Err != nil {
+ if r1 := <-store.Team().GetByName(utils.T, o1.Name); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
@@ -127,7 +128,7 @@ func TestTeamStoreGetByName(t *testing.T) {
}
}
- if err := (<-store.Team().GetByName("")).Err; err == nil {
+ if err := (<-store.Team().GetByName(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -142,7 +143,7 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
o1.Type = model.TEAM_OPEN
o1.InviteId = model.NewId()
- if err := (<-store.Team().Save(&o1)).Err; err != nil {
+ if err := (<-store.Team().Save(utils.T, &o1)).Err; err != nil {
t.Fatal(err)
}
@@ -152,11 +153,11 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
o2.Email = model.NewId() + "@nowhere.com"
o2.Type = model.TEAM_OPEN
- if err := (<-store.Team().Save(&o2)).Err; err != nil {
+ if err := (<-store.Team().Save(utils.T, &o2)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.Team().GetByInviteId(o1.InviteId); r1.Err != nil {
+ if r1 := <-store.Team().GetByInviteId(utils.T, o1.InviteId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).ToJson() != o1.ToJson() {
@@ -165,9 +166,9 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
}
o2.InviteId = ""
- <-store.Team().Update(&o2)
+ <-store.Team().Update(utils.T, &o2)
- if r1 := <-store.Team().GetByInviteId(o2.Id); r1.Err != nil {
+ if r1 := <-store.Team().GetByInviteId(utils.T, o2.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.Team).Id != o2.Id {
@@ -175,7 +176,7 @@ func TestTeamStoreGetByIniviteId(t *testing.T) {
}
}
- if err := (<-store.Team().GetByInviteId("")).Err; err == nil {
+ if err := (<-store.Team().GetByInviteId(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -188,14 +189,14 @@ func TestTeamStoreGetForEmail(t *testing.T) {
o1.Name = "a" + model.NewId() + "b"
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
- Must(store.Team().Save(&o1))
+ Must(store.Team().Save(utils.T, &o1))
u1 := model.User{}
u1.TeamId = o1.Id
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if r1 := <-store.Team().GetTeamsForEmail(u1.Email); r1.Err != nil {
+ if r1 := <-store.Team().GetTeamsForEmail(utils.T, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
@@ -205,7 +206,7 @@ func TestTeamStoreGetForEmail(t *testing.T) {
}
}
- if r1 := <-store.Team().GetTeamsForEmail("missing"); r1.Err != nil {
+ if r1 := <-store.Team().GetTeamsForEmail(utils.T, "missing"); r1.Err != nil {
t.Fatal(r1.Err)
}
}
@@ -219,16 +220,16 @@ func TestAllTeamListing(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
o1.AllowTeamListing = true
- Must(store.Team().Save(&o1))
+ Must(store.Team().Save(utils.T, &o1))
o2 := model.Team{}
o2.DisplayName = "DisplayName"
o2.Name = "a" + model.NewId() + "b"
o2.Email = model.NewId() + "@nowhere.com"
o2.Type = model.TEAM_OPEN
- Must(store.Team().Save(&o2))
+ Must(store.Team().Save(utils.T, &o2))
- if r1 := <-store.Team().GetAllTeamListing(); r1.Err != nil {
+ if r1 := <-store.Team().GetAllTeamListing(utils.T); r1.Err != nil {
t.Fatal(r1.Err)
} else {
teams := r1.Data.([]*model.Team)
@@ -248,16 +249,16 @@ func TestDelete(t *testing.T) {
o1.Email = model.NewId() + "@nowhere.com"
o1.Type = model.TEAM_OPEN
o1.AllowTeamListing = true
- Must(store.Team().Save(&o1))
+ Must(store.Team().Save(utils.T, &o1))
o2 := model.Team{}
o2.DisplayName = "DisplayName"
o2.Name = "a" + model.NewId() + "b"
o2.Email = model.NewId() + "@nowhere.com"
o2.Type = model.TEAM_OPEN
- Must(store.Team().Save(&o2))
+ Must(store.Team().Save(utils.T, &o2))
- if r1 := <-store.Team().PermanentDelete(o1.Id); r1.Err != nil {
+ if r1 := <-store.Team().PermanentDelete(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
}
}
diff --git a/store/sql_user_store.go b/store/sql_user_store.go
index 0f73f73c3..e17db6666 100644
--- a/store/sql_user_store.go
+++ b/store/sql_user_store.go
@@ -5,9 +5,11 @@ package store
import (
"fmt"
+ "strings"
+
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
- "strings"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
const (
@@ -54,7 +56,7 @@ func (us SqlUserStore) CreateIndexesIfNotExists() {
us.CreateIndexIfNotExists("idx_users_email", "Users", "Email")
}
-func (us SqlUserStore) Save(user *model.User) StoreChannel {
+func (us SqlUserStore) Save(T goi18n.TranslateFunc, user *model.User) StoreChannel {
storeChannel := make(StoreChannel)
@@ -106,7 +108,7 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreChannel {
+func (us SqlUserStore) Update(T goi18n.TranslateFunc, user *model.User, allowActiveUpdate bool) StoreChannel {
storeChannel := make(StoreChannel)
@@ -183,7 +185,7 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha
return storeChannel
}
-func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
+func (us SqlUserStore) UpdateLastPictureUpdate(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -204,7 +206,7 @@ func (us SqlUserStore) UpdateLastPictureUpdate(userId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateLastPingAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -223,7 +225,7 @@ func (us SqlUserStore) UpdateLastPingAt(userId string, time int64) StoreChannel
return storeChannel
}
-func (us SqlUserStore) UpdateLastActivityAt(userId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateLastActivityAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -242,7 +244,7 @@ func (us SqlUserStore) UpdateLastActivityAt(userId string, time int64) StoreChan
return storeChannel
}
-func (us SqlUserStore) UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel {
+func (us SqlUserStore) UpdateUserAndSessionActivity(T goi18n.TranslateFunc, userId string, sessionId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -263,7 +265,7 @@ func (us SqlUserStore) UpdateUserAndSessionActivity(userId string, sessionId str
return storeChannel
}
-func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) StoreChannel {
+func (us SqlUserStore) UpdatePassword(T goi18n.TranslateFunc, userId, hashedPassword string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -285,7 +287,7 @@ func (us SqlUserStore) UpdatePassword(userId, hashedPassword string) StoreChanne
return storeChannel
}
-func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel {
+func (us SqlUserStore) UpdateFailedPasswordAttempts(T goi18n.TranslateFunc, userId string, attempts int) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -304,7 +306,7 @@ func (us SqlUserStore) UpdateFailedPasswordAttempts(userId string, attempts int)
return storeChannel
}
-func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreChannel {
+func (us SqlUserStore) UpdateAuthData(T goi18n.TranslateFunc, userId, service, authData string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -326,7 +328,7 @@ func (us SqlUserStore) UpdateAuthData(userId, service, authData string) StoreCha
return storeChannel
}
-func (us SqlUserStore) Get(id string) StoreChannel {
+func (us SqlUserStore) Get(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -349,7 +351,7 @@ func (us SqlUserStore) Get(id string) StoreChannel {
return storeChannel
}
-func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
+func (s SqlUserStore) GetEtagForProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -369,7 +371,7 @@ func (s SqlUserStore) GetEtagForProfiles(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetProfiles(teamId string) StoreChannel {
+func (us SqlUserStore) GetProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -400,7 +402,7 @@ func (us SqlUserStore) GetProfiles(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetSystemAdminProfiles() StoreChannel {
+func (us SqlUserStore) GetSystemAdminProfiles(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
@@ -431,7 +433,7 @@ func (us SqlUserStore) GetSystemAdminProfiles() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel {
+func (us SqlUserStore) GetByEmail(T goi18n.TranslateFunc, teamId string, email string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -453,7 +455,7 @@ func (us SqlUserStore) GetByEmail(teamId string, email string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetByAuth(teamId string, authData string, authService string) StoreChannel {
+func (us SqlUserStore) GetByAuth(T goi18n.TranslateFunc, teamId string, authData string, authService string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -475,7 +477,7 @@ func (us SqlUserStore) GetByAuth(teamId string, authData string, authService str
return storeChannel
}
-func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChannel {
+func (us SqlUserStore) GetByUsername(T goi18n.TranslateFunc, teamId string, username string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -497,7 +499,7 @@ func (us SqlUserStore) GetByUsername(teamId string, username string) StoreChanne
return storeChannel
}
-func (us SqlUserStore) VerifyEmail(userId string) StoreChannel {
+func (us SqlUserStore) VerifyEmail(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -516,7 +518,7 @@ func (us SqlUserStore) VerifyEmail(userId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetForExport(teamId string) StoreChannel {
+func (us SqlUserStore) GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
@@ -543,7 +545,7 @@ func (us SqlUserStore) GetForExport(teamId string) StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetTotalUsersCount() StoreChannel {
+func (us SqlUserStore) GetTotalUsersCount(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -562,7 +564,7 @@ func (us SqlUserStore) GetTotalUsersCount() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel {
+func (us SqlUserStore) GetTotalActiveUsersCount(T goi18n.TranslateFunc) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -583,7 +585,7 @@ func (us SqlUserStore) GetTotalActiveUsersCount() StoreChannel {
return storeChannel
}
-func (us SqlUserStore) PermanentDelete(userId string) StoreChannel {
+func (us SqlUserStore) PermanentDelete(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/sql_user_store_test.go b/store/sql_user_store_test.go
index d1ee5e647..50296b251 100644
--- a/store/sql_user_store_test.go
+++ b/store/sql_user_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"strings"
"testing"
"time"
@@ -18,27 +19,27 @@ func TestUserStoreSave(t *testing.T) {
u1.Username = model.NewId()
u1.TeamId = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err != nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err != nil {
t.Fatal("couldn't save user", err)
}
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("shouldn't be able to update user from save")
}
u1.Id = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique email")
}
u1.Email = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique username")
}
u1.Email = strings.Repeat("0123456789", 20)
u1.Username = ""
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be unique username")
}
@@ -46,7 +47,7 @@ func TestUserStoreSave(t *testing.T) {
u1.Id = ""
u1.Email = model.NewId()
u1.Username = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err != nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
}
@@ -54,7 +55,7 @@ func TestUserStoreSave(t *testing.T) {
u1.Id = ""
u1.Email = model.NewId()
u1.Username = model.NewId()
- if err := (<-store.User().Save(&u1)).Err; err == nil {
+ if err := (<-store.User().Save(utils.T, &u1)).Err; err == nil {
t.Fatal("should be the limit", err)
}
}
@@ -65,21 +66,21 @@ func TestUserStoreUpdate(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
time.Sleep(100 * time.Millisecond)
- if err := (<-store.User().Update(&u1, false)).Err; err != nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err != nil {
t.Fatal(err)
}
u1.Id = "missing"
- if err := (<-store.User().Update(&u1, false)).Err; err == nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err == nil {
t.Fatal("Update should have failed because of missing key")
}
u1.Id = model.NewId()
- if err := (<-store.User().Update(&u1, false)).Err; err == nil {
+ if err := (<-store.User().Update(utils.T, &u1, false)).Err; err == nil {
t.Fatal("Update should have faile because id change")
}
}
@@ -90,13 +91,13 @@ func TestUserStoreUpdateLastPingAt(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateLastPingAt(u1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateLastPingAt(utils.T, u1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastPingAt != 1234567890 {
@@ -112,13 +113,13 @@ func TestUserStoreUpdateLastActivityAt(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateLastActivityAt(u1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateLastActivityAt(utils.T, u1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastActivityAt != 1234567890 {
@@ -134,13 +135,13 @@ func TestUserStoreUpdateFailedPasswordAttempts(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().UpdateFailedPasswordAttempts(u1.Id, 3)).Err; err != nil {
+ if err := (<-store.User().UpdateFailedPasswordAttempts(utils.T, u1.Id, 3)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).FailedAttempts != 3 {
@@ -156,18 +157,18 @@ func TestUserStoreUpdateUserAndSessionActivity(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
s1 := model.Session{}
s1.UserId = u1.Id
s1.TeamId = u1.TeamId
- Must(store.Session().Save(&s1))
+ Must(store.Session().Save(utils.T, &s1))
- if err := (<-store.User().UpdateUserAndSessionActivity(u1.Id, s1.Id, 1234567890)).Err; err != nil {
+ if err := (<-store.User().UpdateUserAndSessionActivity(utils.T, u1.Id, s1.Id, 1234567890)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).LastActivityAt != 1234567890 {
@@ -175,7 +176,7 @@ func TestUserStoreUpdateUserAndSessionActivity(t *testing.T) {
}
}
- if r2 := <-store.Session().Get(s1.Id); r2.Err != nil {
+ if r2 := <-store.Session().Get(utils.T, s1.Id); r2.Err != nil {
t.Fatal(r2.Err)
} else {
if r2.Data.(*model.Session).LastActivityAt != 1234567890 {
@@ -191,9 +192,9 @@ func TestUserStoreGet(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if r1 := <-store.User().Get(u1.Id); r1.Err != nil {
+ if r1 := <-store.User().Get(utils.T, u1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.User).ToJson() != u1.ToJson() {
@@ -201,7 +202,7 @@ func TestUserStoreGet(t *testing.T) {
}
}
- if err := (<-store.User().Get("")).Err; err == nil {
+ if err := (<-store.User().Get(utils.T, "")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -212,9 +213,9 @@ func TestUserCount(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if result := <-store.User().GetTotalUsersCount(); result.Err != nil {
+ if result := <-store.User().GetTotalUsersCount(utils.T); result.Err != nil {
t.Fatal(result.Err)
} else {
count := result.Data.(int64)
@@ -230,9 +231,9 @@ func TestActiveUserCount(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if result := <-store.User().GetTotalActiveUsersCount(); result.Err != nil {
+ if result := <-store.User().GetTotalActiveUsersCount(utils.T); result.Err != nil {
t.Fatal(result.Err)
} else {
count := result.Data.(int64)
@@ -248,14 +249,14 @@ func TestUserStoreGetProfiles(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = u1.TeamId
u2.Email = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
- if r1 := <-store.User().GetProfiles(u1.TeamId); r1.Err != nil {
+ if r1 := <-store.User().GetProfiles(utils.T, u1.TeamId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
users := r1.Data.(map[string]*model.User)
@@ -268,7 +269,7 @@ func TestUserStoreGetProfiles(t *testing.T) {
}
}
- if r2 := <-store.User().GetProfiles("123"); r2.Err != nil {
+ if r2 := <-store.User().GetProfiles(utils.T, "123"); r2.Err != nil {
t.Fatal(r2.Err)
} else {
if len(r2.Data.(map[string]*model.User)) != 0 {
@@ -283,14 +284,14 @@ func TestUserStoreGetSystemAdminProfiles(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
u2 := model.User{}
u2.TeamId = u1.TeamId
u2.Email = model.NewId()
- Must(store.User().Save(&u2))
+ Must(store.User().Save(utils.T, &u2))
- if r1 := <-store.User().GetSystemAdminProfiles(); r1.Err != nil {
+ if r1 := <-store.User().GetSystemAdminProfiles(utils.T); r1.Err != nil {
t.Fatal(r1.Err)
} else {
users := r1.Data.(map[string]*model.User)
@@ -306,13 +307,13 @@ func TestUserStoreGetByEmail(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByEmail(u1.TeamId, u1.Email)).Err; err != nil {
+ if err := (<-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByEmail("", "")).Err; err == nil {
+ if err := (<-store.User().GetByEmail(utils.T, "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing email")
}
}
@@ -325,13 +326,13 @@ func TestUserStoreGetByAuthData(t *testing.T) {
u1.Email = model.NewId()
u1.AuthData = "123"
u1.AuthService = "service"
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByAuth(u1.TeamId, u1.AuthData, u1.AuthService)).Err; err != nil {
+ if err := (<-store.User().GetByAuth(utils.T, u1.TeamId, u1.AuthData, u1.AuthService)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByAuth("", "", "")).Err; err == nil {
+ if err := (<-store.User().GetByAuth(utils.T, "", "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing auth data")
}
}
@@ -343,13 +344,13 @@ func TestUserStoreGetByUsername(t *testing.T) {
u1.TeamId = model.NewId()
u1.Email = model.NewId()
u1.Username = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().GetByUsername(u1.TeamId, u1.Username)).Err; err != nil {
+ if err := (<-store.User().GetByUsername(utils.T, u1.TeamId, u1.Username)).Err; err != nil {
t.Fatal(err)
}
- if err := (<-store.User().GetByUsername("", "")).Err; err == nil {
+ if err := (<-store.User().GetByUsername(utils.T, "", "")).Err; err == nil {
t.Fatal("Should have failed because of missing username")
}
}
@@ -360,15 +361,15 @@ func TestUserStoreUpdatePassword(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
hashedPassword := model.HashPassword("newpwd")
- if err := (<-store.User().UpdatePassword(u1.Id, hashedPassword)).Err; err != nil {
+ if err := (<-store.User().UpdatePassword(utils.T, u1.Id, hashedPassword)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().GetByEmail(u1.TeamId, u1.Email); r1.Err != nil {
+ if r1 := <-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
user := r1.Data.(*model.User)
@@ -384,9 +385,9 @@ func TestUserStoreDelete(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
- if err := (<-store.User().PermanentDelete(u1.Id)).Err; err != nil {
+ if err := (<-store.User().PermanentDelete(utils.T, u1.Id)).Err; err != nil {
t.Fatal(err)
}
}
@@ -397,16 +398,16 @@ func TestUserStoreUpdateAuthData(t *testing.T) {
u1 := model.User{}
u1.TeamId = model.NewId()
u1.Email = model.NewId()
- Must(store.User().Save(&u1))
+ Must(store.User().Save(utils.T, &u1))
service := "someservice"
authData := "1"
- if err := (<-store.User().UpdateAuthData(u1.Id, service, authData)).Err; err != nil {
+ if err := (<-store.User().UpdateAuthData(utils.T, u1.Id, service, authData)).Err; err != nil {
t.Fatal(err)
}
- if r1 := <-store.User().GetByEmail(u1.TeamId, u1.Email); r1.Err != nil {
+ if r1 := <-store.User().GetByEmail(utils.T, u1.TeamId, u1.Email); r1.Err != nil {
t.Fatal(r1.Err)
} else {
user := r1.Data.(*model.User)
diff --git a/store/sql_webhook_store.go b/store/sql_webhook_store.go
index b7bf0615f..8b1e8136b 100644
--- a/store/sql_webhook_store.go
+++ b/store/sql_webhook_store.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type SqlWebhookStore struct {
@@ -43,7 +44,7 @@ func (s SqlWebhookStore) CreateIndexesIfNotExists() {
s.CreateIndexIfNotExists("idx_outgoing_webhook_team_id", "OutgoingWebhooks", "TeamId")
}
-func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChannel {
+func (s SqlWebhookStore) SaveIncoming(T goi18n.TranslateFunc, webhook *model.IncomingWebhook) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -77,7 +78,7 @@ func (s SqlWebhookStore) SaveIncoming(webhook *model.IncomingWebhook) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) GetIncoming(id string) StoreChannel {
+func (s SqlWebhookStore) GetIncoming(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -98,7 +99,7 @@ func (s SqlWebhookStore) GetIncoming(id string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChannel {
+func (s SqlWebhookStore) DeleteIncoming(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -116,7 +117,7 @@ func (s SqlWebhookStore) DeleteIncoming(webhookId string, time int64) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChannel {
+func (s SqlWebhookStore) PermanentDeleteIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -134,7 +135,7 @@ func (s SqlWebhookStore) PermanentDeleteIncomingByUser(userId string) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) GetIncomingByUser(userId string) StoreChannel {
+func (s SqlWebhookStore) GetIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -155,7 +156,7 @@ func (s SqlWebhookStore) GetIncomingByUser(userId string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel {
+func (s SqlWebhookStore) GetIncomingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -176,7 +177,7 @@ func (s SqlWebhookStore) GetIncomingByChannel(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel {
+func (s SqlWebhookStore) SaveOutgoing(T goi18n.TranslateFunc, webhook *model.OutgoingWebhook) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -210,7 +211,7 @@ func (s SqlWebhookStore) SaveOutgoing(webhook *model.OutgoingWebhook) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) GetOutgoing(id string) StoreChannel {
+func (s SqlWebhookStore) GetOutgoing(T goi18n.TranslateFunc, id string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -231,7 +232,7 @@ func (s SqlWebhookStore) GetOutgoing(id string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) GetOutgoingByCreator(userId string) StoreChannel {
+func (s SqlWebhookStore) GetOutgoingByCreator(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -252,7 +253,7 @@ func (s SqlWebhookStore) GetOutgoingByCreator(userId string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) GetOutgoingByChannel(channelId string) StoreChannel {
+func (s SqlWebhookStore) GetOutgoingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -273,7 +274,7 @@ func (s SqlWebhookStore) GetOutgoingByChannel(channelId string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) GetOutgoingByTeam(teamId string) StoreChannel {
+func (s SqlWebhookStore) GetOutgoingByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -294,7 +295,7 @@ func (s SqlWebhookStore) GetOutgoingByTeam(teamId string) StoreChannel {
return storeChannel
}
-func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) StoreChannel {
+func (s SqlWebhookStore) DeleteOutgoing(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -312,7 +313,7 @@ func (s SqlWebhookStore) DeleteOutgoing(webhookId string, time int64) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChannel {
+func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(T goi18n.TranslateFunc, userId string) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
@@ -330,7 +331,7 @@ func (s SqlWebhookStore) PermanentDeleteOutgoingByUser(userId string) StoreChann
return storeChannel
}
-func (s SqlWebhookStore) UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel {
+func (s SqlWebhookStore) UpdateOutgoing(T goi18n.TranslateFunc, hook *model.OutgoingWebhook) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
diff --git a/store/sql_webhook_store_test.go b/store/sql_webhook_store_test.go
index 1a9d5be3b..c5bd95af7 100644
--- a/store/sql_webhook_store_test.go
+++ b/store/sql_webhook_store_test.go
@@ -5,6 +5,7 @@ package store
import (
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/utils"
"testing"
)
@@ -16,11 +17,11 @@ func TestWebhookStoreSaveIncoming(t *testing.T) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- if err := (<-store.Webhook().SaveIncoming(&o1)).Err; err != nil {
+ if err := (<-store.Webhook().SaveIncoming(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
- if err := (<-store.Webhook().SaveIncoming(&o1)).Err; err == nil {
+ if err := (<-store.Webhook().SaveIncoming(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
}
@@ -33,9 +34,9 @@ func TestWebhookStoreGetIncoming(t *testing.T) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+ o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook)
- if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt {
@@ -43,7 +44,7 @@ func TestWebhookStoreGetIncoming(t *testing.T) {
}
}
- if err := (<-store.Webhook().GetIncoming("123")).Err; err == nil {
+ if err := (<-store.Webhook().GetIncoming(utils.T, "123")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -56,9 +57,9 @@ func TestWebhookStoreGetIncomingByUser(t *testing.T) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+ o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook)
- if r1 := <-store.Webhook().GetIncomingByUser(o1.UserId); r1.Err != nil {
+ if r1 := <-store.Webhook().GetIncomingByUser(utils.T, o1.UserId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.([]*model.IncomingWebhook)[0].CreateAt != o1.CreateAt {
@@ -66,7 +67,7 @@ func TestWebhookStoreGetIncomingByUser(t *testing.T) {
}
}
- if result := <-store.Webhook().GetIncomingByUser("123"); result.Err != nil {
+ if result := <-store.Webhook().GetIncomingByUser(utils.T, "123"); result.Err != nil {
t.Fatal(result.Err)
} else {
if len(result.Data.([]*model.IncomingWebhook)) != 0 {
@@ -83,9 +84,9 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+ o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook)
- if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt {
@@ -93,11 +94,11 @@ func TestWebhookStoreDeleteIncoming(t *testing.T) {
}
}
- if r2 := <-store.Webhook().DeleteIncoming(o1.Id, model.GetMillis()); r2.Err != nil {
+ if r2 := <-store.Webhook().DeleteIncoming(utils.T, o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Webhook().GetIncoming(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Webhook().GetIncoming(utils.T, o1.Id)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
}
@@ -111,9 +112,9 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) {
o1.UserId = model.NewId()
o1.TeamId = model.NewId()
- o1 = (<-store.Webhook().SaveIncoming(o1)).Data.(*model.IncomingWebhook)
+ o1 = (<-store.Webhook().SaveIncoming(utils.T, o1)).Data.(*model.IncomingWebhook)
- if r1 := <-store.Webhook().GetIncoming(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetIncoming(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.IncomingWebhook).CreateAt != o1.CreateAt {
@@ -121,11 +122,11 @@ func TestWebhookStoreDeleteIncomingByUser(t *testing.T) {
}
}
- if r2 := <-store.Webhook().PermanentDeleteIncomingByUser(o1.UserId); r2.Err != nil {
+ if r2 := <-store.Webhook().PermanentDeleteIncomingByUser(utils.T, o1.UserId); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Webhook().GetIncoming(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Webhook().GetIncoming(utils.T, o1.Id)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
}
@@ -140,11 +141,11 @@ func TestWebhookStoreSaveOutgoing(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- if err := (<-store.Webhook().SaveOutgoing(&o1)).Err; err != nil {
+ if err := (<-store.Webhook().SaveOutgoing(utils.T, &o1)).Err; err != nil {
t.Fatal("couldn't save item", err)
}
- if err := (<-store.Webhook().SaveOutgoing(&o1)).Err; err == nil {
+ if err := (<-store.Webhook().SaveOutgoing(utils.T, &o1)).Err; err == nil {
t.Fatal("shouldn't be able to update from save")
}
}
@@ -158,9 +159,9 @@ func TestWebhookStoreGetOutgoing(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt {
@@ -168,7 +169,7 @@ func TestWebhookStoreGetOutgoing(t *testing.T) {
}
}
- if err := (<-store.Webhook().GetOutgoing("123")).Err; err == nil {
+ if err := (<-store.Webhook().GetOutgoing(utils.T, "123")).Err; err == nil {
t.Fatal("Missing id should have failed")
}
}
@@ -182,9 +183,9 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoingByChannel(o1.ChannelId); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoingByChannel(utils.T, o1.ChannelId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt {
@@ -192,7 +193,7 @@ func TestWebhookStoreGetOutgoingByChannel(t *testing.T) {
}
}
- if result := <-store.Webhook().GetOutgoingByChannel("123"); result.Err != nil {
+ if result := <-store.Webhook().GetOutgoingByChannel(utils.T, "123"); result.Err != nil {
t.Fatal(result.Err)
} else {
if len(result.Data.([]*model.OutgoingWebhook)) != 0 {
@@ -210,9 +211,9 @@ func TestWebhookStoreGetOutgoingByCreator(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoingByCreator(o1.CreatorId); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoingByCreator(utils.T, o1.CreatorId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt {
@@ -220,7 +221,7 @@ func TestWebhookStoreGetOutgoingByCreator(t *testing.T) {
}
}
- if result := <-store.Webhook().GetOutgoingByCreator("123"); result.Err != nil {
+ if result := <-store.Webhook().GetOutgoingByCreator(utils.T, "123"); result.Err != nil {
t.Fatal(result.Err)
} else {
if len(result.Data.([]*model.OutgoingWebhook)) != 0 {
@@ -238,9 +239,9 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoingByTeam(o1.TeamId); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoingByTeam(utils.T, o1.TeamId); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.([]*model.OutgoingWebhook)[0].CreateAt != o1.CreateAt {
@@ -248,7 +249,7 @@ func TestWebhookStoreGetOutgoingByTeam(t *testing.T) {
}
}
- if result := <-store.Webhook().GetOutgoingByTeam("123"); result.Err != nil {
+ if result := <-store.Webhook().GetOutgoingByTeam(utils.T, "123"); result.Err != nil {
t.Fatal(result.Err)
} else {
if len(result.Data.([]*model.OutgoingWebhook)) != 0 {
@@ -266,9 +267,9 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt {
@@ -276,11 +277,11 @@ func TestWebhookStoreDeleteOutgoing(t *testing.T) {
}
}
- if r2 := <-store.Webhook().DeleteOutgoing(o1.Id, model.GetMillis()); r2.Err != nil {
+ if r2 := <-store.Webhook().DeleteOutgoing(utils.T, o1.Id, model.GetMillis()); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Webhook().GetOutgoing(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Webhook().GetOutgoing(utils.T, o1.Id)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
}
@@ -295,9 +296,9 @@ func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
- if r1 := <-store.Webhook().GetOutgoing(o1.Id); r1.Err != nil {
+ if r1 := <-store.Webhook().GetOutgoing(utils.T, o1.Id); r1.Err != nil {
t.Fatal(r1.Err)
} else {
if r1.Data.(*model.OutgoingWebhook).CreateAt != o1.CreateAt {
@@ -305,11 +306,11 @@ func TestWebhookStoreDeleteOutgoingByUser(t *testing.T) {
}
}
- if r2 := <-store.Webhook().PermanentDeleteOutgoingByUser(o1.CreatorId); r2.Err != nil {
+ if r2 := <-store.Webhook().PermanentDeleteOutgoingByUser(utils.T, o1.CreatorId); r2.Err != nil {
t.Fatal(r2.Err)
}
- if r3 := (<-store.Webhook().GetOutgoing(o1.Id)); r3.Err == nil {
+ if r3 := (<-store.Webhook().GetOutgoing(utils.T, o1.Id)); r3.Err == nil {
t.Log(r3.Data)
t.Fatal("Missing id should have failed")
}
@@ -324,11 +325,11 @@ func TestWebhookStoreUpdateOutgoing(t *testing.T) {
o1.TeamId = model.NewId()
o1.CallbackURLs = []string{"http://nowhere.com/"}
- o1 = (<-store.Webhook().SaveOutgoing(o1)).Data.(*model.OutgoingWebhook)
+ o1 = (<-store.Webhook().SaveOutgoing(utils.T, o1)).Data.(*model.OutgoingWebhook)
o1.Token = model.NewId()
- if r2 := <-store.Webhook().UpdateOutgoing(o1); r2.Err != nil {
+ if r2 := <-store.Webhook().UpdateOutgoing(utils.T, o1); r2.Err != nil {
t.Fatal(r2.Err)
}
}
diff --git a/store/store.go b/store/store.go
index 179cfecd7..e50fc23bc 100644
--- a/store/store.go
+++ b/store/store.go
@@ -4,9 +4,11 @@
package store
import (
+ "time"
+
l4g "github.com/alecthomas/log4go"
"github.com/mattermost/platform/model"
- "time"
+ goi18n "github.com/nicksnyder/go-i18n/i18n"
)
type StoreResult struct {
@@ -43,150 +45,150 @@ type Store interface {
}
type TeamStore interface {
- Save(team *model.Team) StoreChannel
- Update(team *model.Team) StoreChannel
- UpdateDisplayName(name string, teamId string) StoreChannel
- Get(id string) StoreChannel
- GetByName(name string) StoreChannel
- GetTeamsForEmail(domain string) StoreChannel
- GetAll() StoreChannel
- GetAllTeamListing() StoreChannel
- GetByInviteId(inviteId string) StoreChannel
- PermanentDelete(teamId string) StoreChannel
+ Save(T goi18n.TranslateFunc, team *model.Team) StoreChannel
+ Update(T goi18n.TranslateFunc, team *model.Team) StoreChannel
+ UpdateDisplayName(T goi18n.TranslateFunc, name string, teamId string) StoreChannel
+ Get(T goi18n.TranslateFunc, id string) StoreChannel
+ GetByName(T goi18n.TranslateFunc, name string) StoreChannel
+ GetTeamsForEmail(T goi18n.TranslateFunc, domain string) StoreChannel
+ GetAll(T goi18n.TranslateFunc) StoreChannel
+ GetAllTeamListing(T goi18n.TranslateFunc) StoreChannel
+ GetByInviteId(T goi18n.TranslateFunc, inviteId string) StoreChannel
+ PermanentDelete(T goi18n.TranslateFunc, teamId string) StoreChannel
}
type ChannelStore interface {
- Save(channel *model.Channel) StoreChannel
- SaveDirectChannel(channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel
- Update(channel *model.Channel) StoreChannel
- Get(id string) StoreChannel
- GetFromMaster(id string) StoreChannel
- Delete(channelId string, time int64) StoreChannel
- PermanentDeleteByTeam(teamId string) StoreChannel
- GetByName(team_id string, domain string) StoreChannel
- GetChannels(teamId string, userId string) StoreChannel
- GetMoreChannels(teamId string, userId string) StoreChannel
- GetChannelCounts(teamId string, userId string) StoreChannel
- GetForExport(teamId string) StoreChannel
-
- SaveMember(member *model.ChannelMember) StoreChannel
- UpdateMember(member *model.ChannelMember) StoreChannel
- GetMembers(channelId string) StoreChannel
- GetMember(channelId string, userId string) StoreChannel
- GetMemberCount(channelId string) StoreChannel
- RemoveMember(channelId string, userId string) StoreChannel
- PermanentDeleteMembersByUser(userId string) StoreChannel
- GetExtraMembers(channelId string, limit int) StoreChannel
- CheckPermissionsTo(teamId string, channelId string, userId string) StoreChannel
- CheckOpenChannelPermissions(teamId string, channelId string) StoreChannel
- CheckPermissionsToByName(teamId string, channelName string, userId string) StoreChannel
- UpdateLastViewedAt(channelId string, userId string) StoreChannel
- IncrementMentionCount(channelId string, userId string) StoreChannel
- AnalyticsTypeCount(teamId string, channelType string) StoreChannel
+ Save(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel
+ SaveDirectChannel(T goi18n.TranslateFunc, channel *model.Channel, member1 *model.ChannelMember, member2 *model.ChannelMember) StoreChannel
+ Update(T goi18n.TranslateFunc, channel *model.Channel) StoreChannel
+ Get(T goi18n.TranslateFunc, id string) StoreChannel
+ GetFromMaster(T goi18n.TranslateFunc, id string) StoreChannel
+ Delete(T goi18n.TranslateFunc, channelId string, time int64) StoreChannel
+ PermanentDeleteByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel
+ GetByName(T goi18n.TranslateFunc, team_id string, domain string) StoreChannel
+ GetChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel
+ GetMoreChannels(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel
+ GetChannelCounts(T goi18n.TranslateFunc, teamId string, userId string) StoreChannel
+ GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel
+
+ SaveMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel
+ UpdateMember(T goi18n.TranslateFunc, member *model.ChannelMember) StoreChannel
+ GetMembers(T goi18n.TranslateFunc, channelId string) StoreChannel
+ GetMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel
+ GetMemberCount(T goi18n.TranslateFunc, channelId string) StoreChannel
+ RemoveMember(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel
+ PermanentDeleteMembersByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetExtraMembers(T goi18n.TranslateFunc, channelId string, limit int) StoreChannel
+ CheckPermissionsTo(T goi18n.TranslateFunc, teamId string, channelId string, userId string) StoreChannel
+ CheckOpenChannelPermissions(T goi18n.TranslateFunc, teamId string, channelId string) StoreChannel
+ CheckPermissionsToByName(T goi18n.TranslateFunc, teamId string, channelName string, userId string) StoreChannel
+ UpdateLastViewedAt(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel
+ IncrementMentionCount(T goi18n.TranslateFunc, channelId string, userId string) StoreChannel
+ AnalyticsTypeCount(T goi18n.TranslateFunc, teamId string, channelType string) StoreChannel
}
type PostStore interface {
- Save(post *model.Post) StoreChannel
- Update(post *model.Post, newMessage string, newHashtags string) StoreChannel
- Get(id string) StoreChannel
- Delete(postId string, time int64) StoreChannel
- PermanentDeleteByUser(userId string) StoreChannel
- GetPosts(channelId string, offset int, limit int) StoreChannel
- GetPostsBefore(channelId string, postId string, numPosts int, offset int) StoreChannel
- GetPostsAfter(channelId string, postId string, numPosts int, offset int) StoreChannel
- GetPostsSince(channelId string, time int64) StoreChannel
- GetEtag(channelId string) StoreChannel
- Search(teamId string, userId string, params *model.SearchParams) StoreChannel
- GetForExport(channelId string) StoreChannel
- AnalyticsUserCountsWithPostsByDay(teamId string) StoreChannel
- AnalyticsPostCountsByDay(teamId string) StoreChannel
- AnalyticsPostCount(teamId string) StoreChannel
+ Save(T goi18n.TranslateFunc, post *model.Post) StoreChannel
+ Update(T goi18n.TranslateFunc, post *model.Post, newMessage string, newHashtags string) StoreChannel
+ Get(T goi18n.TranslateFunc, id string) StoreChannel
+ Delete(T goi18n.TranslateFunc, postId string, time int64) StoreChannel
+ PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetPosts(T goi18n.TranslateFunc, channelId string, offset int, limit int) StoreChannel
+ GetPostsBefore(T goi18n.TranslateFunc, channelId string, postId string, numPosts int, offset int) StoreChannel
+ GetPostsAfter(T goi18n.TranslateFunc, channelId string, postId string, numPosts int, offset int) StoreChannel
+ GetPostsSince(T goi18n.TranslateFunc, channelId string, time int64) StoreChannel
+ GetEtag(T goi18n.TranslateFunc, channelId string) StoreChannel
+ Search(T goi18n.TranslateFunc, teamId string, userId string, params *model.SearchParams) StoreChannel
+ GetForExport(T goi18n.TranslateFunc, channelId string) StoreChannel
+ AnalyticsUserCountsWithPostsByDay(T goi18n.TranslateFunc, teamId string) StoreChannel
+ AnalyticsPostCountsByDay(T goi18n.TranslateFunc, teamId string) StoreChannel
+ AnalyticsPostCount(T goi18n.TranslateFunc, teamId string) StoreChannel
}
type UserStore interface {
- Save(user *model.User) StoreChannel
- Update(user *model.User, allowRoleUpdate bool) StoreChannel
- UpdateLastPictureUpdate(userId string) StoreChannel
- UpdateLastPingAt(userId string, time int64) StoreChannel
- UpdateLastActivityAt(userId string, time int64) StoreChannel
- UpdateUserAndSessionActivity(userId string, sessionId string, time int64) StoreChannel
- UpdatePassword(userId, newPassword string) StoreChannel
- UpdateAuthData(userId, service, authData string) StoreChannel
- Get(id string) StoreChannel
- GetProfiles(teamId string) StoreChannel
- GetByEmail(teamId string, email string) StoreChannel
- GetByAuth(teamId string, authData string, authService string) StoreChannel
- GetByUsername(teamId string, username string) StoreChannel
- VerifyEmail(userId string) StoreChannel
- GetEtagForProfiles(teamId string) StoreChannel
- UpdateFailedPasswordAttempts(userId string, attempts int) StoreChannel
- GetForExport(teamId string) StoreChannel
- GetTotalUsersCount() StoreChannel
- GetTotalActiveUsersCount() StoreChannel
- GetSystemAdminProfiles() StoreChannel
- PermanentDelete(userId string) StoreChannel
+ Save(T goi18n.TranslateFunc, user *model.User) StoreChannel
+ Update(T goi18n.TranslateFunc, user *model.User, allowRoleUpdate bool) StoreChannel
+ UpdateLastPictureUpdate(T goi18n.TranslateFunc, userId string) StoreChannel
+ UpdateLastPingAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel
+ UpdateLastActivityAt(T goi18n.TranslateFunc, userId string, time int64) StoreChannel
+ UpdateUserAndSessionActivity(T goi18n.TranslateFunc, userId string, sessionId string, time int64) StoreChannel
+ UpdatePassword(T goi18n.TranslateFunc, userId, newPassword string) StoreChannel
+ UpdateAuthData(T goi18n.TranslateFunc, userId, service, authData string) StoreChannel
+ Get(T goi18n.TranslateFunc, id string) StoreChannel
+ GetProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel
+ GetByEmail(T goi18n.TranslateFunc, teamId string, email string) StoreChannel
+ GetByAuth(T goi18n.TranslateFunc, teamId string, authData string, authService string) StoreChannel
+ GetByUsername(T goi18n.TranslateFunc, teamId string, username string) StoreChannel
+ VerifyEmail(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetEtagForProfiles(T goi18n.TranslateFunc, teamId string) StoreChannel
+ UpdateFailedPasswordAttempts(T goi18n.TranslateFunc, userId string, attempts int) StoreChannel
+ GetForExport(T goi18n.TranslateFunc, teamId string) StoreChannel
+ GetTotalUsersCount(T goi18n.TranslateFunc) StoreChannel
+ GetTotalActiveUsersCount(T goi18n.TranslateFunc) StoreChannel
+ GetSystemAdminProfiles(T goi18n.TranslateFunc) StoreChannel
+ PermanentDelete(T goi18n.TranslateFunc, userId string) StoreChannel
}
type SessionStore interface {
- Save(session *model.Session) StoreChannel
- Get(sessionIdOrToken string) StoreChannel
- GetSessions(userId string) StoreChannel
- Remove(sessionIdOrToken string) StoreChannel
- RemoveAllSessionsForTeam(teamId string) StoreChannel
- PermanentDeleteSessionsByUser(teamId string) StoreChannel
- UpdateLastActivityAt(sessionId string, time int64) StoreChannel
- UpdateRoles(userId string, roles string) StoreChannel
+ Save(T goi18n.TranslateFunc, session *model.Session) StoreChannel
+ Get(T goi18n.TranslateFunc, sessionIdOrToken string) StoreChannel
+ GetSessions(T goi18n.TranslateFunc, userId string) StoreChannel
+ Remove(T goi18n.TranslateFunc, sessionIdOrToken string) StoreChannel
+ RemoveAllSessionsForTeam(T goi18n.TranslateFunc, teamId string) StoreChannel
+ PermanentDeleteSessionsByUser(T goi18n.TranslateFunc, teamId string) StoreChannel
+ UpdateLastActivityAt(T goi18n.TranslateFunc, sessionId string, time int64) StoreChannel
+ UpdateRoles(T goi18n.TranslateFunc, userId string, roles string) StoreChannel
}
type AuditStore interface {
- Save(audit *model.Audit) StoreChannel
- Get(user_id string, limit int) StoreChannel
- PermanentDeleteByUser(userId string) StoreChannel
+ Save(T goi18n.TranslateFunc, audit *model.Audit) StoreChannel
+ Get(T goi18n.TranslateFunc, user_id string, limit int) StoreChannel
+ PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel
}
type OAuthStore interface {
- SaveApp(app *model.OAuthApp) StoreChannel
- UpdateApp(app *model.OAuthApp) StoreChannel
- GetApp(id string) StoreChannel
- GetAppByUser(userId string) StoreChannel
- SaveAuthData(authData *model.AuthData) StoreChannel
- GetAuthData(code string) StoreChannel
- RemoveAuthData(code string) StoreChannel
- PermanentDeleteAuthDataByUser(userId string) StoreChannel
- SaveAccessData(accessData *model.AccessData) StoreChannel
- GetAccessData(token string) StoreChannel
- GetAccessDataByAuthCode(authCode string) StoreChannel
- RemoveAccessData(token string) StoreChannel
+ SaveApp(T goi18n.TranslateFunc, app *model.OAuthApp) StoreChannel
+ UpdateApp(T goi18n.TranslateFunc, app *model.OAuthApp) StoreChannel
+ GetApp(T goi18n.TranslateFunc, id string) StoreChannel
+ GetAppByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ SaveAuthData(T goi18n.TranslateFunc, authData *model.AuthData) StoreChannel
+ GetAuthData(T goi18n.TranslateFunc, code string) StoreChannel
+ RemoveAuthData(T goi18n.TranslateFunc, code string) StoreChannel
+ PermanentDeleteAuthDataByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ SaveAccessData(T goi18n.TranslateFunc, accessData *model.AccessData) StoreChannel
+ GetAccessData(T goi18n.TranslateFunc, token string) StoreChannel
+ GetAccessDataByAuthCode(T goi18n.TranslateFunc, authCode string) StoreChannel
+ RemoveAccessData(T goi18n.TranslateFunc, token string) StoreChannel
}
type SystemStore interface {
- Save(system *model.System) StoreChannel
- Update(system *model.System) StoreChannel
- Get() StoreChannel
+ Save(T goi18n.TranslateFunc, system *model.System) StoreChannel
+ Update(T goi18n.TranslateFunc, system *model.System) StoreChannel
+ Get(T goi18n.TranslateFunc) StoreChannel
}
type WebhookStore interface {
- SaveIncoming(webhook *model.IncomingWebhook) StoreChannel
- GetIncoming(id string) StoreChannel
- GetIncomingByUser(userId string) StoreChannel
- GetIncomingByChannel(channelId string) StoreChannel
- DeleteIncoming(webhookId string, time int64) StoreChannel
- PermanentDeleteIncomingByUser(userId string) StoreChannel
- SaveOutgoing(webhook *model.OutgoingWebhook) StoreChannel
- GetOutgoing(id string) StoreChannel
- GetOutgoingByCreator(userId string) StoreChannel
- GetOutgoingByChannel(channelId string) StoreChannel
- GetOutgoingByTeam(teamId string) StoreChannel
- DeleteOutgoing(webhookId string, time int64) StoreChannel
- PermanentDeleteOutgoingByUser(userId string) StoreChannel
- UpdateOutgoing(hook *model.OutgoingWebhook) StoreChannel
+ SaveIncoming(T goi18n.TranslateFunc, webhook *model.IncomingWebhook) StoreChannel
+ GetIncoming(T goi18n.TranslateFunc, id string) StoreChannel
+ GetIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetIncomingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel
+ DeleteIncoming(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel
+ PermanentDeleteIncomingByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ SaveOutgoing(T goi18n.TranslateFunc, webhook *model.OutgoingWebhook) StoreChannel
+ GetOutgoing(T goi18n.TranslateFunc, id string) StoreChannel
+ GetOutgoingByCreator(T goi18n.TranslateFunc, userId string) StoreChannel
+ GetOutgoingByChannel(T goi18n.TranslateFunc, channelId string) StoreChannel
+ GetOutgoingByTeam(T goi18n.TranslateFunc, teamId string) StoreChannel
+ DeleteOutgoing(T goi18n.TranslateFunc, webhookId string, time int64) StoreChannel
+ PermanentDeleteOutgoingByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ UpdateOutgoing(T goi18n.TranslateFunc, hook *model.OutgoingWebhook) StoreChannel
}
type PreferenceStore interface {
- Save(preferences *model.Preferences) StoreChannel
- Get(userId string, category string, name string) StoreChannel
- GetCategory(userId string, category string) StoreChannel
- GetAll(userId string) StoreChannel
- PermanentDeleteByUser(userId string) StoreChannel
- IsFeatureEnabled(feature, userId string) StoreChannel
+ Save(T goi18n.TranslateFunc, preferences *model.Preferences) StoreChannel
+ Get(T goi18n.TranslateFunc, userId string, category string, name string) StoreChannel
+ GetCategory(T goi18n.TranslateFunc, userId string, category string) StoreChannel
+ GetAll(T goi18n.TranslateFunc, userId string) StoreChannel
+ PermanentDeleteByUser(T goi18n.TranslateFunc, userId string) StoreChannel
+ IsFeatureEnabled(T goi18n.TranslateFunc, feature, userId string) StoreChannel
}