generated from mattermost/mattermost-plugin-starter-template
-
Notifications
You must be signed in to change notification settings - Fork 29
/
num_bindings.go
36 lines (27 loc) · 844 Bytes
/
num_bindings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"strconv"
"github.com/gorilla/mux"
"github.com/pkg/errors"
"github.com/mattermost/mattermost-plugin-apps/apps"
)
var numPostMenuBindings int64 = -1
var numChannelHeaderBindings int64 = -1
func initNumBindingsCommand(r *mux.Router) {
handleCall(r, NumBindingsPath, handleNumBindingsCommand)
}
func handleNumBindingsCommand(creq *apps.CallRequest) apps.CallResponse {
location := creq.GetValue("location", "post_menu")
numStr := creq.GetValue("number", "-1")
num, _ := strconv.ParseInt(numStr, 10, 32)
switch location {
case "post_menu":
numPostMenuBindings = num
case "channel_header":
numChannelHeaderBindings = num
default:
return apps.NewErrorResponse(errors.Errorf("unsupported location %s", location))
}
return apps.NewTextResponse(fmt.Sprintf("changed %s to %d", location, num))
}