summaryrefslogtreecommitdiffstats
path: root/model
diff options
context:
space:
mode:
Diffstat (limited to 'model')
-rw-r--r--model/client.go21
-rw-r--r--model/command_response.go2
-rw-r--r--model/config.go26
-rw-r--r--model/incoming_webhook.go3
-rw-r--r--model/license.go7
-rw-r--r--model/push_notification.go1
-rw-r--r--model/websocket_message.go9
7 files changed, 68 insertions, 1 deletions
diff --git a/model/client.go b/model/client.go
index 8a361c177..32532508f 100644
--- a/model/client.go
+++ b/model/client.go
@@ -500,6 +500,17 @@ func (c *Client) GetUser(id string, etag string) (*Result, *AppError) {
}
}
+// getByUsername returns a user based on a provided username string. Must be authenticated.
+func (c *Client) GetByUsername(username string, etag string) (*Result, *AppError) {
+ if r, err := c.DoApiGet(fmt.Sprintf("/users/name/%v", username), "", etag); err != nil {
+ return nil, err
+ } else {
+ defer closeBody(r)
+ return &Result{r.Header.Get(HEADER_REQUEST_ID),
+ r.Header.Get(HEADER_ETAG_SERVER), UserFromJson(r.Body)}, nil
+ }
+}
+
// GetMe returns the current user.
func (c *Client) GetMe(etag string) (*Result, *AppError) {
if r, err := c.DoApiGet("/users/me", "", etag); err != nil {
@@ -846,6 +857,16 @@ func (c *Client) CreateCommand(cmd *Command) (*Result, *AppError) {
}
}
+func (c *Client) UpdateCommand(cmd *Command) (*Result, *AppError) {
+ if r, err := c.DoApiPost(c.GetTeamRoute()+"/commands/update", cmd.ToJson()); err != nil {
+ return nil, err
+ } else {
+ defer closeBody(r)
+ return &Result{r.Header.Get(HEADER_REQUEST_ID),
+ r.Header.Get(HEADER_ETAG_SERVER), CommandFromJson(r.Body)}, nil
+ }
+}
+
func (c *Client) RegenCommandToken(data map[string]string) (*Result, *AppError) {
if r, err := c.DoApiPost(c.GetTeamRoute()+"/commands/regen_token", MapToJson(data)); err != nil {
return nil, err
diff --git a/model/command_response.go b/model/command_response.go
index 9314f38ef..bbb70418e 100644
--- a/model/command_response.go
+++ b/model/command_response.go
@@ -16,6 +16,8 @@ const (
type CommandResponse struct {
ResponseType string `json:"response_type"`
Text string `json:"text"`
+ Username string `json:"username"`
+ IconURL string `json:"icon_url"`
GotoLocation string `json:"goto_location"`
Attachments interface{} `json:"attachments"`
}
diff --git a/model/config.go b/model/config.go
index f2ff788d8..f9a1d4861 100644
--- a/model/config.go
+++ b/model/config.go
@@ -98,6 +98,11 @@ type ClusterSettings struct {
InterNodeUrls []string
}
+type MetricsSettings struct {
+ Enable *bool
+ ListenAddress *string
+}
+
type SSOSettings struct {
Enable bool
Secret string
@@ -221,6 +226,7 @@ type TeamSettings struct {
RestrictPrivateChannelManagement *string
UserStatusAwayTimeout *int64
MaxChannelsPerTeam *int64
+ MaxNotificationsPerChannel *int64
}
type LdapSettings struct {
@@ -330,6 +336,7 @@ type Config struct {
SamlSettings SamlSettings
NativeAppSettings NativeAppSettings
ClusterSettings ClusterSettings
+ MetricsSettings MetricsSettings
WebrtcSettings WebrtcSettings
}
@@ -501,6 +508,11 @@ func (o *Config) SetDefaults() {
*o.TeamSettings.MaxChannelsPerTeam = 2000
}
+ if o.TeamSettings.MaxNotificationsPerChannel == nil {
+ o.TeamSettings.MaxNotificationsPerChannel = new(int64)
+ *o.TeamSettings.MaxNotificationsPerChannel = 1000
+ }
+
if o.EmailSettings.EnableSignInWithEmail == nil {
o.EmailSettings.EnableSignInWithEmail = new(bool)
@@ -772,6 +784,16 @@ func (o *Config) SetDefaults() {
o.ClusterSettings.InterNodeUrls = []string{}
}
+ if o.MetricsSettings.ListenAddress == nil {
+ o.MetricsSettings.ListenAddress = new(string)
+ *o.MetricsSettings.ListenAddress = ":8067"
+ }
+
+ if o.MetricsSettings.Enable == nil {
+ o.MetricsSettings.Enable = new(bool)
+ *o.MetricsSettings.Enable = false
+ }
+
if o.ComplianceSettings.Enable == nil {
o.ComplianceSettings.Enable = new(bool)
*o.ComplianceSettings.Enable = false
@@ -987,6 +1009,10 @@ func (o *Config) IsValid() *AppError {
return NewLocAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "")
}
+ if *o.TeamSettings.MaxNotificationsPerChannel <= 0 {
+ return NewLocAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", nil, "")
+ }
+
if !(*o.TeamSettings.RestrictDirectMessage == DIRECT_MESSAGE_ANY || *o.TeamSettings.RestrictDirectMessage == DIRECT_MESSAGE_TEAM) {
return NewLocAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "")
}
diff --git a/model/incoming_webhook.go b/model/incoming_webhook.go
index c567edfda..72fa3e54c 100644
--- a/model/incoming_webhook.go
+++ b/model/incoming_webhook.go
@@ -6,6 +6,7 @@ package model
import (
"bytes"
"encoding/json"
+ "fmt"
"io"
"regexp"
"strings"
@@ -233,7 +234,7 @@ func expandAnnouncements(i *IncomingWebhookRequest) {
for _, field := range fields {
f := field.(map[string]interface{})
if f["value"] != nil {
- f["value"] = expandAnnouncement(f["value"].(string))
+ f["value"] = expandAnnouncement(fmt.Sprintf("%v", f["value"]))
}
}
}
diff --git a/model/license.go b/model/license.go
index 8d8d0068f..7115aa1ac 100644
--- a/model/license.go
+++ b/model/license.go
@@ -39,6 +39,7 @@ type Features struct {
Office365OAuth *bool `json:"office365_oauth"`
Compliance *bool `json:"compliance"`
Cluster *bool `json:"cluster"`
+ Metrics *bool `json:"metrics"`
CustomBrand *bool `json:"custom_brand"`
MHPNS *bool `json:"mhpns"`
SAML *bool `json:"saml"`
@@ -55,6 +56,7 @@ func (f *Features) ToMap() map[string]interface{} {
"office365": *f.Office365OAuth,
"compliance": *f.Compliance,
"cluster": *f.Cluster,
+ "metrics": *f.Metrics,
"custom_brand": *f.CustomBrand,
"mhpns": *f.MHPNS,
"saml": *f.SAML,
@@ -104,6 +106,11 @@ func (f *Features) SetDefaults() {
*f.Cluster = *f.FutureFeatures
}
+ if f.Metrics == nil {
+ f.Metrics = new(bool)
+ *f.Metrics = *f.FutureFeatures
+ }
+
if f.CustomBrand == nil {
f.CustomBrand = new(bool)
*f.CustomBrand = *f.FutureFeatures
diff --git a/model/push_notification.go b/model/push_notification.go
index d4c380291..3c010fb75 100644
--- a/model/push_notification.go
+++ b/model/push_notification.go
@@ -30,6 +30,7 @@ type PushNotification struct {
Message string `json:"message"`
Badge int `json:"badge"`
ContentAvailable int `json:"cont_ava"`
+ TeamId string `json:"team_id"`
ChannelId string `json:"channel_id"`
ChannelName string `json:"channel_name"`
Type string `json:"type"`
diff --git a/model/websocket_message.go b/model/websocket_message.go
index 5eb02642e..3fa58aeb3 100644
--- a/model/websocket_message.go
+++ b/model/websocket_message.go
@@ -34,6 +34,7 @@ type WebSocketMessage interface {
IsValid() bool
DoPreComputeJson()
GetPreComputeJson() []byte
+ EventType() string
}
type WebsocketBroadcast struct {
@@ -63,6 +64,10 @@ func (o *WebSocketEvent) IsValid() bool {
return o.Event != ""
}
+func (o *WebSocketEvent) EventType() string {
+ return o.Event
+}
+
func (o *WebSocketEvent) DoPreComputeJson() {
b, err := json.Marshal(o)
if err != nil {
@@ -120,6 +125,10 @@ func (o *WebSocketResponse) IsValid() bool {
return o.Status != ""
}
+func (o *WebSocketResponse) EventType() string {
+ return ""
+}
+
func (o *WebSocketResponse) ToJson() string {
b, err := json.Marshal(o)
if err != nil {