summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-07-06 10:11:21 -0800
committerChristopher Speller <crspeller@gmail.com>2016-07-06 14:11:21 -0400
commitb1520d0b9458d1dab09d9e3e05dd7522fc28ba57 (patch)
tree6500ca9d516ddf456eaf4edfe4b27617a7490bf8 /store
parent26c91e73fef89b1d4a0ef04ef39589243d411752 (diff)
downloadchat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.tar.gz
chat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.tar.bz2
chat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.zip
PLT-3512 adding join/leave channel to the CLI (#3498)
* PLT-3512 adding join/leave channel to the CLI * PLT-3512 adding list channels to the CLI * PLT-3512 adding restore channel * Adding make run-cli command * Updating txt * Fixing txt purposed by PMs
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go28
-rw-r--r--store/sql_channel_store_test.go9
-rw-r--r--store/store.go2
3 files changed, 38 insertions, 1 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 3636fb62f..e5e0aa8ba 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -289,12 +289,16 @@ func (s SqlChannelStore) get(id string, master bool) StoreChannel {
}
func (s SqlChannelStore) Delete(channelId string, time int64) StoreChannel {
+ return s.SetDeleteAt(channelId, time, time)
+}
+
+func (s SqlChannelStore) SetDeleteAt(channelId string, deleteAt int64, updateAt int64) StoreChannel {
storeChannel := make(StoreChannel)
go func() {
result := StoreResult{}
- _, err := s.GetMaster().Exec("Update Channels SET DeleteAt = :Time, UpdateAt = :Time WHERE Id = :ChannelId", map[string]interface{}{"Time": time, "ChannelId": channelId})
+ _, err := s.GetMaster().Exec("Update Channels SET DeleteAt = :DeleteAt, UpdateAt = :UpdateAt WHERE Id = :ChannelId", map[string]interface{}{"DeleteAt": deleteAt, "UpdateAt": updateAt, "ChannelId": channelId})
if err != nil {
result.Err = model.NewLocAppError("SqlChannelStore.Delete", "store.sql_channel.delete.channel.app_error", nil, "id="+channelId+", err="+err.Error())
}
@@ -948,6 +952,28 @@ func (s SqlChannelStore) GetForExport(teamId string) StoreChannel {
return storeChannel
}
+func (s SqlChannelStore) GetAll(teamId string) StoreChannel {
+ storeChannel := make(StoreChannel)
+
+ go func() {
+ result := StoreResult{}
+
+ var data []*model.Channel
+ _, err := s.GetReplica().Select(&data, "SELECT * FROM Channels WHERE TeamId = :TeamId AND Type != 'D' ORDER BY Name", map[string]interface{}{"TeamId": teamId})
+
+ if err != nil {
+ result.Err = model.NewLocAppError("SqlChannelStore.GetAll", "store.sql_channel.get_all.app_error", nil, "teamId="+teamId+", err="+err.Error())
+ } else {
+ result.Data = data
+ }
+
+ storeChannel <- result
+ close(storeChannel)
+ }()
+
+ return storeChannel
+}
+
func (s SqlChannelStore) AnalyticsTypeCount(teamId string, channelType string) StoreChannel {
storeChannel := make(StoreChannel)
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index 2b284d06e..0c293972c 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -200,6 +200,15 @@ func TestChannelStoreGet(t *testing.T) {
t.Fatal("invalid returned channel")
}
}
+
+ if r3 := <-store.Channel().GetAll(o1.TeamId); r3.Err != nil {
+ t.Fatal(r3.Err)
+ } else {
+ channels := r3.Data.([]*model.Channel)
+ if len(channels) == 0 {
+ t.Fatal("too little")
+ }
+ }
}
func TestChannelStoreDelete(t *testing.T) {
diff --git a/store/store.go b/store/store.go
index 29a7e8d82..f576cc2ab 100644
--- a/store/store.go
+++ b/store/store.go
@@ -77,12 +77,14 @@ type ChannelStore interface {
Get(id string) StoreChannel
GetFromMaster(id string) StoreChannel
Delete(channelId string, time int64) StoreChannel
+ SetDeleteAt(channelId string, deleteAt int64, updateAt 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
+ GetAll(teamId string) StoreChannel
SaveMember(member *model.ChannelMember) StoreChannel
UpdateMember(member *model.ChannelMember) StoreChannel