summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go21
-rw-r--r--store/sql_post_store.go6
-rw-r--r--store/sql_post_store_test.go2
-rw-r--r--store/sql_preference_store.go2
-rw-r--r--store/sql_preference_store_test.go2
-rw-r--r--store/store.go1
6 files changed, 25 insertions, 9 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index badaa4d13..b68774189 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -241,12 +241,27 @@ func (s SqlChannelStore) extraUpdated(channel *model.Channel) StoreChannel {
}
func (s SqlChannelStore) Get(id string) StoreChannel {
+ return s.get(id, false)
+}
+
+func (s SqlChannelStore) GetFromMaster(id string) StoreChannel {
+ return s.get(id, true)
+}
+
+func (s SqlChannelStore) get(id string, master bool) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
- if obj, err := s.GetReplica().Get(model.Channel{}, id); err != nil {
+ var db *gorp.DbMap
+ if master {
+ db = s.GetMaster()
+ } else {
+ db = s.GetReplica()
+ }
+
+ if obj, err := db.Get(model.Channel{}, id); err != nil {
result.Err = model.NewAppError("SqlChannelStore.Get", "We encountered an error finding the channel", "id="+id+", "+err.Error())
} else if obj == nil {
result.Err = model.NewAppError("SqlChannelStore.Get", "We couldn't find the existing channel", "id="+id)
@@ -438,7 +453,7 @@ func (s SqlChannelStore) SaveMember(member *model.ChannelMember) StoreChannel {
go func() {
var result StoreResult
// Grab the channel we are saving this member to
- if cr := <-s.Get(member.ChannelId); cr.Err != nil {
+ if cr := <-s.GetFromMaster(member.ChannelId); cr.Err != nil {
result.Err = cr.Err
} else {
channel := cr.Data.(*model.Channel)
@@ -591,7 +606,7 @@ func (s SqlChannelStore) GetExtraMembers(channelId string, limit int) StoreChann
result.Err = model.NewAppError("SqlChannelStore.GetExtraMembers", "We couldn't get the extra info for channel members", "channel_id="+channelId+", "+err.Error())
} else {
for i := range members {
- members[i].Sanitize(utils.SanitizeOptions)
+ members[i].Sanitize(utils.Cfg.GetSanitizeOptions())
}
result.Data = members
}
diff --git a/store/sql_post_store.go b/store/sql_post_store.go
index 1831eb23c..40dca9930 100644
--- a/store/sql_post_store.go
+++ b/store/sql_post_store.go
@@ -30,7 +30,7 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore {
table.ColMap("Message").SetMaxSize(4000)
table.ColMap("Type").SetMaxSize(26)
table.ColMap("Hashtags").SetMaxSize(1000)
- table.ColMap("Props")
+ table.ColMap("Props").SetMaxSize(8000)
table.ColMap("Filenames").SetMaxSize(4000)
}
@@ -38,7 +38,6 @@ func NewSqlPostStore(sqlStore *SqlStore) PostStore {
}
func (s SqlPostStore) UpgradeSchemaIfNeeded() {
- s.RemoveColumnIfExists("Posts", "ImgCount") // remove after 1.3 release
}
func (s SqlPostStore) CreateIndexesIfNotExists() {
@@ -570,7 +569,8 @@ func (s SqlPostStore) getParentsPosts(channelId string, offset int, limit int) S
AND DeleteAt = 0
ORDER BY CreateAt DESC
LIMIT :Limit OFFSET :Offset) q3
- WHERE q3.RootId != '') q1 ON q1.RootId = q2.Id
+ WHERE q3.RootId != '') q1
+ ON q1.RootId = q2.Id OR q1.RootId = q2.RootId
WHERE
ChannelId = :ChannelId2
AND DeleteAt = 0
diff --git a/store/sql_post_store_test.go b/store/sql_post_store_test.go
index 12b50cad3..a3e3e10dd 100644
--- a/store/sql_post_store_test.go
+++ b/store/sql_post_store_test.go
@@ -445,7 +445,7 @@ func TestPostStoreGetPostsWtihDetails(t *testing.T) {
t.Fatal("invalid order")
}
- if len(r1.Posts) != 5 { //the last 4, + o1 (o3 and o2a's parent)
+ if len(r1.Posts) != 6 { //the last 4, + o1 (o2a and o3's parent) + o2 (in same thread as o2a and o3)
t.Fatal("wrong size")
}
diff --git a/store/sql_preference_store.go b/store/sql_preference_store.go
index f73dad3ac..307761150 100644
--- a/store/sql_preference_store.go
+++ b/store/sql_preference_store.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
diff --git a/store/sql_preference_store_test.go b/store/sql_preference_store_test.go
index 6f8f44f47..ec9d1df6c 100644
--- a/store/sql_preference_store_test.go
+++ b/store/sql_preference_store_test.go
@@ -1,4 +1,4 @@
-// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
package store
diff --git a/store/store.go b/store/store.go
index 0695ea27f..682195148 100644
--- a/store/store.go
+++ b/store/store.go
@@ -60,6 +60,7 @@ type ChannelStore interface {
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