From 1074a1c7ab0769b0da3525282fcabf961e2ddfce Mon Sep 17 00:00:00 2001 From: Jason Mojica Date: Thu, 25 Oct 2018 17:24:43 +0000 Subject: GH-9612 Add plugin API for GetChannelStats method (#9627) * Add GetChannelStats plugin api * Fix to return channel stats correctly * Add server version; Handle error idiomatically --- app/plugin_api.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app') diff --git a/app/plugin_api.go b/app/plugin_api.go index c409a88f8..a07a07652 100644 --- a/app/plugin_api.go +++ b/app/plugin_api.go @@ -261,6 +261,14 @@ func (api *PluginAPI) GetChannelsForTeamForUser(teamId, userId string, includeDe return api.app.GetChannelsForUser(teamId, userId, includeDeleted) } +func (api *PluginAPI) GetChannelStats(channelId string) (*model.ChannelStats, *model.AppError) { + memberCount, err := api.app.GetChannelMemberCount(channelId) + if err != nil { + return nil, err + } + return &model.ChannelStats{ChannelId: channelId, MemberCount: memberCount}, nil +} + func (api *PluginAPI) GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError) { return api.app.GetDirectChannel(userId1, userId2) } -- cgit v1.2.3-1-g7c22