mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-18 17:12:37 +01:00
Sync with mattermost 3.4.0
This commit is contained in:
parent
0f530e7902
commit
16ed2aca6a
1
vendor/github.com/mattermost/platform/einterfaces/ldap.go
generated
vendored
1
vendor/github.com/mattermost/platform/einterfaces/ldap.go
generated
vendored
@ -16,6 +16,7 @@ type LdapInterface interface {
|
||||
Syncronize() *model.AppError
|
||||
StartLdapSyncJob()
|
||||
SyncNow()
|
||||
RunTest() *model.AppError
|
||||
GetAllLdapUsers() ([]*model.User, *model.AppError)
|
||||
}
|
||||
|
||||
|
86
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
86
vendor/github.com/mattermost/platform/model/client.go
generated
vendored
@ -35,6 +35,8 @@ const (
|
||||
STATUS_OK = "OK"
|
||||
STATUS_FAIL = "FAIL"
|
||||
|
||||
CLIENT_DIR = "webapp/dist"
|
||||
|
||||
API_URL_SUFFIX_V1 = "/api/v1"
|
||||
API_URL_SUFFIX_V3 = "/api/v3"
|
||||
API_URL_SUFFIX = API_URL_SUFFIX_V3
|
||||
@ -818,6 +820,17 @@ func (c *Client) GetClusterStatus() ([]*ClusterInfo, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetRecentlyActiveUsers returns a map of users including lastActivityAt using user id as the key
|
||||
func (c *Client) GetRecentlyActiveUsers(teamId string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet("/admin/recently_active_users/"+teamId, "", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), UserMapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetAllAudits() (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet("/admin/audits", "", ""); err != nil {
|
||||
return nil, err
|
||||
@ -885,6 +898,19 @@ func (c *Client) TestEmail(config *Config) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestLdap will run a connection test on the current LDAP settings.
|
||||
// It will return the standard OK response if settings work. Otherwise
|
||||
// it will return an appropriate error.
|
||||
func (c *Client) TestLdap(config *Config) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/admin/ldap_test", config.ToJson()); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetComplianceReports() (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet("/admin/compliance_reports", "", ""); err != nil {
|
||||
return nil, err
|
||||
@ -1125,8 +1151,13 @@ func (c *Client) RemoveChannelMember(id, user_id string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) UpdateLastViewedAt(channelId string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_last_viewed_at", ""); err != nil {
|
||||
// UpdateLastViewedAt will mark a channel as read.
|
||||
// The channelId indicates the channel to mark as read. If active is true, push notifications
|
||||
// will be cleared if there are unread messages. The default for active is true.
|
||||
func (c *Client) UpdateLastViewedAt(channelId string, active bool) (*Result, *AppError) {
|
||||
data := make(map[string]interface{})
|
||||
data["active"] = active
|
||||
if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_last_viewed_at", StringInterfaceToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
@ -1448,6 +1479,21 @@ func (c *Client) GetStatuses() (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetActiveChannel sets the the channel id the user is currently viewing.
|
||||
// The channelId key is required but the value can be blank. Returns standard
|
||||
// response.
|
||||
func (c *Client) SetActiveChannel(channelId string) (*Result, *AppError) {
|
||||
data := map[string]string{}
|
||||
data["channel_id"] = channelId
|
||||
if r, err := c.DoApiPost("/users/status/set_active_channel", MapToJson(data)); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetMyTeam(etag string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet(c.GetTeamRoute()+"/me", "", etag); err != nil {
|
||||
return nil, err
|
||||
@ -1532,6 +1578,42 @@ func (c *Client) DeleteOAuthApp(id string) (*Result, *AppError) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetOAuthAuthorizedApps returns the OAuth2 Apps authorized by the user. On success
|
||||
// it returns a list of sanitized OAuth2 Authorized Apps by the user.
|
||||
func (c *Client) GetOAuthAuthorizedApps() (*Result, *AppError) {
|
||||
if r, err := c.DoApiGet("/oauth/authorized", "", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), OAuthAppListFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
// OAuthDeauthorizeApp deauthorize a user an OAuth 2.0 app. On success
|
||||
// it returns status OK or an AppError on fail.
|
||||
func (c *Client) OAuthDeauthorizeApp(clientId string) *AppError {
|
||||
if r, err := c.DoApiPost("/oauth/"+clientId+"/deauthorize", ""); err != nil {
|
||||
return err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// RegenerateOAuthAppSecret generates a new OAuth App Client Secret. On success
|
||||
// it returns an OAuth2 App. Must be authenticated as a user and the same user who
|
||||
// registered the app or a System Admin.
|
||||
func (c *Client) RegenerateOAuthAppSecret(clientId string) (*Result, *AppError) {
|
||||
if r, err := c.DoApiPost("/oauth/"+clientId+"/regen_secret", ""); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
defer closeBody(r)
|
||||
return &Result{r.Header.Get(HEADER_REQUEST_ID),
|
||||
r.Header.Get(HEADER_ETAG_SERVER), OAuthAppFromJson(r.Body)}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) GetAccessToken(data url.Values) (*Result, *AppError) {
|
||||
if r, err := c.DoPost("/oauth/access_token", data.Encode(), "application/x-www-form-urlencoded"); err != nil {
|
||||
return nil, err
|
||||
|
73
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
73
vendor/github.com/mattermost/platform/model/config.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
||||
|
||||
const (
|
||||
CONN_SECURITY_NONE = ""
|
||||
CONN_SECURITY_PLAIN = "PLAIN"
|
||||
CONN_SECURITY_TLS = "TLS"
|
||||
CONN_SECURITY_STARTTLS = "STARTTLS"
|
||||
|
||||
@ -47,6 +48,9 @@ const (
|
||||
RESTRICT_EMOJI_CREATION_ADMIN = "admin"
|
||||
RESTRICT_EMOJI_CREATION_SYSTEM_ADMIN = "system_admin"
|
||||
|
||||
EMAIL_BATCHING_BUFFER_SIZE = 256
|
||||
EMAIL_BATCHING_INTERVAL = 30
|
||||
|
||||
SITENAME_MAX_LENGTH = 30
|
||||
)
|
||||
|
||||
@ -114,6 +118,7 @@ type LogSettings struct {
|
||||
FileFormat string
|
||||
FileLocation string
|
||||
EnableWebhookDebugging bool
|
||||
EnableDiagnostics *bool
|
||||
}
|
||||
|
||||
type PasswordSettings struct {
|
||||
@ -129,7 +134,7 @@ type FileSettings struct {
|
||||
DriverName string
|
||||
Directory string
|
||||
EnablePublicLink bool
|
||||
PublicLinkSalt string
|
||||
PublicLinkSalt *string
|
||||
ThumbnailWidth int
|
||||
ThumbnailHeight int
|
||||
PreviewWidth int
|
||||
@ -166,6 +171,9 @@ type EmailSettings struct {
|
||||
SendPushNotifications *bool
|
||||
PushNotificationServer *string
|
||||
PushNotificationContents *string
|
||||
EnableEmailBatching *bool
|
||||
EmailBatchingBufferSize *int
|
||||
EmailBatchingInterval *int
|
||||
}
|
||||
|
||||
type RateLimitSettings struct {
|
||||
@ -350,8 +358,9 @@ func (o *Config) SetDefaults() {
|
||||
*o.FileSettings.MaxFileSize = 52428800 // 50 MB
|
||||
}
|
||||
|
||||
if len(o.FileSettings.PublicLinkSalt) == 0 {
|
||||
o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
||||
if len(*o.FileSettings.PublicLinkSalt) == 0 {
|
||||
o.FileSettings.PublicLinkSalt = new(string)
|
||||
*o.FileSettings.PublicLinkSalt = NewRandomString(32)
|
||||
}
|
||||
|
||||
if o.FileSettings.AmazonS3LocationConstraint == nil {
|
||||
@ -507,6 +516,21 @@ func (o *Config) SetDefaults() {
|
||||
*o.EmailSettings.FeedbackOrganization = ""
|
||||
}
|
||||
|
||||
if o.EmailSettings.EnableEmailBatching == nil {
|
||||
o.EmailSettings.EnableEmailBatching = new(bool)
|
||||
*o.EmailSettings.EnableEmailBatching = false
|
||||
}
|
||||
|
||||
if o.EmailSettings.EmailBatchingBufferSize == nil {
|
||||
o.EmailSettings.EmailBatchingBufferSize = new(int)
|
||||
*o.EmailSettings.EmailBatchingBufferSize = EMAIL_BATCHING_BUFFER_SIZE
|
||||
}
|
||||
|
||||
if o.EmailSettings.EmailBatchingInterval == nil {
|
||||
o.EmailSettings.EmailBatchingInterval = new(int)
|
||||
*o.EmailSettings.EmailBatchingInterval = EMAIL_BATCHING_INTERVAL
|
||||
}
|
||||
|
||||
if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
|
||||
o.SupportSettings.TermsOfServiceLink = nil
|
||||
}
|
||||
@ -758,6 +782,11 @@ func (o *Config) SetDefaults() {
|
||||
*o.LocalizationSettings.AvailableLocales = ""
|
||||
}
|
||||
|
||||
if o.LogSettings.EnableDiagnostics == nil {
|
||||
o.LogSettings.EnableDiagnostics = new(bool)
|
||||
*o.LogSettings.EnableDiagnostics = true
|
||||
}
|
||||
|
||||
if o.SamlSettings.Enable == nil {
|
||||
o.SamlSettings.Enable = new(bool)
|
||||
*o.SamlSettings.Enable = false
|
||||
@ -870,6 +899,14 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.ClusterSettings.Enable && *o.EmailSettings.EnableEmailBatching {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.ServiceSettings.SiteURL) == 0 && *o.EmailSettings.EnableEmailBatching {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.site_url_email_batching.app_error", nil, "")
|
||||
}
|
||||
|
||||
if o.TeamSettings.MaxUsersPerTeam <= 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.max_users.app_error", nil, "")
|
||||
}
|
||||
@ -930,11 +967,11 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.file_thumb_width.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(o.FileSettings.PublicLinkSalt) < 32 {
|
||||
if len(*o.FileSettings.PublicLinkSalt) < 32 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "")
|
||||
}
|
||||
|
||||
if !(o.EmailSettings.ConnectionSecurity == CONN_SECURITY_NONE || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_TLS || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_STARTTLS) {
|
||||
if !(o.EmailSettings.ConnectionSecurity == CONN_SECURITY_NONE || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_TLS || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_STARTTLS || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_PLAIN) {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_security.app_error", nil, "")
|
||||
}
|
||||
|
||||
@ -946,6 +983,14 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_reset_salt.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.EmailSettings.EmailBatchingBufferSize <= 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_batching_buffer_size.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.EmailSettings.EmailBatchingInterval < 30 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "")
|
||||
}
|
||||
|
||||
if o.RateLimitSettings.MemoryStoreSize <= 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.rate_mem.app_error", nil, "")
|
||||
}
|
||||
@ -975,14 +1020,6 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "")
|
||||
}
|
||||
|
||||
if *o.LdapSettings.FirstNameAttribute == "" {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_firstname", nil, "")
|
||||
}
|
||||
|
||||
if *o.LdapSettings.LastNameAttribute == "" {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_lastname", nil, "")
|
||||
}
|
||||
|
||||
if *o.LdapSettings.EmailAttribute == "" {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "")
|
||||
}
|
||||
@ -1017,14 +1054,6 @@ func (o *Config) IsValid() *AppError {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.FirstNameAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_first_name_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if len(*o.SamlSettings.LastNameAttribute) == 0 {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_last_name_attribute.app_error", nil, "")
|
||||
}
|
||||
|
||||
if *o.SamlSettings.Verify {
|
||||
if len(*o.SamlSettings.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*o.SamlSettings.AssertionConsumerServiceURL) {
|
||||
return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "")
|
||||
@ -1070,7 +1099,7 @@ func (o *Config) Sanitize() {
|
||||
*o.LdapSettings.BindPassword = FAKE_SETTING
|
||||
}
|
||||
|
||||
o.FileSettings.PublicLinkSalt = FAKE_SETTING
|
||||
*o.FileSettings.PublicLinkSalt = FAKE_SETTING
|
||||
if len(o.FileSettings.AmazonS3SecretAccessKey) > 0 {
|
||||
o.FileSettings.AmazonS3SecretAccessKey = FAKE_SETTING
|
||||
}
|
||||
|
16
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
16
vendor/github.com/mattermost/platform/model/license.go
generated
vendored
@ -46,6 +46,22 @@ type Features struct {
|
||||
FutureFeatures *bool `json:"future_features"`
|
||||
}
|
||||
|
||||
func (f *Features) ToMap() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"ldap": *f.LDAP,
|
||||
"mfa": *f.MFA,
|
||||
"google": *f.GoogleOAuth,
|
||||
"office365": *f.Office365OAuth,
|
||||
"compliance": *f.Compliance,
|
||||
"cluster": *f.Cluster,
|
||||
"custom_brand": *f.CustomBrand,
|
||||
"mhpns": *f.MHPNS,
|
||||
"saml": *f.SAML,
|
||||
"password": *f.PasswordRequirements,
|
||||
"future": *f.FutureFeatures,
|
||||
}
|
||||
}
|
||||
|
||||
func (f *Features) SetDefaults() {
|
||||
if f.FutureFeatures == nil {
|
||||
f.FutureFeatures = new(bool)
|
||||
|
3
vendor/github.com/mattermost/platform/model/post.go
generated
vendored
3
vendor/github.com/mattermost/platform/model/post.go
generated
vendored
@ -15,6 +15,7 @@ const (
|
||||
POST_SLACK_ATTACHMENT = "slack_attachment"
|
||||
POST_SYSTEM_GENERIC = "system_generic"
|
||||
POST_JOIN_LEAVE = "system_join_leave"
|
||||
POST_ADD_REMOVE = "system_add_remove"
|
||||
POST_HEADER_CHANGE = "system_header_change"
|
||||
POST_CHANNEL_DELETED = "system_channel_deleted"
|
||||
POST_EPHEMERAL = "system_ephemeral"
|
||||
@ -109,7 +110,7 @@ func (o *Post) IsValid() *AppError {
|
||||
}
|
||||
|
||||
// should be removed once more message types are supported
|
||||
if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_SLACK_ATTACHMENT || o.Type == POST_HEADER_CHANGE) {
|
||||
if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_ADD_REMOVE || o.Type == POST_SLACK_ATTACHMENT || o.Type == POST_HEADER_CHANGE) {
|
||||
return NewLocAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type)
|
||||
}
|
||||
|
||||
|
9
vendor/github.com/mattermost/platform/model/preference.go
generated
vendored
9
vendor/github.com/mattermost/platform/model/preference.go
generated
vendored
@ -19,6 +19,11 @@ const (
|
||||
|
||||
PREFERENCE_CATEGORY_DISPLAY_SETTINGS = "display_settings"
|
||||
PREFERENCE_NAME_COLLAPSE_SETTING = "collapse_previews"
|
||||
PREFERENCE_NAME_DISPLAY_NAME_FORMAT = "name_format"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_NICKNAME = "nickname_full_name"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_FULL = "full_name"
|
||||
PREFERENCE_VALUE_DISPLAY_NAME_USERNAME = "username"
|
||||
PREFERENCE_DEFAULT_DISPLAY_NAME_FORMAT = PREFERENCE_VALUE_DISPLAY_NAME_USERNAME
|
||||
|
||||
PREFERENCE_CATEGORY_THEME = "theme"
|
||||
// the name for theme props is the team id
|
||||
@ -28,6 +33,10 @@ const (
|
||||
|
||||
PREFERENCE_CATEGORY_LAST = "last"
|
||||
PREFERENCE_NAME_LAST_CHANNEL = "channel"
|
||||
|
||||
PREFERENCE_CATEGORY_NOTIFICATIONS = "notifications"
|
||||
PREFERENCE_NAME_EMAIL_INTERVAL = "email_interval"
|
||||
PREFERENCE_DEFAULT_EMAIL_INTERVAL = "30" // default to match the interval of the "immediate" setting (ie 30 seconds)
|
||||
)
|
||||
|
||||
type Preference struct {
|
||||
|
15
vendor/github.com/mattermost/platform/model/push_notification.go
generated
vendored
15
vendor/github.com/mattermost/platform/model/push_notification.go
generated
vendored
@ -6,12 +6,16 @@ package model
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
PUSH_NOTIFY_APPLE = "apple"
|
||||
PUSH_NOTIFY_ANDROID = "android"
|
||||
|
||||
PUSH_TYPE_MESSAGE = "message"
|
||||
PUSH_TYPE_CLEAR = "clear"
|
||||
|
||||
CATEGORY_DM = "DIRECT_MESSAGE"
|
||||
|
||||
MHPNS = "https://push.mattermost.com"
|
||||
@ -28,6 +32,7 @@ type PushNotification struct {
|
||||
ContentAvailable int `json:"cont_ava"`
|
||||
ChannelId string `json:"channel_id"`
|
||||
ChannelName string `json:"channel_name"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func (me *PushNotification) ToJson() string {
|
||||
@ -39,6 +44,16 @@ func (me *PushNotification) ToJson() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (me *PushNotification) SetDeviceIdAndPlatform(deviceId string) {
|
||||
if strings.HasPrefix(deviceId, PUSH_NOTIFY_APPLE+":") {
|
||||
me.Platform = PUSH_NOTIFY_APPLE
|
||||
me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_APPLE+":")
|
||||
} else if strings.HasPrefix(deviceId, PUSH_NOTIFY_ANDROID+":") {
|
||||
me.Platform = PUSH_NOTIFY_ANDROID
|
||||
me.DeviceId = strings.TrimPrefix(deviceId, PUSH_NOTIFY_ANDROID+":")
|
||||
}
|
||||
}
|
||||
|
||||
func PushNotificationFromJson(data io.Reader) *PushNotification {
|
||||
decoder := json.NewDecoder(data)
|
||||
var me PushNotification
|
||||
|
6
vendor/github.com/mattermost/platform/model/session.go
generated
vendored
6
vendor/github.com/mattermost/platform/model/session.go
generated
vendored
@ -6,6 +6,7 @@ package model
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -109,6 +110,11 @@ func (me *Session) GetTeamByTeamId(teamId string) *TeamMember {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (me *Session) IsMobileApp() bool {
|
||||
return len(me.DeviceId) > 0 &&
|
||||
(strings.HasPrefix(me.DeviceId, PUSH_NOTIFY_APPLE+":") || strings.HasPrefix(me.DeviceId, PUSH_NOTIFY_ANDROID+":"))
|
||||
}
|
||||
|
||||
func SessionsToJson(o []*Session) string {
|
||||
if b, err := json.Marshal(o); err != nil {
|
||||
return "[]"
|
||||
|
3
vendor/github.com/mattermost/platform/model/status.go
generated
vendored
3
vendor/github.com/mattermost/platform/model/status.go
generated
vendored
@ -13,12 +13,15 @@ const (
|
||||
STATUS_AWAY = "away"
|
||||
STATUS_ONLINE = "online"
|
||||
STATUS_CACHE_SIZE = 10000
|
||||
STATUS_CHANNEL_TIMEOUT = 20000 // 20 seconds
|
||||
)
|
||||
|
||||
type Status struct {
|
||||
UserId string `json:"user_id"`
|
||||
Status string `json:"status"`
|
||||
Manual bool `json:"manual"`
|
||||
LastActivityAt int64 `json:"last_activity_at"`
|
||||
ActiveChannel string `json:"active_channel"`
|
||||
}
|
||||
|
||||
func (o *Status) ToJson() string {
|
||||
|
26
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
26
vendor/github.com/mattermost/platform/model/user.go
generated
vendored
@ -48,6 +48,7 @@ type User struct {
|
||||
Locale string `json:"locale"`
|
||||
MfaActive bool `json:"mfa_active,omitempty"`
|
||||
MfaSecret string `json:"mfa_secret,omitempty"`
|
||||
LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"`
|
||||
}
|
||||
|
||||
// IsValid validates the user and returns an error if it isn't configured
|
||||
@ -235,7 +236,6 @@ func (u *User) Sanitize(options map[string]bool) {
|
||||
}
|
||||
|
||||
func (u *User) ClearNonProfileFields() {
|
||||
u.UpdateAt = 0
|
||||
u.Password = ""
|
||||
u.AuthData = new(string)
|
||||
*u.AuthData = ""
|
||||
@ -251,6 +251,12 @@ func (u *User) ClearNonProfileFields() {
|
||||
u.FailedAttempts = 0
|
||||
}
|
||||
|
||||
func (u *User) SanitizeProfile(options map[string]bool) {
|
||||
u.ClearNonProfileFields()
|
||||
|
||||
u.Sanitize(options)
|
||||
}
|
||||
|
||||
func (u *User) MakeNonNil() {
|
||||
if u.Props == nil {
|
||||
u.Props = make(map[string]string)
|
||||
@ -295,6 +301,24 @@ func (u *User) GetDisplayName() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *User) GetDisplayNameForPreference(nameFormat string) string {
|
||||
displayName := u.Username
|
||||
|
||||
if nameFormat == PREFERENCE_VALUE_DISPLAY_NAME_NICKNAME {
|
||||
if u.Nickname != "" {
|
||||
displayName = u.Nickname
|
||||
} else if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
} else if nameFormat == PREFERENCE_VALUE_DISPLAY_NAME_FULL {
|
||||
if fullName := u.GetFullName(); fullName != "" {
|
||||
displayName = fullName
|
||||
}
|
||||
}
|
||||
|
||||
return displayName
|
||||
}
|
||||
|
||||
func IsValidUserRoles(userRoles string) bool {
|
||||
|
||||
roles := strings.Split(userRoles, " ")
|
||||
|
1
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
1
vendor/github.com/mattermost/platform/model/version.go
generated
vendored
@ -13,6 +13,7 @@ import (
|
||||
// It should be maitained in chronological order with most current
|
||||
// release at the front of the list.
|
||||
var versions = []string{
|
||||
"3.4.0",
|
||||
"3.3.0",
|
||||
"3.2.0",
|
||||
"3.1.0",
|
||||
|
2
vendor/github.com/mattermost/platform/model/websocket_message.go
generated
vendored
2
vendor/github.com/mattermost/platform/model/websocket_message.go
generated
vendored
@ -19,10 +19,12 @@ const (
|
||||
WEBSOCKET_EVENT_NEW_USER = "new_user"
|
||||
WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
|
||||
WEBSOCKET_EVENT_USER_ADDED = "user_added"
|
||||
WEBSOCKET_EVENT_USER_UPDATED = "user_updated"
|
||||
WEBSOCKET_EVENT_USER_REMOVED = "user_removed"
|
||||
WEBSOCKET_EVENT_PREFERENCE_CHANGED = "preference_changed"
|
||||
WEBSOCKET_EVENT_EPHEMERAL_MESSAGE = "ephemeral_message"
|
||||
WEBSOCKET_EVENT_STATUS_CHANGE = "status_change"
|
||||
WEBSOCKET_EVENT_HELLO = "hello"
|
||||
)
|
||||
|
||||
type WebSocketMessage interface {
|
||||
|
8
vendor/manifest
vendored
8
vendor/manifest
vendored
@ -63,8 +63,8 @@
|
||||
"importpath": "github.com/mattermost/platform/einterfaces",
|
||||
"repository": "https://github.com/mattermost/platform",
|
||||
"vcs": "git",
|
||||
"revision": "20735470185e0b0ac1d15b975041ed9a2e0e43bc",
|
||||
"branch": "release-3.3",
|
||||
"revision": "57f25fa59c71821cc38fd220b133aa6a40815e12",
|
||||
"branch": "release-3.4",
|
||||
"path": "/einterfaces",
|
||||
"notests": true
|
||||
},
|
||||
@ -72,8 +72,8 @@
|
||||
"importpath": "github.com/mattermost/platform/model",
|
||||
"repository": "https://github.com/mattermost/platform",
|
||||
"vcs": "git",
|
||||
"revision": "20735470185e0b0ac1d15b975041ed9a2e0e43bc",
|
||||
"branch": "release-3.3",
|
||||
"revision": "57f25fa59c71821cc38fd220b133aa6a40815e12",
|
||||
"branch": "release-3.4",
|
||||
"path": "/model",
|
||||
"notests": true
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user