summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go28
1 files changed, 27 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)