partial fix for UI
Этот коммит содержится в:
@@ -372,7 +372,25 @@ func (c *Client) Command(channelId string, command string, suggest bool) (*Resul
|
||||
m["command"] = command
|
||||
m["channelId"] = channelId
|
||||
m["suggest"] = strconv.FormatBool(suggest)
|
||||
if r, err := c.DoApiPost("/command", MapToJson(m)); err != nil {
|
||||
if r, err := c.DoApiPost("/commands/execute", MapToJson(m)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), CommandResponseFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) ListCommands() (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/commands/list", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), CommandListFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) CreateCommand(cmd *Command) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/commands/create", cmd.ToJson()); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
|
||||
40
model/command_response.go
Обычный файл
40
model/command_response.go
Обычный файл
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
)
|
||||
|
||||
const (
|
||||
COMMAND_RESPONSE_TYPE_IN_CHANNEL = "in_channel"
|
||||
COMMAND_RESPONSE_TYPE_EPHEMERAL = "ephemeral"
|
||||
)
|
||||
|
||||
type CommandResponse struct {
|
||||
ResponseType string `json:"response_type"`
|
||||
Text string `json:"text"`
|
||||
Attachments interface{} `json:"attachments"`
|
||||
}
|
||||
|
||||
func (o *CommandResponse) ToJson() string {
|
||||
b, err := json.Marshal(o)
|
||||
if err != nil {
|
||||
return ""
|
||||
} else {
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
func CommandResponseFromJson(data io.Reader) *CommandResponse {
|
||||
decoder := json.NewDecoder(data)
|
||||
var o CommandResponse
|
||||
err := decoder.Decode(&o)
|
||||
if err == nil {
|
||||
return &o
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
19
model/command_response_test.go
Обычный файл
19
model/command_response_test.go
Обычный файл
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCommandResponseJson(t *testing.T) {
|
||||
o := CommandResponse{Text: "test"}
|
||||
json := o.ToJson()
|
||||
ro := CommandResponseFromJson(strings.NewReader(json))
|
||||
|
||||
if o.Text != ro.Text {
|
||||
t.Fatal("Ids do not match")
|
||||
}
|
||||
}
|
||||
@@ -24,22 +24,24 @@ const (
|
||||
)
|
||||
|
||||
type ServiceSettings struct {
|
||||
ListenAddress string
|
||||
MaximumLoginAttempts int
|
||||
SegmentDeveloperKey string
|
||||
GoogleDeveloperKey string
|
||||
EnableOAuthServiceProvider bool
|
||||
EnableIncomingWebhooks bool
|
||||
EnableOutgoingWebhooks bool
|
||||
EnablePostUsernameOverride bool
|
||||
EnablePostIconOverride bool
|
||||
EnableTesting bool
|
||||
EnableDeveloper *bool
|
||||
EnableSecurityFixAlert *bool
|
||||
SessionLengthWebInDays *int
|
||||
SessionLengthMobileInDays *int
|
||||
SessionLengthSSOInDays *int
|
||||
SessionCacheInMinutes *int
|
||||
ListenAddress string
|
||||
MaximumLoginAttempts int
|
||||
SegmentDeveloperKey string
|
||||
GoogleDeveloperKey string
|
||||
EnableOAuthServiceProvider bool
|
||||
EnableIncomingWebhooks bool
|
||||
EnableOutgoingWebhooks bool
|
||||
EnableCommands *bool
|
||||
EnableOnlyAdminIntegrations *bool
|
||||
EnablePostUsernameOverride bool
|
||||
EnablePostIconOverride bool
|
||||
EnableTesting bool
|
||||
EnableDeveloper *bool
|
||||
EnableSecurityFixAlert *bool
|
||||
SessionLengthWebInDays *int
|
||||
SessionLengthMobileInDays *int
|
||||
SessionLengthSSOInDays *int
|
||||
SessionCacheInMinutes *int
|
||||
}
|
||||
|
||||
type SSOSettings struct {
|
||||
@@ -330,6 +332,16 @@ func (o *Config) SetDefaults() {
|
||||
o.ServiceSettings.SessionCacheInMinutes = new(int)
|
||||
*o.ServiceSettings.SessionCacheInMinutes = 10
|
||||
}
|
||||
|
||||
if o.ServiceSettings.EnableCommands == nil {
|
||||
o.ServiceSettings.EnableCommands = new(bool)
|
||||
*o.ServiceSettings.EnableCommands = false
|
||||
}
|
||||
|
||||
if o.ServiceSettings.EnableOnlyAdminIntegrations == nil {
|
||||
o.ServiceSettings.EnableOnlyAdminIntegrations = new(bool)
|
||||
*o.ServiceSettings.EnableOnlyAdminIntegrations = true
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Config) IsValid() *AppError {
|
||||
|
||||
@@ -24,10 +24,10 @@ var versions = []string{
|
||||
}
|
||||
|
||||
var CurrentVersion string = versions[0]
|
||||
var BuildNumber = "_BUILD_NUMBER_"
|
||||
var BuildDate = "_BUILD_DATE_"
|
||||
var BuildHash = "_BUILD_HASH_"
|
||||
var BuildEnterpriseReady = "_BUILD_ENTERPRISE_READY_"
|
||||
var BuildNumber = "dev"
|
||||
var BuildDate = "Fri Jan 8 14:19:26 UTC 2016"
|
||||
var BuildHash = "001a4448ca5fb0018eeb442915b473b121c04bf3"
|
||||
var BuildEnterpriseReady = "false"
|
||||
|
||||
func SplitVersion(version string) (int64, int64, int64) {
|
||||
parts := strings.Split(version, ".")
|
||||
@@ -73,7 +73,7 @@ func GetPreviousVersion(currentVersion string) (int64, int64) {
|
||||
}
|
||||
|
||||
func IsOfficalBuild() bool {
|
||||
return BuildNumber != "_BUILD_NUMBER_"
|
||||
return BuildNumber != "dev"
|
||||
}
|
||||
|
||||
func IsCurrentVersion(versionToCheck string) bool {
|
||||
|
||||
Ссылка в новой задаче
Block a user