summaryrefslogtreecommitdiffstats
path: root/api/channel.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-08-10 14:47:45 -0400
committerJoramWilander <jwawilander@gmail.com>2015-08-11 12:11:35 -0400
commit6c0fefad152e1843bccf80fb675301b789f70dd5 (patch)
treee48b601f97cf9f7456e8783082fcb3974691785b /api/channel.go
parent1c0ee4d2f65d1d4434a3a16070abe7d61a268ce6 (diff)
downloadchat-6c0fefad152e1843bccf80fb675301b789f70dd5.tar.gz
chat-6c0fefad152e1843bccf80fb675301b789f70dd5.tar.bz2
chat-6c0fefad152e1843bccf80fb675301b789f70dd5.zip
added getChannelCounts service and refactored the client to more intelligently pull channel data
Diffstat (limited to 'api/channel.go')
-rw-r--r--api/channel.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/api/channel.go b/api/channel.go
index a3de30377..851816dde 100644
--- a/api/channel.go
+++ b/api/channel.go
@@ -18,6 +18,7 @@ func InitChannel(r *mux.Router) {
sr := r.PathPrefix("/channels").Subrouter()
sr.Handle("/", ApiUserRequiredActivity(getChannels, false)).Methods("GET")
sr.Handle("/more", ApiUserRequired(getMoreChannels)).Methods("GET")
+ sr.Handle("/counts", ApiUserRequiredActivity(getChannelCounts, false)).Methods("GET")
sr.Handle("/create", ApiUserRequired(createChannel)).Methods("POST")
sr.Handle("/create_direct", ApiUserRequired(createDirectChannel)).Methods("POST")
sr.Handle("/update", ApiUserRequired(updateChannel)).Methods("POST")
@@ -315,6 +316,22 @@ func getMoreChannels(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
+func getChannelCounts(c *Context, w http.ResponseWriter, r *http.Request) {
+
+ // user is already in the team
+
+ if result := <-Srv.Store.Channel().GetChannelCounts(c.Session.TeamId, c.Session.UserId); result.Err != nil {
+ c.Err = model.NewAppError("getChannelCounts", "Unable to get channel counts from the database", result.Err.Message)
+ return
+ } else if HandleEtag(result.Data.(*model.ChannelCounts).Etag(), w, r) {
+ return
+ } else {
+ data := result.Data.(*model.ChannelCounts)
+ w.Header().Set(model.HEADER_ETAG_SERVER, data.Etag())
+ w.Write([]byte(data.ToJson()))
+ }
+}
+
func joinChannel(c *Context, w http.ResponseWriter, r *http.Request) {
params := mux.Vars(r)