summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform/model
diff options
context:
space:
mode:
authorDuco van Amstel <helcaraxan@gmail.com>2018-11-18 17:55:05 +0000
committerWim <wim@42.be>2018-11-25 21:21:04 +0100
commit09875fe1603307080f3a4172985c5dca3bd9912d (patch)
treea23220772f6f6597d509ca71b2df3480a77b8076 /vendor/github.com/mattermost/platform/model
parentf716b8fc0ff90f47b61e218ef34019b38bd70e0d (diff)
downloadmatterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.gz
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.tar.bz2
matterbridge-msglm-09875fe1603307080f3a4172985c5dca3bd9912d.zip
Update direct dependencies where possible
Diffstat (limited to 'vendor/github.com/mattermost/platform/model')
-rw-r--r--vendor/github.com/mattermost/platform/model/access.go114
-rw-r--r--vendor/github.com/mattermost/platform/model/analytics_row.go55
-rw-r--r--vendor/github.com/mattermost/platform/model/audit.go39
-rw-r--r--vendor/github.com/mattermost/platform/model/audits.go39
-rw-r--r--vendor/github.com/mattermost/platform/model/authorization.go522
-rw-r--r--vendor/github.com/mattermost/platform/model/authorize.go159
-rw-r--r--vendor/github.com/mattermost/platform/model/builtin.go9
-rw-r--r--vendor/github.com/mattermost/platform/model/bundle_info.go23
-rw-r--r--vendor/github.com/mattermost/platform/model/channel.go226
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_count.go63
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_data.go43
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_list.go63
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_member.go171
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_member_history.go12
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_search.go35
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_stats.go34
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_view.go59
-rw-r--r--vendor/github.com/mattermost/platform/model/client.go2379
-rw-r--r--vendor/github.com/mattermost/platform/model/client4.go3225
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_discovery.go133
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_info.go62
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_message.go55
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_stats.go36
-rw-r--r--vendor/github.com/mattermost/platform/model/command.go157
-rw-r--r--vendor/github.com/mattermost/platform/model/command_args.go43
-rw-r--r--vendor/github.com/mattermost/platform/model/command_response.go65
-rw-r--r--vendor/github.com/mattermost/platform/model/command_webhook.go65
-rw-r--r--vendor/github.com/mattermost/platform/model/compliance.go133
-rw-r--r--vendor/github.com/mattermost/platform/model/compliance_post.go114
-rw-r--r--vendor/github.com/mattermost/platform/model/config.go2168
-rw-r--r--vendor/github.com/mattermost/platform/model/data_retention_policy.go36
-rw-r--r--vendor/github.com/mattermost/platform/model/emoji.go96
-rw-r--r--vendor/github.com/mattermost/platform/model/file.go43
-rw-r--r--vendor/github.com/mattermost/platform/model/file_info.go178
-rw-r--r--vendor/github.com/mattermost/platform/model/gitlab.go8
-rw-r--r--vendor/github.com/mattermost/platform/model/incoming_webhook.go224
-rw-r--r--vendor/github.com/mattermost/platform/model/initial_load.go39
-rw-r--r--vendor/github.com/mattermost/platform/model/job.go127
-rw-r--r--vendor/github.com/mattermost/platform/model/ldap.go9
-rw-r--r--vendor/github.com/mattermost/platform/model/license.go209
-rw-r--r--vendor/github.com/mattermost/platform/model/manifest.go246
-rw-r--r--vendor/github.com/mattermost/platform/model/message_export.go18
-rw-r--r--vendor/github.com/mattermost/platform/model/mfa_secret.go34
-rw-r--r--vendor/github.com/mattermost/platform/model/oauth.go191
-rw-r--r--vendor/github.com/mattermost/platform/model/outgoing_webhook.go284
-rw-r--r--vendor/github.com/mattermost/platform/model/plugin_key_value.go32
-rw-r--r--vendor/github.com/mattermost/platform/model/plugins_response.go39
-rw-r--r--vendor/github.com/mattermost/platform/model/post.go394
-rw-r--r--vendor/github.com/mattermost/platform/model/post_list.go134
-rw-r--r--vendor/github.com/mattermost/platform/model/preference.go122
-rw-r--r--vendor/github.com/mattermost/platform/model/preferences.go31
-rw-r--r--vendor/github.com/mattermost/platform/model/push_notification.go77
-rw-r--r--vendor/github.com/mattermost/platform/model/push_response.go57
-rw-r--r--vendor/github.com/mattermost/platform/model/reaction.go82
-rw-r--r--vendor/github.com/mattermost/platform/model/saml.go49
-rw-r--r--vendor/github.com/mattermost/platform/model/scheduled_task.go110
-rw-r--r--vendor/github.com/mattermost/platform/model/search_params.go175
-rw-r--r--vendor/github.com/mattermost/platform/model/security_bulletin.go55
-rw-r--r--vendor/github.com/mattermost/platform/model/session.go151
-rw-r--r--vendor/github.com/mattermost/platform/model/slack_attachment.go59
-rw-r--r--vendor/github.com/mattermost/platform/model/status.go78
-rw-r--r--vendor/github.com/mattermost/platform/model/suggest_command.go34
-rw-r--r--vendor/github.com/mattermost/platform/model/switch_request.go62
-rw-r--r--vendor/github.com/mattermost/platform/model/system.go42
-rw-r--r--vendor/github.com/mattermost/platform/model/team.go330
-rw-r--r--vendor/github.com/mattermost/platform/model/team_member.go122
-rw-r--r--vendor/github.com/mattermost/platform/model/team_search.go35
-rw-r--r--vendor/github.com/mattermost/platform/model/team_stats.go35
-rw-r--r--vendor/github.com/mattermost/platform/model/token.go40
-rw-r--r--vendor/github.com/mattermost/platform/model/user.go653
-rw-r--r--vendor/github.com/mattermost/platform/model/user_access_token.go83
-rw-r--r--vendor/github.com/mattermost/platform/model/user_autocomplete.go83
-rw-r--r--vendor/github.com/mattermost/platform/model/user_search.go41
-rw-r--r--vendor/github.com/mattermost/platform/model/utils.go494
-rw-r--r--vendor/github.com/mattermost/platform/model/version.go147
-rw-r--r--vendor/github.com/mattermost/platform/model/webrtc.go53
-rw-r--r--vendor/github.com/mattermost/platform/model/websocket_client.go167
-rw-r--r--vendor/github.com/mattermost/platform/model/websocket_message.go149
-rw-r--r--vendor/github.com/mattermost/platform/model/websocket_request.go43
79 files changed, 0 insertions, 16301 deletions
diff --git a/vendor/github.com/mattermost/platform/model/access.go b/vendor/github.com/mattermost/platform/model/access.go
deleted file mode 100644
index 551ef930..00000000
--- a/vendor/github.com/mattermost/platform/model/access.go
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-const (
- ACCESS_TOKEN_GRANT_TYPE = "authorization_code"
- ACCESS_TOKEN_TYPE = "bearer"
- REFRESH_TOKEN_GRANT_TYPE = "refresh_token"
-)
-
-type AccessData struct {
- ClientId string `json:"client_id"`
- UserId string `json:"user_id"`
- Token string `json:"token"`
- RefreshToken string `json:"refresh_token"`
- RedirectUri string `json:"redirect_uri"`
- ExpiresAt int64 `json:"expires_at"`
- Scope string `json:"scope"`
-}
-
-type AccessResponse struct {
- AccessToken string `json:"access_token"`
- TokenType string `json:"token_type"`
- ExpiresIn int32 `json:"expires_in"`
- Scope string `json:"scope"`
- RefreshToken string `json:"refresh_token"`
-}
-
-// IsValid validates the AccessData and returns an error if it isn't configured
-// correctly.
-func (ad *AccessData) IsValid() *AppError {
-
- if len(ad.ClientId) == 0 || len(ad.ClientId) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.UserId) == 0 || len(ad.UserId) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.Token) != 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.access_token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.RefreshToken) > 26 {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.refresh_token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.RedirectUri) == 0 || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
- return NewAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (me *AccessData) IsExpired() bool {
-
- if me.ExpiresAt <= 0 {
- return false
- }
-
- if GetMillis() > me.ExpiresAt {
- return true
- }
-
- return false
-}
-
-func (ad *AccessData) ToJson() string {
- b, err := json.Marshal(ad)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AccessDataFromJson(data io.Reader) *AccessData {
- decoder := json.NewDecoder(data)
- var ad AccessData
- err := decoder.Decode(&ad)
- if err == nil {
- return &ad
- } else {
- return nil
- }
-}
-
-func (ar *AccessResponse) ToJson() string {
- b, err := json.Marshal(ar)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AccessResponseFromJson(data io.Reader) *AccessResponse {
- decoder := json.NewDecoder(data)
- var ar AccessResponse
- err := decoder.Decode(&ar)
- if err == nil {
- return &ar
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/analytics_row.go b/vendor/github.com/mattermost/platform/model/analytics_row.go
deleted file mode 100644
index 5493163d..00000000
--- a/vendor/github.com/mattermost/platform/model/analytics_row.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type AnalyticsRow struct {
- Name string `json:"name"`
- Value float64 `json:"value"`
-}
-
-type AnalyticsRows []*AnalyticsRow
-
-func (me *AnalyticsRow) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AnalyticsRowFromJson(data io.Reader) *AnalyticsRow {
- decoder := json.NewDecoder(data)
- var me AnalyticsRow
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
-
-func (me AnalyticsRows) ToJson() string {
- if b, err := json.Marshal(me); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func AnalyticsRowsFromJson(data io.Reader) AnalyticsRows {
- decoder := json.NewDecoder(data)
- var me AnalyticsRows
- err := decoder.Decode(&me)
- if err == nil {
- return me
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/audit.go b/vendor/github.com/mattermost/platform/model/audit.go
deleted file mode 100644
index 7699cf93..00000000
--- a/vendor/github.com/mattermost/platform/model/audit.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type Audit struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UserId string `json:"user_id"`
- Action string `json:"action"`
- ExtraInfo string `json:"extra_info"`
- IpAddress string `json:"ip_address"`
- SessionId string `json:"session_id"`
-}
-
-func (o *Audit) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AuditFromJson(data io.Reader) *Audit {
- decoder := json.NewDecoder(data)
- var o Audit
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/audits.go b/vendor/github.com/mattermost/platform/model/audits.go
deleted file mode 100644
index e57e2a3a..00000000
--- a/vendor/github.com/mattermost/platform/model/audits.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type Audits []Audit
-
-func (o Audits) Etag() string {
- if len(o) > 0 {
- // the first in the list is always the most current
- return Etag(o[0].CreateAt)
- } else {
- return ""
- }
-}
-
-func (o Audits) ToJson() string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func AuditsFromJson(data io.Reader) Audits {
- decoder := json.NewDecoder(data)
- var o Audits
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/authorization.go b/vendor/github.com/mattermost/platform/model/authorization.go
deleted file mode 100644
index 9f4e36ea..00000000
--- a/vendor/github.com/mattermost/platform/model/authorization.go
+++ /dev/null
@@ -1,522 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-type Permission struct {
- Id string `json:"id"`
- Name string `json:"name"`
- Description string `json:"description"`
-}
-
-type Role struct {
- Id string `json:"id"`
- Name string `json:"name"`
- Description string `json:"description"`
- Permissions []string `json:"permissions"`
-}
-
-var PERMISSION_INVITE_USER *Permission
-var PERMISSION_ADD_USER_TO_TEAM *Permission
-var PERMISSION_USE_SLASH_COMMANDS *Permission
-var PERMISSION_MANAGE_SLASH_COMMANDS *Permission
-var PERMISSION_MANAGE_OTHERS_SLASH_COMMANDS *Permission
-var PERMISSION_CREATE_PUBLIC_CHANNEL *Permission
-var PERMISSION_CREATE_PRIVATE_CHANNEL *Permission
-var PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS *Permission
-var PERMISSION_MANAGE_PRIVATE_CHANNEL_MEMBERS *Permission
-var PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE *Permission
-var PERMISSION_MANAGE_ROLES *Permission
-var PERMISSION_MANAGE_TEAM_ROLES *Permission
-var PERMISSION_MANAGE_CHANNEL_ROLES *Permission
-var PERMISSION_CREATE_DIRECT_CHANNEL *Permission
-var PERMISSION_CREATE_GROUP_CHANNEL *Permission
-var PERMISSION_MANAGE_PUBLIC_CHANNEL_PROPERTIES *Permission
-var PERMISSION_MANAGE_PRIVATE_CHANNEL_PROPERTIES *Permission
-var PERMISSION_LIST_TEAM_CHANNELS *Permission
-var PERMISSION_JOIN_PUBLIC_CHANNELS *Permission
-var PERMISSION_DELETE_PUBLIC_CHANNEL *Permission
-var PERMISSION_DELETE_PRIVATE_CHANNEL *Permission
-var PERMISSION_EDIT_OTHER_USERS *Permission
-var PERMISSION_READ_CHANNEL *Permission
-var PERMISSION_READ_PUBLIC_CHANNEL *Permission
-var PERMISSION_PERMANENT_DELETE_USER *Permission
-var PERMISSION_UPLOAD_FILE *Permission
-var PERMISSION_GET_PUBLIC_LINK *Permission
-var PERMISSION_MANAGE_WEBHOOKS *Permission
-var PERMISSION_MANAGE_OTHERS_WEBHOOKS *Permission
-var PERMISSION_MANAGE_OAUTH *Permission
-var PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH *Permission
-var PERMISSION_CREATE_POST *Permission
-var PERMISSION_CREATE_POST_PUBLIC *Permission
-var PERMISSION_EDIT_POST *Permission
-var PERMISSION_EDIT_OTHERS_POSTS *Permission
-var PERMISSION_DELETE_POST *Permission
-var PERMISSION_DELETE_OTHERS_POSTS *Permission
-var PERMISSION_REMOVE_USER_FROM_TEAM *Permission
-var PERMISSION_CREATE_TEAM *Permission
-var PERMISSION_MANAGE_TEAM *Permission
-var PERMISSION_IMPORT_TEAM *Permission
-var PERMISSION_VIEW_TEAM *Permission
-var PERMISSION_LIST_USERS_WITHOUT_TEAM *Permission
-var PERMISSION_MANAGE_JOBS *Permission
-var PERMISSION_CREATE_USER_ACCESS_TOKEN *Permission
-var PERMISSION_READ_USER_ACCESS_TOKEN *Permission
-var PERMISSION_REVOKE_USER_ACCESS_TOKEN *Permission
-
-// General permission that encompases all system admin functions
-// in the future this could be broken up to allow access to some
-// admin functions but not others
-var PERMISSION_MANAGE_SYSTEM *Permission
-
-const (
- SYSTEM_USER_ROLE_ID = "system_user"
- SYSTEM_ADMIN_ROLE_ID = "system_admin"
- SYSTEM_POST_ALL_ROLE_ID = "system_post_all"
- SYSTEM_POST_ALL_PUBLIC_ROLE_ID = "system_post_all_public"
- SYSTEM_USER_ACCESS_TOKEN_ROLE_ID = "system_user_access_token"
-
- TEAM_USER_ROLE_ID = "team_user"
- TEAM_ADMIN_ROLE_ID = "team_admin"
- TEAM_POST_ALL_ROLE_ID = "team_post_all"
- TEAM_POST_ALL_PUBLIC_ROLE_ID = "team_post_all_public"
-
- CHANNEL_USER_ROLE_ID = "channel_user"
- CHANNEL_ADMIN_ROLE_ID = "channel_admin"
- CHANNEL_GUEST_ROLE_ID = "guest"
-)
-
-func initializePermissions() {
- PERMISSION_INVITE_USER = &Permission{
- "invite_user",
- "authentication.permissions.team_invite_user.name",
- "authentication.permissions.team_invite_user.description",
- }
- PERMISSION_ADD_USER_TO_TEAM = &Permission{
- "add_user_to_team",
- "authentication.permissions.add_user_to_team.name",
- "authentication.permissions.add_user_to_team.description",
- }
- PERMISSION_USE_SLASH_COMMANDS = &Permission{
- "use_slash_commands",
- "authentication.permissions.team_use_slash_commands.name",
- "authentication.permissions.team_use_slash_commands.description",
- }
- PERMISSION_MANAGE_SLASH_COMMANDS = &Permission{
- "manage_slash_commands",
- "authentication.permissions.manage_slash_commands.name",
- "authentication.permissions.manage_slash_commands.description",
- }
- PERMISSION_MANAGE_OTHERS_SLASH_COMMANDS = &Permission{
- "manage_others_slash_commands",
- "authentication.permissions.manage_others_slash_commands.name",
- "authentication.permissions.manage_others_slash_commands.description",
- }
- PERMISSION_CREATE_PUBLIC_CHANNEL = &Permission{
- "create_public_channel",
- "authentication.permissions.create_public_channel.name",
- "authentication.permissions.create_public_channel.description",
- }
- PERMISSION_CREATE_PRIVATE_CHANNEL = &Permission{
- "create_private_channel",
- "authentication.permissions.create_private_channel.name",
- "authentication.permissions.create_private_channel.description",
- }
- PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS = &Permission{
- "manage_public_channel_members",
- "authentication.permissions.manage_public_channel_members.name",
- "authentication.permissions.manage_public_channel_members.description",
- }
- PERMISSION_MANAGE_PRIVATE_CHANNEL_MEMBERS = &Permission{
- "manage_private_channel_members",
- "authentication.permissions.manage_private_channel_members.name",
- "authentication.permissions.manage_private_channel_members.description",
- }
- PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE = &Permission{
- "assign_system_admin_role",
- "authentication.permissions.assign_system_admin_role.name",
- "authentication.permissions.assign_system_admin_role.description",
- }
- PERMISSION_MANAGE_ROLES = &Permission{
- "manage_roles",
- "authentication.permissions.manage_roles.name",
- "authentication.permissions.manage_roles.description",
- }
- PERMISSION_MANAGE_TEAM_ROLES = &Permission{
- "manage_team_roles",
- "authentication.permissions.manage_team_roles.name",
- "authentication.permissions.manage_team_roles.description",
- }
- PERMISSION_MANAGE_CHANNEL_ROLES = &Permission{
- "manage_channel_roles",
- "authentication.permissions.manage_channel_roles.name",
- "authentication.permissions.manage_channel_roles.description",
- }
- PERMISSION_MANAGE_SYSTEM = &Permission{
- "manage_system",
- "authentication.permissions.manage_system.name",
- "authentication.permissions.manage_system.description",
- }
- PERMISSION_CREATE_DIRECT_CHANNEL = &Permission{
- "create_direct_channel",
- "authentication.permissions.create_direct_channel.name",
- "authentication.permissions.create_direct_channel.description",
- }
- PERMISSION_CREATE_GROUP_CHANNEL = &Permission{
- "create_group_channel",
- "authentication.permissions.create_group_channel.name",
- "authentication.permissions.create_group_channel.description",
- }
- PERMISSION_MANAGE_PUBLIC_CHANNEL_PROPERTIES = &Permission{
- "manage__publicchannel_properties",
- "authentication.permissions.manage_public_channel_properties.name",
- "authentication.permissions.manage_public_channel_properties.description",
- }
- PERMISSION_MANAGE_PRIVATE_CHANNEL_PROPERTIES = &Permission{
- "manage_private_channel_properties",
- "authentication.permissions.manage_private_channel_properties.name",
- "authentication.permissions.manage_private_channel_properties.description",
- }
- PERMISSION_LIST_TEAM_CHANNELS = &Permission{
- "list_team_channels",
- "authentication.permissions.list_team_channels.name",
- "authentication.permissions.list_team_channels.description",
- }
- PERMISSION_JOIN_PUBLIC_CHANNELS = &Permission{
- "join_public_channels",
- "authentication.permissions.join_public_channels.name",
- "authentication.permissions.join_public_channels.description",
- }
- PERMISSION_DELETE_PUBLIC_CHANNEL = &Permission{
- "delete_public_channel",
- "authentication.permissions.delete_public_channel.name",
- "authentication.permissions.delete_public_channel.description",
- }
- PERMISSION_DELETE_PRIVATE_CHANNEL = &Permission{
- "delete_private_channel",
- "authentication.permissions.delete_private_channel.name",
- "authentication.permissions.delete_private_channel.description",
- }
- PERMISSION_EDIT_OTHER_USERS = &Permission{
- "edit_other_users",
- "authentication.permissions.edit_other_users.name",
- "authentication.permissions.edit_other_users.description",
- }
- PERMISSION_READ_CHANNEL = &Permission{
- "read_channel",
- "authentication.permissions.read_channel.name",
- "authentication.permissions.read_channel.description",
- }
- PERMISSION_READ_PUBLIC_CHANNEL = &Permission{
- "read_public_channel",
- "authentication.permissions.read_public_channel.name",
- "authentication.permissions.read_public_channel.description",
- }
- PERMISSION_PERMANENT_DELETE_USER = &Permission{
- "permanent_delete_user",
- "authentication.permissions.permanent_delete_user.name",
- "authentication.permissions.permanent_delete_user.description",
- }
- PERMISSION_UPLOAD_FILE = &Permission{
- "upload_file",
- "authentication.permissions.upload_file.name",
- "authentication.permissions.upload_file.description",
- }
- PERMISSION_GET_PUBLIC_LINK = &Permission{
- "get_public_link",
- "authentication.permissions.get_public_link.name",
- "authentication.permissions.get_public_link.description",
- }
- PERMISSION_MANAGE_WEBHOOKS = &Permission{
- "manage_webhooks",
- "authentication.permissions.manage_webhooks.name",
- "authentication.permissions.manage_webhooks.description",
- }
- PERMISSION_MANAGE_OTHERS_WEBHOOKS = &Permission{
- "manage_others_webhooks",
- "authentication.permissions.manage_others_webhooks.name",
- "authentication.permissions.manage_others_webhooks.description",
- }
- PERMISSION_MANAGE_OAUTH = &Permission{
- "manage_oauth",
- "authentication.permissions.manage_oauth.name",
- "authentication.permissions.manage_oauth.description",
- }
- PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH = &Permission{
- "manage_sytem_wide_oauth",
- "authentication.permissions.manage_sytem_wide_oauth.name",
- "authentication.permissions.manage_sytem_wide_oauth.description",
- }
- PERMISSION_CREATE_POST = &Permission{
- "create_post",
- "authentication.permissions.create_post.name",
- "authentication.permissions.create_post.description",
- }
- PERMISSION_CREATE_POST_PUBLIC = &Permission{
- "create_post_public",
- "authentication.permissions.create_post_public.name",
- "authentication.permissions.create_post_public.description",
- }
- PERMISSION_EDIT_POST = &Permission{
- "edit_post",
- "authentication.permissions.edit_post.name",
- "authentication.permissions.edit_post.description",
- }
- PERMISSION_EDIT_OTHERS_POSTS = &Permission{
- "edit_others_posts",
- "authentication.permissions.edit_others_posts.name",
- "authentication.permissions.edit_others_posts.description",
- }
- PERMISSION_DELETE_POST = &Permission{
- "delete_post",
- "authentication.permissions.delete_post.name",
- "authentication.permissions.delete_post.description",
- }
- PERMISSION_DELETE_OTHERS_POSTS = &Permission{
- "delete_others_posts",
- "authentication.permissions.delete_others_posts.name",
- "authentication.permissions.delete_others_posts.description",
- }
- PERMISSION_REMOVE_USER_FROM_TEAM = &Permission{
- "remove_user_from_team",
- "authentication.permissions.remove_user_from_team.name",
- "authentication.permissions.remove_user_from_team.description",
- }
- PERMISSION_CREATE_TEAM = &Permission{
- "create_team",
- "authentication.permissions.create_team.name",
- "authentication.permissions.create_team.description",
- }
- PERMISSION_MANAGE_TEAM = &Permission{
- "manage_team",
- "authentication.permissions.manage_team.name",
- "authentication.permissions.manage_team.description",
- }
- PERMISSION_IMPORT_TEAM = &Permission{
- "import_team",
- "authentication.permissions.import_team.name",
- "authentication.permissions.import_team.description",
- }
- PERMISSION_VIEW_TEAM = &Permission{
- "view_team",
- "authentication.permissions.view_team.name",
- "authentication.permissions.view_team.description",
- }
- PERMISSION_LIST_USERS_WITHOUT_TEAM = &Permission{
- "list_users_without_team",
- "authentication.permissions.list_users_without_team.name",
- "authentication.permissions.list_users_without_team.description",
- }
- PERMISSION_CREATE_USER_ACCESS_TOKEN = &Permission{
- "create_user_access_token",
- "authentication.permissions.create_user_access_token.name",
- "authentication.permissions.create_user_access_token.description",
- }
- PERMISSION_READ_USER_ACCESS_TOKEN = &Permission{
- "read_user_access_token",
- "authentication.permissions.read_user_access_token.name",
- "authentication.permissions.read_user_access_token.description",
- }
- PERMISSION_REVOKE_USER_ACCESS_TOKEN = &Permission{
- "revoke_user_access_token",
- "authentication.permissions.revoke_user_access_token.name",
- "authentication.permissions.revoke_user_access_token.description",
- }
- PERMISSION_MANAGE_JOBS = &Permission{
- "manage_jobs",
- "authentication.permisssions.manage_jobs.name",
- "authentication.permisssions.manage_jobs.description",
- }
-}
-
-var DefaultRoles map[string]*Role
-
-func initializeDefaultRoles() {
- DefaultRoles = make(map[string]*Role)
-
- DefaultRoles[CHANNEL_USER_ROLE_ID] = &Role{
- "channel_user",
- "authentication.roles.channel_user.name",
- "authentication.roles.channel_user.description",
- []string{
- PERMISSION_READ_CHANNEL.Id,
- PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS.Id,
- PERMISSION_UPLOAD_FILE.Id,
- PERMISSION_GET_PUBLIC_LINK.Id,
- PERMISSION_CREATE_POST.Id,
- PERMISSION_EDIT_POST.Id,
- PERMISSION_USE_SLASH_COMMANDS.Id,
- },
- }
-
- DefaultRoles[CHANNEL_ADMIN_ROLE_ID] = &Role{
- "channel_admin",
- "authentication.roles.channel_admin.name",
- "authentication.roles.channel_admin.description",
- []string{
- PERMISSION_MANAGE_CHANNEL_ROLES.Id,
- },
- }
-
- DefaultRoles[CHANNEL_GUEST_ROLE_ID] = &Role{
- "guest",
- "authentication.roles.global_guest.name",
- "authentication.roles.global_guest.description",
- []string{},
- }
-
- DefaultRoles[TEAM_USER_ROLE_ID] = &Role{
- "team_user",
- "authentication.roles.team_user.name",
- "authentication.roles.team_user.description",
- []string{
- PERMISSION_LIST_TEAM_CHANNELS.Id,
- PERMISSION_JOIN_PUBLIC_CHANNELS.Id,
- PERMISSION_READ_PUBLIC_CHANNEL.Id,
- PERMISSION_VIEW_TEAM.Id,
- },
- }
-
- DefaultRoles[TEAM_POST_ALL_ROLE_ID] = &Role{
- "team_post_all",
- "authentication.roles.team_post_all.name",
- "authentication.roles.team_post_all.description",
- []string{
- PERMISSION_CREATE_POST.Id,
- },
- }
-
- DefaultRoles[TEAM_POST_ALL_PUBLIC_ROLE_ID] = &Role{
- "team_post_all_public",
- "authentication.roles.team_post_all_public.name",
- "authentication.roles.team_post_all_public.description",
- []string{
- PERMISSION_CREATE_POST_PUBLIC.Id,
- },
- }
-
- DefaultRoles[TEAM_ADMIN_ROLE_ID] = &Role{
- "team_admin",
- "authentication.roles.team_admin.name",
- "authentication.roles.team_admin.description",
- []string{
- PERMISSION_EDIT_OTHERS_POSTS.Id,
- PERMISSION_REMOVE_USER_FROM_TEAM.Id,
- PERMISSION_MANAGE_TEAM.Id,
- PERMISSION_IMPORT_TEAM.Id,
- PERMISSION_MANAGE_TEAM_ROLES.Id,
- PERMISSION_MANAGE_CHANNEL_ROLES.Id,
- PERMISSION_MANAGE_OTHERS_WEBHOOKS.Id,
- PERMISSION_MANAGE_SLASH_COMMANDS.Id,
- PERMISSION_MANAGE_OTHERS_SLASH_COMMANDS.Id,
- PERMISSION_MANAGE_WEBHOOKS.Id,
- },
- }
-
- DefaultRoles[SYSTEM_USER_ROLE_ID] = &Role{
- "system_user",
- "authentication.roles.global_user.name",
- "authentication.roles.global_user.description",
- []string{
- PERMISSION_CREATE_DIRECT_CHANNEL.Id,
- PERMISSION_CREATE_GROUP_CHANNEL.Id,
- PERMISSION_PERMANENT_DELETE_USER.Id,
- },
- }
-
- DefaultRoles[SYSTEM_POST_ALL_ROLE_ID] = &Role{
- "system_post_all",
- "authentication.roles.system_post_all.name",
- "authentication.roles.system_post_all.description",
- []string{
- PERMISSION_CREATE_POST.Id,
- },
- }
-
- DefaultRoles[SYSTEM_POST_ALL_PUBLIC_ROLE_ID] = &Role{
- "system_post_all_public",
- "authentication.roles.system_post_all_public.name",
- "authentication.roles.system_post_all_public.description",
- []string{
- PERMISSION_CREATE_POST_PUBLIC.Id,
- },
- }
-
- DefaultRoles[SYSTEM_USER_ACCESS_TOKEN_ROLE_ID] = &Role{
- "system_user_access_token",
- "authentication.roles.system_user_access_token.name",
- "authentication.roles.system_user_access_token.description",
- []string{
- PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
- PERMISSION_READ_USER_ACCESS_TOKEN.Id,
- PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
- },
- }
-
- DefaultRoles[SYSTEM_ADMIN_ROLE_ID] = &Role{
- "system_admin",
- "authentication.roles.global_admin.name",
- "authentication.roles.global_admin.description",
- // System admins can do anything channel and team admins can do
- // plus everything members of teams and channels can do to all teams
- // and channels on the system
- append(
- append(
- append(
- append(
- []string{
- PERMISSION_ASSIGN_SYSTEM_ADMIN_ROLE.Id,
- PERMISSION_MANAGE_SYSTEM.Id,
- PERMISSION_MANAGE_ROLES.Id,
- PERMISSION_MANAGE_PUBLIC_CHANNEL_PROPERTIES.Id,
- PERMISSION_MANAGE_PUBLIC_CHANNEL_MEMBERS.Id,
- PERMISSION_MANAGE_PRIVATE_CHANNEL_MEMBERS.Id,
- PERMISSION_DELETE_PUBLIC_CHANNEL.Id,
- PERMISSION_CREATE_PUBLIC_CHANNEL.Id,
- PERMISSION_MANAGE_PRIVATE_CHANNEL_PROPERTIES.Id,
- PERMISSION_DELETE_PRIVATE_CHANNEL.Id,
- PERMISSION_CREATE_PRIVATE_CHANNEL.Id,
- PERMISSION_MANAGE_SYSTEM_WIDE_OAUTH.Id,
- PERMISSION_MANAGE_OTHERS_WEBHOOKS.Id,
- PERMISSION_EDIT_OTHER_USERS.Id,
- PERMISSION_MANAGE_OAUTH.Id,
- PERMISSION_INVITE_USER.Id,
- PERMISSION_DELETE_POST.Id,
- PERMISSION_DELETE_OTHERS_POSTS.Id,
- PERMISSION_CREATE_TEAM.Id,
- PERMISSION_ADD_USER_TO_TEAM.Id,
- PERMISSION_LIST_USERS_WITHOUT_TEAM.Id,
- PERMISSION_MANAGE_JOBS.Id,
- PERMISSION_CREATE_POST_PUBLIC.Id,
- PERMISSION_CREATE_USER_ACCESS_TOKEN.Id,
- PERMISSION_READ_USER_ACCESS_TOKEN.Id,
- PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
- },
- DefaultRoles[TEAM_USER_ROLE_ID].Permissions...,
- ),
- DefaultRoles[CHANNEL_USER_ROLE_ID].Permissions...,
- ),
- DefaultRoles[TEAM_ADMIN_ROLE_ID].Permissions...,
- ),
- DefaultRoles[CHANNEL_ADMIN_ROLE_ID].Permissions...,
- ),
- }
-}
-
-func RoleIdsToString(roles []string) string {
- output := ""
- for _, role := range roles {
- output += role + ", "
- }
-
- if output == "" {
- return "[<NO ROLES>]"
- }
-
- return output[:len(output)-1]
-}
-
-func init() {
- initializePermissions()
- initializeDefaultRoles()
-}
diff --git a/vendor/github.com/mattermost/platform/model/authorize.go b/vendor/github.com/mattermost/platform/model/authorize.go
deleted file mode 100644
index df07ff14..00000000
--- a/vendor/github.com/mattermost/platform/model/authorize.go
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-const (
- AUTHCODE_EXPIRE_TIME = 60 * 10 // 10 minutes
- AUTHCODE_RESPONSE_TYPE = "code"
- DEFAULT_SCOPE = "user"
-)
-
-type AuthData struct {
- ClientId string `json:"client_id"`
- UserId string `json:"user_id"`
- Code string `json:"code"`
- ExpiresIn int32 `json:"expires_in"`
- CreateAt int64 `json:"create_at"`
- RedirectUri string `json:"redirect_uri"`
- State string `json:"state"`
- Scope string `json:"scope"`
-}
-
-type AuthorizeRequest struct {
- ResponseType string `json:"response_type"`
- ClientId string `json:"client_id"`
- RedirectUri string `json:"redirect_uri"`
- Scope string `json:"scope"`
- State string `json:"state"`
-}
-
-// IsValid validates the AuthData and returns an error if it isn't configured
-// correctly.
-func (ad *AuthData) IsValid() *AppError {
-
- if len(ad.ClientId) != 26 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.UserId) != 26 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ad.Code) == 0 || len(ad.Code) > 128 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.auth_code.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
- }
-
- if ad.ExpiresIn == 0 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.expires.app_error", nil, "", http.StatusBadRequest)
- }
-
- if ad.CreateAt <= 0 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.create_at.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
- }
-
- if len(ad.RedirectUri) == 0 || len(ad.RedirectUri) > 256 || !IsValidHttpUrl(ad.RedirectUri) {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
- }
-
- if len(ad.State) > 128 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.state.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
- }
-
- if len(ad.Scope) > 128 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.scope.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
- }
-
- return nil
-}
-
-// IsValid validates the AuthorizeRequest and returns an error if it isn't configured
-// correctly.
-func (ar *AuthorizeRequest) IsValid() *AppError {
-
- if len(ar.ClientId) != 26 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ar.ResponseType) == 0 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.response_type.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ar.RedirectUri) == 0 || len(ar.RedirectUri) > 256 || !IsValidHttpUrl(ar.RedirectUri) {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ar.ClientId, http.StatusBadRequest)
- }
-
- if len(ar.State) > 128 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.state.app_error", nil, "client_id="+ar.ClientId, http.StatusBadRequest)
- }
-
- if len(ar.Scope) > 128 {
- return NewAppError("AuthData.IsValid", "model.authorize.is_valid.scope.app_error", nil, "client_id="+ar.ClientId, http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ad *AuthData) PreSave() {
- if ad.ExpiresIn == 0 {
- ad.ExpiresIn = AUTHCODE_EXPIRE_TIME
- }
-
- if ad.CreateAt == 0 {
- ad.CreateAt = GetMillis()
- }
-
- if len(ad.Scope) == 0 {
- ad.Scope = DEFAULT_SCOPE
- }
-}
-
-func (ad *AuthData) ToJson() string {
- b, err := json.Marshal(ad)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AuthDataFromJson(data io.Reader) *AuthData {
- decoder := json.NewDecoder(data)
- var ad AuthData
- err := decoder.Decode(&ad)
- if err == nil {
- return &ad
- } else {
- return nil
- }
-}
-
-func (ar *AuthorizeRequest) ToJson() string {
- b, err := json.Marshal(ar)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func AuthorizeRequestFromJson(data io.Reader) *AuthorizeRequest {
- decoder := json.NewDecoder(data)
- var ar AuthorizeRequest
- err := decoder.Decode(&ar)
- if err == nil {
- return &ar
- } else {
- return nil
- }
-}
-
-func (ad *AuthData) IsExpired() bool {
- return GetMillis() > ad.CreateAt+int64(ad.ExpiresIn*1000)
-}
diff --git a/vendor/github.com/mattermost/platform/model/builtin.go b/vendor/github.com/mattermost/platform/model/builtin.go
deleted file mode 100644
index 5dd00a96..00000000
--- a/vendor/github.com/mattermost/platform/model/builtin.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-func NewBool(b bool) *bool { return &b }
-func NewInt(n int) *int { return &n }
-func NewInt64(n int64) *int64 { return &n }
-func NewString(s string) *string { return &s }
diff --git a/vendor/github.com/mattermost/platform/model/bundle_info.go b/vendor/github.com/mattermost/platform/model/bundle_info.go
deleted file mode 100644
index 6965159c..00000000
--- a/vendor/github.com/mattermost/platform/model/bundle_info.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-type BundleInfo struct {
- Path string
-
- Manifest *Manifest
- ManifestPath string
- ManifestError error
-}
-
-// Returns bundle info for the given path. The return value is never nil.
-func BundleInfoForPath(path string) *BundleInfo {
- m, mpath, err := FindManifest(path)
- return &BundleInfo{
- Path: path,
- Manifest: m,
- ManifestPath: mpath,
- ManifestError: err,
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel.go b/vendor/github.com/mattermost/platform/model/channel.go
deleted file mode 100644
index a4c733c3..00000000
--- a/vendor/github.com/mattermost/platform/model/channel.go
+++ /dev/null
@@ -1,226 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "crypto/sha1"
- "encoding/hex"
- "encoding/json"
- "io"
- "net/http"
- "sort"
- "strings"
- "unicode/utf8"
-)
-
-const (
- CHANNEL_OPEN = "O"
- CHANNEL_PRIVATE = "P"
- CHANNEL_DIRECT = "D"
- CHANNEL_GROUP = "G"
- CHANNEL_GROUP_MAX_USERS = 8
- CHANNEL_GROUP_MIN_USERS = 3
- DEFAULT_CHANNEL = "town-square"
- CHANNEL_DISPLAY_NAME_MAX_RUNES = 64
- CHANNEL_NAME_MIN_LENGTH = 2
- CHANNEL_NAME_MAX_LENGTH = 64
- CHANNEL_NAME_UI_MAX_LENGTH = 22
- CHANNEL_HEADER_MAX_RUNES = 1024
- CHANNEL_PURPOSE_MAX_RUNES = 250
- CHANNEL_CACHE_SIZE = 25000
-)
-
-type Channel struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- TeamId string `json:"team_id"`
- Type string `json:"type"`
- DisplayName string `json:"display_name"`
- Name string `json:"name"`
- Header string `json:"header"`
- Purpose string `json:"purpose"`
- LastPostAt int64 `json:"last_post_at"`
- TotalMsgCount int64 `json:"total_msg_count"`
- ExtraUpdateAt int64 `json:"extra_update_at"`
- CreatorId string `json:"creator_id"`
-}
-
-type ChannelPatch struct {
- DisplayName *string `json:"display_name"`
- Name *string `json:"name"`
- Header *string `json:"header"`
- Purpose *string `json:"purpose"`
-}
-
-func (o *Channel) DeepCopy() *Channel {
- copy := *o
- return &copy
-}
-
-func (o *Channel) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *ChannelPatch) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelFromJson(data io.Reader) *Channel {
- decoder := json.NewDecoder(data)
- var o Channel
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func ChannelPatchFromJson(data io.Reader) *ChannelPatch {
- decoder := json.NewDecoder(data)
- var o ChannelPatch
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *Channel) Etag() string {
- return Etag(o.Id, o.UpdateAt)
-}
-
-func (o *Channel) StatsEtag() string {
- return Etag(o.Id, o.ExtraUpdateAt)
-}
-
-func (o *Channel) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.DisplayName) > CHANNEL_DISPLAY_NAME_MAX_RUNES {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.display_name.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if !IsValidChannelIdentifier(o.Name) {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.2_or_more.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if !(o.Type == CHANNEL_OPEN || o.Type == CHANNEL_PRIVATE || o.Type == CHANNEL_DIRECT || o.Type == CHANNEL_GROUP) {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.type.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.Header) > CHANNEL_HEADER_MAX_RUNES {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.header.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.Purpose) > CHANNEL_PURPOSE_MAX_RUNES {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.purpose.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.CreatorId) > 26 {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.creator_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *Channel) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- o.CreateAt = GetMillis()
- o.UpdateAt = o.CreateAt
- o.ExtraUpdateAt = o.CreateAt
-}
-
-func (o *Channel) PreUpdate() {
- o.UpdateAt = GetMillis()
-}
-
-func (o *Channel) ExtraUpdated() {
- o.ExtraUpdateAt = GetMillis()
-}
-
-func (o *Channel) IsGroupOrDirect() bool {
- return o.Type == CHANNEL_DIRECT || o.Type == CHANNEL_GROUP
-}
-
-func (o *Channel) Patch(patch *ChannelPatch) {
- if patch.DisplayName != nil {
- o.DisplayName = *patch.DisplayName
- }
-
- if patch.Name != nil {
- o.Name = *patch.Name
- }
-
- if patch.Header != nil {
- o.Header = *patch.Header
- }
-
- if patch.Purpose != nil {
- o.Purpose = *patch.Purpose
- }
-}
-
-func GetDMNameFromIds(userId1, userId2 string) string {
- if userId1 > userId2 {
- return userId2 + "__" + userId1
- } else {
- return userId1 + "__" + userId2
- }
-}
-
-func GetGroupDisplayNameFromUsers(users []*User, truncate bool) string {
- usernames := make([]string, len(users))
- for index, user := range users {
- usernames[index] = user.Username
- }
-
- sort.Strings(usernames)
-
- name := strings.Join(usernames, ", ")
-
- if truncate && len(name) > CHANNEL_NAME_MAX_LENGTH {
- name = name[:CHANNEL_NAME_MAX_LENGTH]
- }
-
- return name
-}
-
-func GetGroupNameFromUserIds(userIds []string) string {
- sort.Strings(userIds)
-
- h := sha1.New()
- for _, id := range userIds {
- io.WriteString(h, id)
- }
-
- return hex.EncodeToString(h.Sum(nil))
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_count.go b/vendor/github.com/mattermost/platform/model/channel_count.go
deleted file mode 100644
index aecb0c71..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_count.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "crypto/md5"
- "encoding/json"
- "fmt"
- "io"
- "sort"
- "strconv"
-)
-
-type ChannelCounts struct {
- Counts map[string]int64 `json:"counts"`
- UpdateTimes map[string]int64 `json:"update_times"`
-}
-
-func (o *ChannelCounts) Etag() string {
-
- ids := []string{}
- for id := range o.Counts {
- ids = append(ids, id)
- }
- sort.Strings(ids)
-
- str := ""
- for _, id := range ids {
- str += id + strconv.FormatInt(o.Counts[id], 10)
- }
-
- md5Counts := fmt.Sprintf("%x", md5.Sum([]byte(str)))
-
- var update int64 = 0
- for _, u := range o.UpdateTimes {
- if u > update {
- update = u
- }
- }
-
- return Etag(md5Counts, update)
-}
-
-func (o *ChannelCounts) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelCountsFromJson(data io.Reader) *ChannelCounts {
- decoder := json.NewDecoder(data)
- var o ChannelCounts
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_data.go b/vendor/github.com/mattermost/platform/model/channel_data.go
deleted file mode 100644
index 41b7eaa6..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_data.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ChannelData struct {
- Channel *Channel `json:"channel"`
- Member *ChannelMember `json:"member"`
-}
-
-func (o *ChannelData) Etag() string {
- var mt int64 = 0
- if o.Member != nil {
- mt = o.Member.LastUpdateAt
- }
-
- return Etag(o.Channel.Id, o.Channel.UpdateAt, o.Channel.LastPostAt, mt)
-}
-
-func (o *ChannelData) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelDataFromJson(data io.Reader) *ChannelData {
- decoder := json.NewDecoder(data)
- var o ChannelData
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_list.go b/vendor/github.com/mattermost/platform/model/channel_list.go
deleted file mode 100644
index d5a4ccb7..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_list.go
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ChannelList []*Channel
-
-func (o *ChannelList) ToJson() string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func (o *ChannelList) Etag() string {
-
- id := "0"
- var t int64 = 0
- var delta int64 = 0
-
- for _, v := range *o {
- if v.LastPostAt > t {
- t = v.LastPostAt
- id = v.Id
- }
-
- if v.UpdateAt > t {
- t = v.UpdateAt
- id = v.Id
- }
-
- }
-
- return Etag(id, t, delta, len(*o))
-}
-
-func ChannelListFromJson(data io.Reader) *ChannelList {
- decoder := json.NewDecoder(data)
- var o ChannelList
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func ChannelSliceFromJson(data io.Reader) []*Channel {
- decoder := json.NewDecoder(data)
- var o []*Channel
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_member.go b/vendor/github.com/mattermost/platform/model/channel_member.go
deleted file mode 100644
index e7ad8232..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_member.go
+++ /dev/null
@@ -1,171 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "strings"
-)
-
-const (
- CHANNEL_NOTIFY_DEFAULT = "default"
- CHANNEL_NOTIFY_ALL = "all"
- CHANNEL_NOTIFY_MENTION = "mention"
- CHANNEL_NOTIFY_NONE = "none"
- CHANNEL_MARK_UNREAD_ALL = "all"
- CHANNEL_MARK_UNREAD_MENTION = "mention"
-)
-
-type ChannelUnread struct {
- TeamId string `json:"team_id"`
- ChannelId string `json:"channel_id"`
- MsgCount int64 `json:"msg_count"`
- MentionCount int64 `json:"mention_count"`
- NotifyProps StringMap `json:"-"`
-}
-
-type ChannelMember struct {
- ChannelId string `json:"channel_id"`
- UserId string `json:"user_id"`
- Roles string `json:"roles"`
- LastViewedAt int64 `json:"last_viewed_at"`
- MsgCount int64 `json:"msg_count"`
- MentionCount int64 `json:"mention_count"`
- NotifyProps StringMap `json:"notify_props"`
- LastUpdateAt int64 `json:"last_update_at"`
-}
-
-type ChannelMembers []ChannelMember
-
-func (o *ChannelMembers) ToJson() string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func (o *ChannelUnread) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelMembersFromJson(data io.Reader) *ChannelMembers {
- decoder := json.NewDecoder(data)
- var o ChannelMembers
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func ChannelUnreadFromJson(data io.Reader) *ChannelUnread {
- decoder := json.NewDecoder(data)
- var o ChannelUnread
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *ChannelMember) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelMemberFromJson(data io.Reader) *ChannelMember {
- decoder := json.NewDecoder(data)
- var o ChannelMember
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *ChannelMember) IsValid() *AppError {
-
- if len(o.ChannelId) != 26 {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.UserId) != 26 {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- notifyLevel := o.NotifyProps[DESKTOP_NOTIFY_PROP]
- if len(notifyLevel) > 20 || !IsChannelNotifyLevelValid(notifyLevel) {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.notify_level.app_error", nil, "notify_level="+notifyLevel, http.StatusBadRequest)
- }
-
- markUnreadLevel := o.NotifyProps[MARK_UNREAD_NOTIFY_PROP]
- if len(markUnreadLevel) > 20 || !IsChannelMarkUnreadLevelValid(markUnreadLevel) {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.unread_level.app_error", nil, "mark_unread_level="+markUnreadLevel, http.StatusBadRequest)
- }
-
- if pushLevel, ok := o.NotifyProps[PUSH_NOTIFY_PROP]; ok {
- if len(pushLevel) > 20 || !IsChannelNotifyLevelValid(pushLevel) {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.push_level.app_error", nil, "push_notification_level="+pushLevel, http.StatusBadRequest)
- }
- }
-
- if sendEmail, ok := o.NotifyProps[EMAIL_NOTIFY_PROP]; ok {
- if len(sendEmail) > 20 || !IsSendEmailValid(sendEmail) {
- return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.email_value.app_error", nil, "push_notification_level="+sendEmail, http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-func (o *ChannelMember) PreSave() {
- o.LastUpdateAt = GetMillis()
-}
-
-func (o *ChannelMember) PreUpdate() {
- o.LastUpdateAt = GetMillis()
-}
-
-func (o *ChannelMember) GetRoles() []string {
- return strings.Fields(o.Roles)
-}
-
-func IsChannelNotifyLevelValid(notifyLevel string) bool {
- return notifyLevel == CHANNEL_NOTIFY_DEFAULT ||
- notifyLevel == CHANNEL_NOTIFY_ALL ||
- notifyLevel == CHANNEL_NOTIFY_MENTION ||
- notifyLevel == CHANNEL_NOTIFY_NONE
-}
-
-func IsChannelMarkUnreadLevelValid(markUnreadLevel string) bool {
- return markUnreadLevel == CHANNEL_MARK_UNREAD_ALL || markUnreadLevel == CHANNEL_MARK_UNREAD_MENTION
-}
-
-func IsSendEmailValid(sendEmail string) bool {
- return sendEmail == CHANNEL_NOTIFY_DEFAULT || sendEmail == "true" || sendEmail == "false"
-}
-
-func GetDefaultChannelNotifyProps() StringMap {
- return StringMap{
- DESKTOP_NOTIFY_PROP: CHANNEL_NOTIFY_DEFAULT,
- MARK_UNREAD_NOTIFY_PROP: CHANNEL_MARK_UNREAD_ALL,
- PUSH_NOTIFY_PROP: CHANNEL_NOTIFY_DEFAULT,
- EMAIL_NOTIFY_PROP: CHANNEL_NOTIFY_DEFAULT,
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_member_history.go b/vendor/github.com/mattermost/platform/model/channel_member_history.go
deleted file mode 100644
index bc71b580..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_member_history.go
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-type ChannelMemberHistory struct {
- ChannelId string
- UserId string
- UserEmail string `db:"Email"`
- JoinTime int64
- LeaveTime *int64
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_search.go b/vendor/github.com/mattermost/platform/model/channel_search.go
deleted file mode 100644
index d915c164..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_search.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ChannelSearch struct {
- Term string `json:"term"`
-}
-
-// ToJson convert a Channel to a json string
-func (c *ChannelSearch) ToJson() string {
- b, err := json.Marshal(c)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// ChannelSearchFromJson will decode the input and return a Channel
-func ChannelSearchFromJson(data io.Reader) *ChannelSearch {
- decoder := json.NewDecoder(data)
- var cs ChannelSearch
- err := decoder.Decode(&cs)
- if err == nil {
- return &cs
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_stats.go b/vendor/github.com/mattermost/platform/model/channel_stats.go
deleted file mode 100644
index 758aa2b1..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_stats.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ChannelStats struct {
- ChannelId string `json:"channel_id"`
- MemberCount int64 `json:"member_count"`
-}
-
-func (o *ChannelStats) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelStatsFromJson(data io.Reader) *ChannelStats {
- decoder := json.NewDecoder(data)
- var o ChannelStats
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/channel_view.go b/vendor/github.com/mattermost/platform/model/channel_view.go
deleted file mode 100644
index e7b1de30..00000000
--- a/vendor/github.com/mattermost/platform/model/channel_view.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ChannelView struct {
- ChannelId string `json:"channel_id"`
- PrevChannelId string `json:"prev_channel_id"`
-}
-
-func (o *ChannelView) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelViewFromJson(data io.Reader) *ChannelView {
- decoder := json.NewDecoder(data)
- var o ChannelView
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-type ChannelViewResponse struct {
- Status string `json:"status"`
- LastViewedAtTimes map[string]int64 `json:"last_viewed_at_times"`
-}
-
-func (o *ChannelViewResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ChannelViewResponseFromJson(data io.Reader) *ChannelViewResponse {
- decoder := json.NewDecoder(data)
- var o ChannelViewResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/client.go b/vendor/github.com/mattermost/platform/model/client.go
deleted file mode 100644
index ef890b59..00000000
--- a/vendor/github.com/mattermost/platform/model/client.go
+++ /dev/null
@@ -1,2379 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "mime/multipart"
- "net/http"
- "net/url"
- "strconv"
- "strings"
- "time"
-
- l4g "github.com/alecthomas/log4go"
-)
-
-var UsedApiV3 *int32 = new(int32)
-
-const (
- HEADER_REQUEST_ID = "X-Request-ID"
- HEADER_VERSION_ID = "X-Version-ID"
- HEADER_CLUSTER_ID = "X-Cluster-ID"
- HEADER_ETAG_SERVER = "ETag"
- HEADER_ETAG_CLIENT = "If-None-Match"
- HEADER_FORWARDED = "X-Forwarded-For"
- HEADER_REAL_IP = "X-Real-IP"
- HEADER_FORWARDED_PROTO = "X-Forwarded-Proto"
- HEADER_TOKEN = "token"
- HEADER_BEARER = "BEARER"
- HEADER_AUTH = "Authorization"
- HEADER_REQUESTED_WITH = "X-Requested-With"
- HEADER_REQUESTED_WITH_XML = "XMLHttpRequest"
- STATUS = "status"
- STATUS_OK = "OK"
- STATUS_FAIL = "FAIL"
- STATUS_REMOVE = "REMOVE"
-
- CLIENT_DIR = "client"
-
- API_URL_SUFFIX_V1 = "/api/v1"
- API_URL_SUFFIX_V3 = "/api/v3"
- API_URL_SUFFIX_V4 = "/api/v4"
- API_URL_SUFFIX = API_URL_SUFFIX_V4
-)
-
-type Result struct {
- RequestId string
- Etag string
- Data interface{}
-}
-
-type ResponseMetadata struct {
- StatusCode int
- Error *AppError
- RequestId string
- Etag string
-}
-
-type Client struct {
- Url string // The location of the server like "http://localhost:8065"
- ApiUrl string // The api location of the server like "http://localhost:8065/api/v3"
- HttpClient *http.Client // The http client
- AuthToken string
- AuthType string
- TeamId string
- RequestId string
- Etag string
- ServerVersion string
-}
-
-// NewClient constructs a new client with convienence methods for talking to
-// the server.
-func NewClient(url string) *Client {
- return &Client{url, url + API_URL_SUFFIX_V3, &http.Client{}, "", "", "", "", "", ""}
-}
-
-func closeBody(r *http.Response) {
- if r.Body != nil {
- ioutil.ReadAll(r.Body)
- r.Body.Close()
- }
-}
-
-func (c *Client) SetOAuthToken(token string) {
- c.AuthToken = token
- c.AuthType = HEADER_TOKEN
-}
-
-func (c *Client) ClearOAuthToken() {
- c.AuthToken = ""
- c.AuthType = HEADER_BEARER
-}
-
-func (c *Client) SetTeamId(teamId string) {
- c.TeamId = teamId
-}
-
-func (c *Client) GetTeamId() string {
- if len(c.TeamId) == 0 {
- println(`You are trying to use a route that requires a team_id,
- but you have not called SetTeamId() in client.go`)
- }
-
- return c.TeamId
-}
-
-func (c *Client) ClearTeamId() {
- c.TeamId = ""
-}
-
-func (c *Client) GetTeamRoute() string {
- return fmt.Sprintf("/teams/%v", c.GetTeamId())
-}
-
-func (c *Client) GetChannelRoute(channelId string) string {
- return fmt.Sprintf("/teams/%v/channels/%v", c.GetTeamId(), channelId)
-}
-
-func (c *Client) GetUserRequiredRoute(userId string) string {
- return fmt.Sprintf("/users/%v", userId)
-}
-
-func (c *Client) GetChannelNameRoute(channelName string) string {
- return fmt.Sprintf("/teams/%v/channels/name/%v", c.GetTeamId(), channelName)
-}
-
-func (c *Client) GetEmojiRoute() string {
- return "/emoji"
-}
-
-func (c *Client) GetGeneralRoute() string {
- return "/general"
-}
-
-func (c *Client) GetFileRoute(fileId string) string {
- return fmt.Sprintf("/files/%v", fileId)
-}
-
-func (c *Client) DoPost(url, data, contentType string) (*http.Response, *AppError) {
- rq, _ := http.NewRequest("POST", c.Url+url, strings.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode >= 300 {
- defer closeBody(rp)
- return nil, AppErrorFromJson(rp.Body)
- } else {
- return rp, nil
- }
-}
-
-func (c *Client) DoApiPost(url string, data string) (*http.Response, *AppError) {
- rq, _ := http.NewRequest("POST", c.ApiUrl+url, strings.NewReader(data))
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode >= 300 {
- defer closeBody(rp)
- return nil, AppErrorFromJson(rp.Body)
- } else {
- return rp, nil
- }
-}
-
-func (c *Client) DoApiGet(url string, data string, etag string) (*http.Response, *AppError) {
- rq, _ := http.NewRequest("GET", c.ApiUrl+url, strings.NewReader(data))
- rq.Close = true
-
- if len(etag) > 0 {
- rq.Header.Set(HEADER_ETAG_CLIENT, etag)
- }
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode == 304 {
- return rp, nil
- } else if rp.StatusCode >= 300 {
- defer closeBody(rp)
- return rp, AppErrorFromJson(rp.Body)
- } else {
- return rp, nil
- }
-}
-
-func getCookie(name string, resp *http.Response) *http.Cookie {
- for _, cookie := range resp.Cookies() {
- if cookie.Name == name {
- return cookie
- }
- }
-
- return nil
-}
-
-// Must is a convenience function used for testing.
-func (c *Client) Must(result *Result, err *AppError) *Result {
- if err != nil {
- l4g.Close()
- time.Sleep(time.Second)
- panic(err)
- }
-
- return result
-}
-
-// MustGeneric is a convenience function used for testing.
-func (c *Client) MustGeneric(result interface{}, err *AppError) interface{} {
- if err != nil {
- l4g.Close()
- time.Sleep(time.Second)
- panic(err)
- }
-
- return result
-}
-
-// CheckStatusOK is a convenience function for checking the return of Web Service
-// call that return the a map of status=OK.
-func (c *Client) CheckStatusOK(r *http.Response) bool {
- m := MapFromJson(r.Body)
- defer closeBody(r)
-
- if m != nil && m[STATUS] == STATUS_OK {
- return true
- }
-
- return false
-}
-
-func (c *Client) fillInExtraProperties(r *http.Response) {
- c.RequestId = r.Header.Get(HEADER_REQUEST_ID)
- c.Etag = r.Header.Get(HEADER_ETAG_SERVER)
- c.ServerVersion = r.Header.Get(HEADER_VERSION_ID)
-}
-
-func (c *Client) clearExtraProperties() {
- c.RequestId = ""
- c.Etag = ""
- c.ServerVersion = ""
-}
-
-// General Routes Section
-
-// GetClientProperties returns properties needed by the client to show/hide
-// certian features. It returns a map of strings.
-func (c *Client) GetClientProperties() (map[string]string, *AppError) {
- c.clearExtraProperties()
- if r, err := c.DoApiGet(c.GetGeneralRoute()+"/client_props", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return MapFromJson(r.Body), nil
- }
-}
-
-// LogClient is a convenience Web Service call so clients can log messages into
-// the server-side logs. For example we typically log javascript error messages
-// into the server-side. It returns true if the logging was successful.
-func (c *Client) LogClient(message string) (bool, *AppError) {
- c.clearExtraProperties()
- m := make(map[string]string)
- m["level"] = "ERROR"
- m["message"] = message
-
- if r, err := c.DoApiPost(c.GetGeneralRoute()+"/log_client", MapToJson(m)); err != nil {
- return false, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return c.CheckStatusOK(r), nil
- }
-}
-
-// GetPing returns a map of strings with server time, server version, and node Id.
-// Systems that want to check on health status of the server should check the
-// url /api/v3/ping for a 200 status response.
-func (c *Client) GetPing() (map[string]string, *AppError) {
- c.clearExtraProperties()
- if r, err := c.DoApiGet(c.GetGeneralRoute()+"/ping", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return MapFromJson(r.Body), nil
- }
-}
-
-// Team Routes Section
-
-// CreateTeam creates a team based on the provided Team struct. On success it returns
-// the Team struct with the Id, CreateAt and other server-decided fields populated.
-func (c *Client) CreateTeam(team *Team) (*Result, *AppError) {
- if r, err := c.DoApiPost("/teams/create", team.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
- }
-}
-
-// GetAllTeams returns a map of all teams using team ids as the key.
-func (c *Client) GetAllTeams() (*Result, *AppError) {
- if r, err := c.DoApiGet("/teams/all", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMapFromJson(r.Body)}, nil
- }
-}
-
-// GetAllTeamListings returns a map of all teams that are available to join
-// using team ids as the key. Must be authenticated.
-func (c *Client) GetAllTeamListings() (*Result, *AppError) {
- if r, err := c.DoApiGet("/teams/all_team_listings", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMapFromJson(r.Body)}, nil
- }
-}
-
-// FindTeamByName returns the strings "true" or "false" depending on if a team
-// with the provided name was found.
-func (c *Client) FindTeamByName(name string) (*Result, *AppError) {
- m := make(map[string]string)
- m["name"] = name
- if r, err := c.DoApiPost("/teams/find_team_by_name", MapToJson(m)); err != nil {
- return nil, err
- } else {
- val := false
- if body, _ := ioutil.ReadAll(r.Body); string(body) == "true" {
- val = true
- }
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), val}, nil
- }
-}
-
-// Adds a user directly to the team without sending an invite.
-// The teamId and userId are required. You must be a valid member of the team and/or
-// have the correct role to add new users to the team. Returns a map of user_id=userId
-// if successful, otherwise returns an AppError.
-func (c *Client) AddUserToTeam(teamId string, userId string) (*Result, *AppError) {
- if len(teamId) == 0 {
- teamId = c.GetTeamId()
- }
-
- data := make(map[string]string)
- data["user_id"] = userId
- if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/add_user_to_team", 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
- }
-}
-
-// AddUserToTeamFromInvite adds a user to a team based off data provided in an invite link.
-// Either hash and dataToHash are required or inviteId is required.
-func (c *Client) AddUserToTeamFromInvite(hash, dataToHash, inviteId string) (*Result, *AppError) {
- data := make(map[string]string)
- data["hash"] = hash
- data["data"] = dataToHash
- data["invite_id"] = inviteId
- if r, err := c.DoApiPost("/teams/add_user_to_team_from_invite", 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), TeamFromJson(r.Body)}, nil
- }
-}
-
-// Removes a user directly from the team.
-// The teamId and userId are required. You must be a valid member of the team and/or
-// have the correct role to remove a user from the team. Returns a map of user_id=userId
-// if successful, otherwise returns an AppError.
-func (c *Client) RemoveUserFromTeam(teamId string, userId string) (*Result, *AppError) {
- if len(teamId) == 0 {
- teamId = c.GetTeamId()
- }
-
- data := make(map[string]string)
- data["user_id"] = userId
- if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v", teamId)+"/remove_user_from_team", 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) InviteMembers(invites *Invites) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/invite_members", invites.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), InvitesFromJson(r.Body)}, nil
- }
-}
-
-// UpdateTeam updates a team based on the changes in the provided team struct. On success
-// it returns a sanitized version of the updated team. Must be authenticated as a team admin
-// for that team or a system admin.
-func (c *Client) UpdateTeam(team *Team) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/update", team.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
- }
-}
-
-// User Routes Section
-
-// CreateUser creates a user in the system based on the provided user struct.
-func (c *Client) CreateUser(user *User, hash string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/create", user.ToJson()); 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
- }
-}
-
-// CreateUserWithInvite creates a user based on the provided user struct. Either the hash and
-// data strings or the inviteId is required from the invite.
-func (c *Client) CreateUserWithInvite(user *User, hash string, data string, inviteId string) (*Result, *AppError) {
-
- url := "/users/create?d=" + url.QueryEscape(data) + "&h=" + url.QueryEscape(hash) + "&iid=" + url.QueryEscape(inviteId)
-
- if r, err := c.DoApiPost(url, user.ToJson()); 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
- }
-}
-
-func (c *Client) CreateUserFromSignup(user *User, data string, hash string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/create?d="+url.QueryEscape(data)+"&h="+hash, user.ToJson()); 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
- }
-}
-
-// GetUser returns a user based on a provided user id string. Must be authenticated.
-func (c *Client) GetUser(id string, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/"+id+"/get", "", 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
- }
-}
-
-// 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
- }
-}
-
-// getByEmail returns a user based on a provided username string. Must be authenticated.
-func (c *Client) GetByEmail(email string, etag string) (*User, *ResponseMetadata) {
- if r, err := c.DoApiGet(fmt.Sprintf("/users/email/%v", email), "", etag); err != nil {
- return nil, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body),
- &ResponseMetadata{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- }
- }
-}
-
-// GetMe returns the current user.
-func (c *Client) GetMe(etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/me", "", 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
- }
-}
-
-// GetProfiles returns a map of users using user id as the key. Must be authenticated.
-func (c *Client) GetProfiles(offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/users/%v/%v", offset, limit), "", etag); 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
- }
-}
-
-// GetProfilesInTeam returns a map of users for a team using user id as the key. Must
-// be authenticated.
-func (c *Client) GetProfilesInTeam(teamId string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/teams/%v/users/%v/%v", teamId, offset, limit), "", etag); 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
- }
-}
-
-// GetProfilesInChannel returns a map of users for a channel using user id as the key. Must
-// be authenticated.
-func (c *Client) GetProfilesInChannel(channelId string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf(c.GetChannelRoute(channelId)+"/users/%v/%v", offset, limit), "", etag); 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
- }
-}
-
-// GetProfilesNotInChannel returns a map of users not in a channel but on the team using user id as the key. Must
-// be authenticated.
-func (c *Client) GetProfilesNotInChannel(channelId string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf(c.GetChannelRoute(channelId)+"/users/not_in_channel/%v/%v", offset, limit), "", etag); 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
- }
-}
-
-// GetProfilesByIds returns a map of users based on the user ids provided. Must
-// be authenticated.
-func (c *Client) GetProfilesByIds(userIds []string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/ids", ArrayToJson(userIds)); 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
- }
-}
-
-// SearchUsers returns a list of users that have a username matching or similar to the search term. Must
-// be authenticated.
-func (c *Client) SearchUsers(params UserSearch) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/search", params.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserListFromJson(r.Body)}, nil
- }
-}
-
-// AutocompleteUsersInChannel returns two lists for autocompletion of users in a channel. The first list "in_channel",
-// specifies users in the channel. The second list "out_of_channel" specifies users outside of the
-// channel. Term, the string to search against, is required, channel id is also required. Must be authenticated.
-func (c *Client) AutocompleteUsersInChannel(term string, channelId string) (*Result, *AppError) {
- url := fmt.Sprintf("%s/users/autocomplete?term=%s", c.GetChannelRoute(channelId), url.QueryEscape(term))
- if r, err := c.DoApiGet(url, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserAutocompleteInChannelFromJson(r.Body)}, nil
- }
-}
-
-// AutocompleteUsersInTeam returns a list for autocompletion of users in a team. The list "in_team" specifies
-// the users in the team that match the provided term, matching against username, full name and
-// nickname. Must be authenticated.
-func (c *Client) AutocompleteUsersInTeam(term string) (*Result, *AppError) {
- url := fmt.Sprintf("%s/users/autocomplete?term=%s", c.GetTeamRoute(), url.QueryEscape(term))
- if r, err := c.DoApiGet(url, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserAutocompleteInTeamFromJson(r.Body)}, nil
- }
-}
-
-// AutocompleteUsers returns a list for autocompletion of users on the system that match the provided term,
-// matching against username, full name and nickname. Must be authenticated.
-func (c *Client) AutocompleteUsers(term string) (*Result, *AppError) {
- url := fmt.Sprintf("/users/autocomplete?term=%s", url.QueryEscape(term))
- if r, err := c.DoApiGet(url, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserListFromJson(r.Body)}, nil
- }
-}
-
-// LoginById authenticates a user by user id and password.
-func (c *Client) LoginById(id string, password string) (*Result, *AppError) {
- m := make(map[string]string)
- m["id"] = id
- m["password"] = password
- return c.login(m)
-}
-
-// Login authenticates a user by login id, which can be username, email or some sort
-// of SSO identifier based on configuration, and a password.
-func (c *Client) Login(loginId string, password string) (*Result, *AppError) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- return c.login(m)
-}
-
-// LoginByLdap authenticates a user by LDAP id and password.
-func (c *Client) LoginByLdap(loginId string, password string) (*Result, *AppError) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- m["ldap_only"] = "true"
- return c.login(m)
-}
-
-// LoginWithDevice authenticates a user by login id (username, email or some sort
-// of SSO identifier based on configuration), password and attaches a device id to
-// the session.
-func (c *Client) LoginWithDevice(loginId string, password string, deviceId string) (*Result, *AppError) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- m["device_id"] = deviceId
- return c.login(m)
-}
-
-func (c *Client) login(m map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/login", MapToJson(m)); err != nil {
- return nil, err
- } else {
- c.AuthToken = r.Header.Get(HEADER_TOKEN)
- c.AuthType = HEADER_BEARER
- sessionToken := getCookie(SESSION_COOKIE_TOKEN, r)
-
- if c.AuthToken != sessionToken.Value {
- NewAppError("/users/login", "model.client.login.app_error", nil, "", 0)
- }
-
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), UserFromJson(r.Body)}, nil
- }
-}
-
-// Logout terminates the current user's session.
-func (c *Client) Logout() (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/logout", ""); err != nil {
- return nil, err
- } else {
- c.AuthToken = ""
- c.AuthType = HEADER_BEARER
- c.TeamId = ""
-
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
- }
-}
-
-// CheckMfa returns a map with key "mfa_required" with the string value "true" or "false",
-// indicating whether MFA is required to log the user in, based on a provided login id
-// (username, email or some sort of SSO identifier based on configuration).
-func (c *Client) CheckMfa(loginId string) (*Result, *AppError) {
- m := make(map[string]string)
- m["login_id"] = loginId
-
- if r, err := c.DoApiPost("/users/mfa", MapToJson(m)); 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
- }
-}
-
-// GenerateMfaSecret returns a QR code image containing the secret, to be scanned
-// by a multi-factor authentication mobile application. It also returns the secret
-// for manual entry. Must be authenticated.
-func (c *Client) GenerateMfaSecret() (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/generate_mfa_secret", "", ""); 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
- }
-}
-
-// UpdateMfa activates multi-factor authenticates for the current user if activate
-// is true and a valid token is provided. If activate is false, then token is not
-// required and multi-factor authentication is disabled for the current user.
-func (c *Client) UpdateMfa(activate bool, token string) (*Result, *AppError) {
- m := make(map[string]interface{})
- m["activate"] = activate
- m["token"] = token
-
- if r, err := c.DoApiPost("/users/update_mfa", StringInterfaceToJson(m)); 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) AdminResetMfa(userId string) (*Result, *AppError) {
- m := make(map[string]string)
- m["user_id"] = userId
-
- if r, err := c.DoApiPost("/admin/reset_mfa", MapToJson(m)); 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) RevokeSession(sessionAltId string) (*Result, *AppError) {
- m := make(map[string]string)
- m["id"] = sessionAltId
-
- if r, err := c.DoApiPost("/users/revoke_session", MapToJson(m)); 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) GetSessions(id string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/"+id+"/sessions", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), SessionsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) EmailToOAuth(m map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/claim/email_to_oauth", MapToJson(m)); 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) OAuthToEmail(m map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/claim/oauth_to_email", MapToJson(m)); 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) LDAPToEmail(m map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/claim/ldap_to_email", MapToJson(m)); 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) EmailToLDAP(m map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/claim/ldap_to_email", MapToJson(m)); 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) Command(channelId string, command string) (*Result, *AppError) {
- args := &CommandArgs{ChannelId: channelId, Command: command}
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/commands/execute", args.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- 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.DoApiGet(c.GetTeamRoute()+"/commands/list", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), CommandListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) ListTeamCommands() (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/commands/list_team_commands", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- 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(c.GetTeamRoute()+"/commands/create", 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) 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
- } 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) DeleteCommand(data map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/commands/delete", 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) GetAudits(id string, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/"+id+"/audits", "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), AuditsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetLogs() (*Result, *AppError) {
- if r, err := c.DoApiGet("/admin/logs", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ArrayFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetClusterStatus() ([]*ClusterInfo, *AppError) {
- if r, err := c.DoApiGet("/admin/cluster_status", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return ClusterInfosFromJson(r.Body), nil
- }
-}
-
-// 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
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), AuditsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetConfig() (*Result, *AppError) {
- if r, err := c.DoApiGet("/admin/config", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ConfigFromJson(r.Body)}, nil
- }
-}
-
-// ReloadConfig will reload the config.json file from disk. Properties
-// requiring a server restart will still need a server restart. You must
-// have the system admin role to call this method. It will return status=OK
-// if it's successfully reloaded the config file, otherwise check the returned error.
-func (c *Client) ReloadConfig() (bool, *AppError) {
- c.clearExtraProperties()
- if r, err := c.DoApiGet("/admin/reload_config", "", ""); err != nil {
- return false, err
- } else {
- c.fillInExtraProperties(r)
- return c.CheckStatusOK(r), nil
- }
-}
-
-func (c *Client) InvalidateAllCaches() (bool, *AppError) {
- c.clearExtraProperties()
- if r, err := c.DoApiGet("/admin/invalidate_all_caches", "", ""); err != nil {
- return false, err
- } else {
- c.fillInExtraProperties(r)
- return c.CheckStatusOK(r), nil
- }
-}
-
-func (c *Client) SaveConfig(config *Config) (*Result, *AppError) {
- if r, err := c.DoApiPost("/admin/save_config", 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
- }
-}
-
-// RecycleDatabaseConnection will attempt to recycle the database connections.
-// You must have the system admin role to call this method. It will return status=OK
-// if it's successfully recycled the connections, otherwise check the returned error.
-func (c *Client) RecycleDatabaseConnection() (bool, *AppError) {
- c.clearExtraProperties()
- if r, err := c.DoApiGet("/admin/recycle_db_conn", "", ""); err != nil {
- return false, err
- } else {
- c.fillInExtraProperties(r)
- return c.CheckStatusOK(r), nil
- }
-}
-
-func (c *Client) TestEmail(config *Config) (*Result, *AppError) {
- if r, err := c.DoApiPost("/admin/test_email", 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
- }
-}
-
-// 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
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), CompliancesFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) SaveComplianceReport(job *Compliance) (*Result, *AppError) {
- if r, err := c.DoApiPost("/admin/save_compliance_report", job.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ComplianceFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) DownloadComplianceReport(id string) (*Result, *AppError) {
- var rq *http.Request
- rq, _ = http.NewRequest("GET", c.ApiUrl+"/admin/download_compliance_report/"+id, nil)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError("/admin/download_compliance_report", "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode >= 300 {
- defer rp.Body.Close()
- return nil, AppErrorFromJson(rp.Body)
- } else {
- defer closeBody(rp)
- return &Result{rp.Header.Get(HEADER_REQUEST_ID),
- rp.Header.Get(HEADER_ETAG_SERVER), rp.Body}, nil
- }
-}
-
-func (c *Client) GetTeamAnalytics(teamId, name string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/admin/analytics/"+teamId+"/"+name, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), AnalyticsRowsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetSystemAnalytics(name string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/admin/analytics/"+name, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), AnalyticsRowsFromJson(r.Body)}, nil
- }
-}
-
-// Initiate immediate synchronization of LDAP users.
-// The synchronization will be performed asynchronously and this function will
-// always return OK unless you don't have permissions.
-// You must be the system administrator to use this function.
-func (c *Client) LdapSyncNow() (*Result, *AppError) {
- if r, err := c.DoApiPost("/admin/ldap_sync_now", ""); 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) CreateChannel(channel *Channel) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/create", channel.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) CreateDirectChannel(userId string) (*Result, *AppError) {
- data := make(map[string]string)
- data["user_id"] = userId
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/create_direct", 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), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) CreateGroupChannel(userIds []string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/create_group", ArrayToJson(userIds)); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateChannel(channel *Channel) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/update", channel.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateChannelHeader(data map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/update_header", 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), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateChannelPurpose(data map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/update_purpose", 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), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateNotifyProps(data map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/update_notify_props", 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) GetMyChannelMembers() (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/channels/members", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelMembersFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetChannel(id, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(id)+"/", "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelDataFromJson(r.Body)}, nil
- }
-}
-
-// GetMoreChannelsPage will return a page of open channels the user is not in based on
-// the provided offset and limit. Must be authenticated.
-func (c *Client) GetMoreChannelsPage(offset int, limit int) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf(c.GetTeamRoute()+"/channels/more/%v/%v", offset, limit), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
- }
-}
-
-// SearchMoreChannels will return a list of open channels the user is not in, that matches
-// the search criteria provided. Must be authenticated.
-func (c *Client) SearchMoreChannels(channelSearch ChannelSearch) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/more/search", channelSearch.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
- }
-}
-
-// AutocompleteChannels will return a list of open channels that match the provided
-// string. Must be authenticated.
-func (c *Client) AutocompleteChannels(term string) (*Result, *AppError) {
- url := fmt.Sprintf("%s/channels/autocomplete?term=%s", c.GetTeamRoute(), url.QueryEscape(term))
- if r, err := c.DoApiGet(url, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetChannelCounts(etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/channels/counts", "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelCountsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetChannels(etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/channels/", "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetChannelByName(channelName string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelNameRoute(channelName), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) JoinChannel(id string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/join", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
- }
-}
-
-func (c *Client) JoinChannelByName(name string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelNameRoute(name)+"/join", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
- }
-}
-
-func (c *Client) LeaveChannel(id string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/leave", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
- }
-}
-
-func (c *Client) DeleteChannel(id string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/delete", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
- }
-}
-
-func (c *Client) AddChannelMember(id, user_id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["user_id"] = user_id
- if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/add", 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), nil}, nil
- }
-}
-
-func (c *Client) RemoveChannelMember(id, user_id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["user_id"] = user_id
- if r, err := c.DoApiPost(c.GetChannelRoute(id)+"/remove", 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), nil}, nil
- }
-}
-
-// ViewChannel performs all the actions related to viewing a channel. This includes marking
-// the channel and the previous one as read, and marking the channel as being actively viewed.
-// ChannelId is required but may be blank to indicate no channel is being viewed.
-// PrevChannelId is optional, populate to indicate a channel switch occurred.
-func (c *Client) ViewChannel(params ChannelView) (bool, *ResponseMetadata) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/channels/view", params.ToJson()); err != nil {
- return false, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
- } else {
- return c.CheckStatusOK(r),
- &ResponseMetadata{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- }
- }
-}
-
-func (c *Client) GetChannelStats(id string, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(id)+"/stats", "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelStatsFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetChannelMember(channelId string, userId string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/members/"+userId, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelMemberFromJson(r.Body)}, nil
- }
-}
-
-// GetChannelMembersByIds will return channel member objects as an array based on the
-// channel id and a list of user ids provided. Must be authenticated.
-func (c *Client) GetChannelMembersByIds(channelId string, userIds []string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/members/ids", ArrayToJson(userIds)); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), ChannelMembersFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) CreatePost(post *Post) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(post.ChannelId)+"/posts/create", post.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdatePost(post *Post) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(post.ChannelId)+"/posts/update", post.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPosts(channelId string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/page/%v/%v", offset, limit), "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPostsSince(channelId string, time int64) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/since/%v", time), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPostsBefore(channelId string, postid string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/before/%v/%v", postid, offset, limit), "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPostsAfter(channelId string, postid string, offset int, limit int, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf(c.GetChannelRoute(channelId)+"/posts/%v/after/%v/%v", postid, offset, limit), "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPost(channelId string, postId string, etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/get", postId), "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-// GetPostById returns a post and any posts in the same thread by post id
-func (c *Client) GetPostById(postId string, etag string) (*PostList, *ResponseMetadata) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+fmt.Sprintf("/posts/%v", postId), "", etag); err != nil {
- return nil, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body),
- &ResponseMetadata{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- }
- }
-}
-
-// GetPermalink returns a post list, based on the provided channel and post ID.
-func (c *Client) GetPermalink(channelId string, postId string, etag string) (*PostList, *ResponseMetadata) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+fmt.Sprintf("/pltmp/%v", postId), "", etag); err != nil {
- return nil, &ResponseMetadata{StatusCode: r.StatusCode, Error: err}
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body),
- &ResponseMetadata{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- }
- }
-}
-
-func (c *Client) DeletePost(channelId string, postId string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/delete", postId), ""); 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) SearchPosts(terms string, isOrSearch bool) (*Result, *AppError) {
- data := map[string]interface{}{}
- data["terms"] = terms
- data["is_or_search"] = isOrSearch
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/posts/search", StringInterfaceToJson(data)); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-// GetFlaggedPosts will return a post list of posts that have been flagged by the user.
-// The page is set by the integer parameters offset and limit.
-func (c *Client) GetFlaggedPosts(offset int, limit int) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+fmt.Sprintf("/posts/flagged/%v/%v", offset, limit), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPinnedPosts(channelId string) (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/pinned", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UploadProfileFile(data []byte, contentType string) (*Result, *AppError) {
- return c.uploadFile(c.ApiUrl+"/users/newimage", data, contentType)
-}
-
-func (c *Client) UploadPostAttachment(data []byte, channelId string, filename string) (*FileUploadResponse, *AppError) {
- c.clearExtraProperties()
-
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("files", filename); err != nil {
- return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), 0)
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), 0)
- }
-
- if part, err := writer.CreateFormField("channel_id"); err != nil {
- return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), 0)
- } else if _, err = io.Copy(part, strings.NewReader(channelId)); err != nil {
- return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), 0)
- }
-
- if err := writer.Close(); err != nil {
- return nil, NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.writer.app_error", nil, err.Error(), 0)
- }
-
- if result, err := c.uploadFile(c.ApiUrl+c.GetTeamRoute()+"/files/upload", body.Bytes(), writer.FormDataContentType()); err != nil {
- return nil, err
- } else {
- return result.Data.(*FileUploadResponse), nil
- }
-}
-
-func (c *Client) uploadFile(url string, data []byte, contentType string) (*Result, *AppError) {
- rq, _ := http.NewRequest("POST", url, bytes.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode >= 300 {
- return nil, AppErrorFromJson(rp.Body)
- } else {
- defer closeBody(rp)
- return &Result{rp.Header.Get(HEADER_REQUEST_ID),
- rp.Header.Get(HEADER_ETAG_SERVER), FileUploadResponseFromJson(rp.Body)}, nil
- }
-}
-
-func (c *Client) GetFile(fileId string) (io.ReadCloser, *AppError) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/get", "", ""); err != nil {
- return nil, err
- } else {
- c.fillInExtraProperties(r)
- return r.Body, nil
- }
-}
-
-func (c *Client) GetFileThumbnail(fileId string) (io.ReadCloser, *AppError) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/get_thumbnail", "", ""); err != nil {
- return nil, err
- } else {
- c.fillInExtraProperties(r)
- return r.Body, nil
- }
-}
-
-func (c *Client) GetFilePreview(fileId string) (io.ReadCloser, *AppError) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/get_preview", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return r.Body, nil
- }
-}
-
-func (c *Client) GetFileInfo(fileId string) (*FileInfo, *AppError) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/get_info", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return FileInfoFromJson(r.Body), nil
- }
-}
-
-func (c *Client) GetPublicLink(fileId string) (string, *AppError) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/get_public_link", "", ""); err != nil {
- return "", err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return StringFromJson(r.Body), nil
- }
-}
-
-func (c *Client) UpdateUser(user *User) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/update", user.ToJson()); 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
- }
-}
-
-func (c *Client) UpdateUserRoles(userId string, roles string) (*Result, *AppError) {
- data := make(map[string]string)
- data["new_roles"] = roles
-
- if r, err := c.DoApiPost(c.GetUserRequiredRoute(userId)+"/update_roles", 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) UpdateTeamRoles(userId string, roles string) (*Result, *AppError) {
- data := make(map[string]string)
- data["new_roles"] = roles
- data["user_id"] = userId
-
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/update_member_roles", 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) AttachDeviceId(deviceId string) (*Result, *AppError) {
- data := make(map[string]string)
- data["device_id"] = deviceId
- if r, err := c.DoApiPost("/users/attach_device", 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), UserFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateActive(userId string, active bool) (*Result, *AppError) {
- data := make(map[string]string)
- data["user_id"] = userId
- data["active"] = strconv.FormatBool(active)
- if r, err := c.DoApiPost("/users/update_active", 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), UserFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateUserNotify(data map[string]string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/update_notify", 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), UserFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateUserPassword(userId, currentPassword, newPassword string) (*Result, *AppError) {
- data := make(map[string]string)
- data["current_password"] = currentPassword
- data["new_password"] = newPassword
- data["user_id"] = userId
-
- if r, err := c.DoApiPost("/users/newpassword", 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) SendPasswordReset(email string) (*Result, *AppError) {
- data := map[string]string{}
- data["email"] = email
- if r, err := c.DoApiPost("/users/send_password_reset", 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) ResetPassword(code, newPassword string) (*Result, *AppError) {
- data := map[string]string{}
- data["code"] = code
- data["new_password"] = newPassword
- if r, err := c.DoApiPost("/users/reset_password", 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) AdminResetPassword(userId, newPassword string) (*Result, *AppError) {
- data := map[string]string{}
- data["user_id"] = userId
- data["new_password"] = newPassword
- if r, err := c.DoApiPost("/admin/reset_password", 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
- }
-}
-
-// GetStatuses returns a map of string statuses using user id as the key
-func (c *Client) GetStatuses() (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/status", "", ""); 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
- }
-}
-
-// GetStatusesByIds returns a map of string statuses using user id as the key,
-// based on the provided user ids
-func (c *Client) GetStatusesByIds(userIds []string) (*Result, *AppError) {
- if r, err := c.DoApiPost("/users/status/ids", ArrayToJson(userIds)); 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
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
- }
-}
-
-// GetTeamMembers will return a page of team member objects as an array paged based on the
-// team id, offset and limit provided. Must be authenticated.
-func (c *Client) GetTeamMembers(teamId string, offset int, limit int) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/teams/%v/members/%v/%v", teamId, offset, limit), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMembersFromJson(r.Body)}, nil
- }
-}
-
-// GetMyTeamMembers will return an array with team member objects that the current user
-// is a member of. Must be authenticated.
-func (c *Client) GetMyTeamMembers() (*Result, *AppError) {
- if r, err := c.DoApiGet("/teams/members", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMembersFromJson(r.Body)}, nil
- }
-}
-
-// GetMyTeamsUnread will return an array with TeamUnread objects that contain the amount of
-// unread messages and mentions the current user has for the teams it belongs to.
-// An optional team ID can be set to exclude that team from the results. Must be authenticated.
-func (c *Client) GetMyTeamsUnread(teamId string) (*Result, *AppError) {
- endpoint := "/teams/unread"
-
- if teamId != "" {
- endpoint += fmt.Sprintf("?id=%s", url.QueryEscape(teamId))
- }
- if r, err := c.DoApiGet(endpoint, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamsUnreadFromJson(r.Body)}, nil
- }
-}
-
-// GetTeamMember will return a team member object based on the team id and user id provided.
-// Must be authenticated.
-func (c *Client) GetTeamMember(teamId string, userId string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/teams/%v/members/%v", teamId, userId), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMemberFromJson(r.Body)}, nil
- }
-}
-
-// GetTeamStats will return a team stats object containing the number of users on the team
-// based on the team id provided. Must be authenticated.
-func (c *Client) GetTeamStats(teamId string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/teams/%v/stats", teamId), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamStatsFromJson(r.Body)}, nil
- }
-}
-
-// GetTeamByName will return a team object based on the team name provided. Must be authenticated.
-func (c *Client) GetTeamByName(teamName string) (*Result, *AppError) {
- if r, err := c.DoApiGet(fmt.Sprintf("/teams/name/%v", teamName), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
- }
-}
-
-// GetTeamMembersByIds will return team member objects as an array based on the
-// team id and a list of user ids provided. Must be authenticated.
-func (c *Client) GetTeamMembersByIds(teamId string, userIds []string) (*Result, *AppError) {
- if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v/members/ids", teamId), ArrayToJson(userIds)); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), TeamMembersFromJson(r.Body)}, nil
- }
-}
-
-// RegisterApp creates a new OAuth2 app to be used with the OAuth2 Provider. On success
-// it returns the created app. Must be authenticated as a user.
-func (c *Client) RegisterApp(app *OAuthApp) (*Result, *AppError) {
- if r, err := c.DoApiPost("/oauth/register", app.ToJson()); 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
- }
-}
-
-// AllowOAuth allows a new session by an OAuth2 App. On success
-// it returns the url to be redirected back to the app which initiated the oauth2 flow.
-// Must be authenticated as a user.
-func (c *Client) AllowOAuth(rspType, clientId, redirect, scope, state string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/oauth/allow?response_type="+rspType+"&client_id="+clientId+"&redirect_uri="+url.QueryEscape(redirect)+"&scope="+scope+"&state="+url.QueryEscape(state), "", ""); 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
- }
-}
-
-// GetOAuthAppsByUser returns the OAuth2 Apps registered by the user. On success
-// it returns a list of OAuth2 Apps from the same user or all the registered apps if the user
-// is a System Administrator. Must be authenticated as a user.
-func (c *Client) GetOAuthAppsByUser() (*Result, *AppError) {
- if r, err := c.DoApiGet("/oauth/list", "", ""); 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
- }
-}
-
-// GetOAuthAppInfo lookup an OAuth2 App using the client_id. On success
-// it returns a Sanitized OAuth2 App. Must be authenticated as a user.
-func (c *Client) GetOAuthAppInfo(clientId string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/oauth/app/"+clientId, "", ""); 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
- }
-}
-
-// DeleteOAuthApp deletes an OAuth2 app, the app must be deleted by the same user who created it or
-// a System Administrator. On success returs Status OK. Must be authenticated as a user.
-func (c *Client) DeleteOAuthApp(id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["id"] = id
- if r, err := c.DoApiPost("/oauth/delete", 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
- }
-}
-
-// 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
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), AccessResponseFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) CreateIncomingWebhook(hook *IncomingWebhook) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/incoming/create", hook.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), IncomingWebhookFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateIncomingWebhook(hook *IncomingWebhook) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/incoming/update", hook.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), IncomingWebhookFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) PostToWebhook(id, payload string) (*Result, *AppError) {
- if r, err := c.DoPost("/hooks/"+id, payload, "application/x-www-form-urlencoded"); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), nil}, nil
- }
-}
-
-func (c *Client) DeleteIncomingWebhook(id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["id"] = id
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/incoming/delete", 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) ListIncomingWebhooks() (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/hooks/incoming/list", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), IncomingWebhookListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetAllPreferences() (*Result, *AppError) {
- if r, err := c.DoApiGet("/preferences/", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- preferences, _ := PreferencesFromJson(r.Body)
- return &Result{r.Header.Get(HEADER_REQUEST_ID), r.Header.Get(HEADER_ETAG_SERVER), preferences}, nil
- }
-}
-
-func (c *Client) SetPreferences(preferences *Preferences) (*Result, *AppError) {
- if r, err := c.DoApiPost("/preferences/save", preferences.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), preferences}, nil
- }
-}
-
-func (c *Client) GetPreference(category string, name string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/preferences/"+category+"/"+name, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID), r.Header.Get(HEADER_ETAG_SERVER), PreferenceFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) GetPreferenceCategory(category string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/preferences/"+category, "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- preferences, _ := PreferencesFromJson(r.Body)
- return &Result{r.Header.Get(HEADER_REQUEST_ID), r.Header.Get(HEADER_ETAG_SERVER), preferences}, nil
- }
-}
-
-// DeletePreferences deletes a list of preferences owned by the current user. If successful,
-// it will return status=ok. Otherwise, an error will be returned.
-func (c *Client) DeletePreferences(preferences *Preferences) (bool, *AppError) {
- if r, err := c.DoApiPost("/preferences/delete", preferences.ToJson()); err != nil {
- return false, err
- } else {
- return c.CheckStatusOK(r), nil
- }
-}
-
-func (c *Client) CreateOutgoingWebhook(hook *OutgoingWebhook) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/outgoing/create", hook.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), OutgoingWebhookFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UpdateOutgoingWebhook(hook *OutgoingWebhook) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/outgoing/update", hook.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), OutgoingWebhookFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) DeleteOutgoingWebhook(id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["id"] = id
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/outgoing/delete", 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) ListOutgoingWebhooks() (*Result, *AppError) {
- if r, err := c.DoApiGet(c.GetTeamRoute()+"/hooks/outgoing/list", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), OutgoingWebhookListFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) RegenOutgoingWebhookToken(id string) (*Result, *AppError) {
- data := make(map[string]string)
- data["id"] = id
- if r, err := c.DoApiPost(c.GetTeamRoute()+"/hooks/outgoing/regen_token", 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), OutgoingWebhookFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) MockSession(sessionToken string) {
- c.AuthToken = sessionToken
- c.AuthType = HEADER_BEARER
-}
-
-func (c *Client) GetClientLicenceConfig(etag string) (*Result, *AppError) {
- if r, err := c.DoApiGet("/license/client_config", "", etag); 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) GetInitialLoad() (*Result, *AppError) {
- if r, err := c.DoApiGet("/users/initial_load", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), InitialLoadFromJson(r.Body)}, nil
- }
-}
-
-// ListEmoji returns a list of all user-created emoji for the server.
-func (c *Client) ListEmoji() ([]*Emoji, *AppError) {
- if r, err := c.DoApiGet(c.GetEmojiRoute()+"/list", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return EmojiListFromJson(r.Body), nil
- }
-}
-
-// CreateEmoji will save an emoji to the server if the current user has permission
-// to do so. If successful, the provided emoji will be returned with its Id field
-// filled in. Otherwise, an error will be returned.
-func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoji, *AppError) {
- c.clearExtraProperties()
-
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("image", filename); err != nil {
- return nil, NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)
- } else if _, err = io.Copy(part, bytes.NewBuffer(image)); err != nil {
- return nil, NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)
- }
-
- if err := writer.WriteField("emoji", emoji.ToJson()); err != nil {
- return nil, NewAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error(), 0)
- }
-
- if err := writer.Close(); err != nil {
- return nil, NewAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error(), 0)
- }
-
- rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetEmojiRoute()+"/create", body)
- rq.Header.Set("Content-Type", writer.FormDataContentType())
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
- }
-
- if r, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if r.StatusCode >= 300 {
- return nil, AppErrorFromJson(r.Body)
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return EmojiFromJson(r.Body), nil
- }
-}
-
-// DeleteEmoji will delete an emoji from the server if the current user has permission
-// to do so. If successful, it will return status=ok. Otherwise, an error will be returned.
-func (c *Client) DeleteEmoji(id string) (bool, *AppError) {
- data := map[string]string{"id": id}
-
- if r, err := c.DoApiPost(c.GetEmojiRoute()+"/delete", MapToJson(data)); err != nil {
- return false, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return c.CheckStatusOK(r), nil
- }
-}
-
-// GetCustomEmojiImageUrl returns the API route that can be used to get the image used by
-// the given emoji.
-func (c *Client) GetCustomEmojiImageUrl(id string) string {
- return c.GetEmojiRoute() + "/" + id
-}
-
-// Uploads a x509 base64 Certificate or Private Key file to be used with SAML.
-// data byte array is required and needs to be a Multi-Part with 'certificate' as the field name
-// contentType is also required. Returns nil if succesful, otherwise returns an AppError
-func (c *Client) UploadCertificateFile(data []byte, contentType string) *AppError {
- url := c.ApiUrl + "/admin/add_certificate"
- rq, _ := http.NewRequest("POST", url, bytes.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil {
- return NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode >= 300 {
- return AppErrorFromJson(rp.Body)
- } else {
- defer closeBody(rp)
- c.fillInExtraProperties(rp)
- return nil
- }
-}
-
-// Removes a x509 base64 Certificate or Private Key file used with SAML.
-// filename is required. Returns nil if successful, otherwise returns an AppError
-func (c *Client) RemoveCertificateFile(filename string) *AppError {
- if r, err := c.DoApiPost("/admin/remove_certificate", MapToJson(map[string]string{"filename": filename})); err != nil {
- return err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return nil
- }
-}
-
-// Checks if the x509 base64 Certificates and Private Key files used with SAML exists on the file system.
-// Returns a map[string]interface{} if successful, otherwise returns an AppError. Must be System Admin authenticated.
-func (c *Client) SamlCertificateStatus(filename string) (map[string]interface{}, *AppError) {
- if r, err := c.DoApiGet("/admin/remove_certificate", "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return StringInterfaceFromJson(r.Body), nil
- }
-}
-
-// GetWebrtcToken if Successful returns a map with a valid token, stun server and turn server with credentials to use with
-// the Mattermost WebRTC service, otherwise returns an AppError. Must be authenticated user.
-func (c *Client) GetWebrtcToken() (map[string]string, *AppError) {
- if r, err := c.DoApiPost("/webrtc/token", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body), nil
- }
-}
-
-// GetFileInfosForPost returns a list of FileInfo objects for a given post id, if successful.
-// Otherwise, it returns an error.
-func (c *Client) GetFileInfosForPost(channelId string, postId string, etag string) ([]*FileInfo, *AppError) {
- c.clearExtraProperties()
-
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/get_file_infos", postId), "", etag); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return FileInfosFromJson(r.Body), nil
- }
-}
-
-// Saves an emoji reaction for a post in the given channel. Returns the saved reaction if successful, otherwise returns an AppError.
-func (c *Client) SaveReaction(channelId string, reaction *Reaction) (*Reaction, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/reactions/save", reaction.PostId), reaction.ToJson()); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return ReactionFromJson(r.Body), nil
- }
-}
-
-// Removes an emoji reaction for a post in the given channel. Returns nil if successful, otherwise returns an AppError.
-func (c *Client) DeleteReaction(channelId string, reaction *Reaction) *AppError {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/reactions/delete", reaction.PostId), reaction.ToJson()); err != nil {
- return err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return nil
- }
-}
-
-// Lists all emoji reactions made for the given post in the given channel. Returns a list of Reactions if successful, otherwise returns an AppError.
-func (c *Client) ListReactions(channelId string, postId string) ([]*Reaction, *AppError) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+fmt.Sprintf("/posts/%v/reactions", postId), "", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- c.fillInExtraProperties(r)
- return ReactionsFromJson(r.Body), nil
- }
-}
-
-// Updates the user's roles in the channel by replacing them with the roles provided.
-func (c *Client) UpdateChannelRoles(channelId string, userId string, roles string) (map[string]string, *ResponseMetadata) {
- data := make(map[string]string)
- data["new_roles"] = roles
- data["user_id"] = userId
-
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/update_member_roles", MapToJson(data)); err != nil {
- metadata := ResponseMetadata{Error: err}
- if r != nil {
- metadata.StatusCode = r.StatusCode
- }
- return nil, &metadata
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body),
- &ResponseMetadata{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- }
- }
-}
-
-func (c *Client) PinPost(channelId string, postId string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/posts/"+postId+"/pin", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostFromJson(r.Body)}, nil
- }
-}
-
-func (c *Client) UnpinPost(channelId string, postId string) (*Result, *AppError) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/posts/"+postId+"/unpin", ""); err != nil {
- return nil, err
- } else {
- defer closeBody(r)
- return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), PostFromJson(r.Body)}, nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/client4.go b/vendor/github.com/mattermost/platform/model/client4.go
deleted file mode 100644
index e84a23e5..00000000
--- a/vendor/github.com/mattermost/platform/model/client4.go
+++ /dev/null
@@ -1,3225 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "bytes"
- "fmt"
- "io"
- "io/ioutil"
- "mime/multipart"
- "net/http"
- "net/url"
- "strconv"
- "strings"
-)
-
-type Response struct {
- StatusCode int
- Error *AppError
- RequestId string
- Etag string
- ServerVersion string
- Header http.Header
-}
-
-type Client4 struct {
- Url string // The location of the server, for example "http://localhost:8065"
- ApiUrl string // The api location of the server, for example "http://localhost:8065/api/v4"
- HttpClient *http.Client // The http client
- AuthToken string
- AuthType string
-}
-
-func NewAPIv4Client(url string) *Client4 {
- return &Client4{url, url + API_URL_SUFFIX, &http.Client{}, "", ""}
-}
-
-func BuildErrorResponse(r *http.Response, err *AppError) *Response {
- var statusCode int
- var header http.Header
- if r != nil {
- statusCode = r.StatusCode
- header = r.Header
- } else {
- statusCode = 0
- header = make(http.Header)
- }
-
- return &Response{
- StatusCode: statusCode,
- Error: err,
- Header: header,
- }
-}
-
-func BuildResponse(r *http.Response) *Response {
- return &Response{
- StatusCode: r.StatusCode,
- RequestId: r.Header.Get(HEADER_REQUEST_ID),
- Etag: r.Header.Get(HEADER_ETAG_SERVER),
- ServerVersion: r.Header.Get(HEADER_VERSION_ID),
- Header: r.Header,
- }
-}
-
-func (c *Client4) SetOAuthToken(token string) {
- c.AuthToken = token
- c.AuthType = HEADER_TOKEN
-}
-
-func (c *Client4) ClearOAuthToken() {
- c.AuthToken = ""
- c.AuthType = HEADER_BEARER
-}
-
-func (c *Client4) GetUsersRoute() string {
- return fmt.Sprintf("/users")
-}
-
-func (c *Client4) GetUserRoute(userId string) string {
- return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId)
-}
-
-func (c *Client4) GetUserAccessTokenRoute(tokenId string) string {
- return fmt.Sprintf(c.GetUsersRoute()+"/tokens/%v", tokenId)
-}
-
-func (c *Client4) GetUserByUsernameRoute(userName string) string {
- return fmt.Sprintf(c.GetUsersRoute()+"/username/%v", userName)
-}
-
-func (c *Client4) GetUserByEmailRoute(email string) string {
- return fmt.Sprintf(c.GetUsersRoute()+"/email/%v", email)
-}
-
-func (c *Client4) GetTeamsRoute() string {
- return fmt.Sprintf("/teams")
-}
-
-func (c *Client4) GetTeamRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamsRoute()+"/%v", teamId)
-}
-
-func (c *Client4) GetTeamAutoCompleteCommandsRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamsRoute()+"/%v/commands/autocomplete", teamId)
-}
-
-func (c *Client4) GetTeamByNameRoute(teamName string) string {
- return fmt.Sprintf(c.GetTeamsRoute()+"/name/%v", teamName)
-}
-
-func (c *Client4) GetTeamMemberRoute(teamId, userId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId)+"/members/%v", userId)
-}
-
-func (c *Client4) GetTeamMembersRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId) + "/members")
-}
-
-func (c *Client4) GetTeamStatsRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId) + "/stats")
-}
-
-func (c *Client4) GetTeamImportRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId) + "/import")
-}
-
-func (c *Client4) GetChannelsRoute() string {
- return fmt.Sprintf("/channels")
-}
-
-func (c *Client4) GetChannelsForTeamRoute(teamId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId) + "/channels")
-}
-
-func (c *Client4) GetChannelRoute(channelId string) string {
- return fmt.Sprintf(c.GetChannelsRoute()+"/%v", channelId)
-}
-
-func (c *Client4) GetChannelByNameRoute(channelName, teamId string) string {
- return fmt.Sprintf(c.GetTeamRoute(teamId)+"/channels/name/%v", channelName)
-}
-
-func (c *Client4) GetChannelByNameForTeamNameRoute(channelName, teamName string) string {
- return fmt.Sprintf(c.GetTeamByNameRoute(teamName)+"/channels/name/%v", channelName)
-}
-
-func (c *Client4) GetChannelMembersRoute(channelId string) string {
- return fmt.Sprintf(c.GetChannelRoute(channelId) + "/members")
-}
-
-func (c *Client4) GetChannelMemberRoute(channelId, userId string) string {
- return fmt.Sprintf(c.GetChannelMembersRoute(channelId)+"/%v", userId)
-}
-
-func (c *Client4) GetPostsRoute() string {
- return fmt.Sprintf("/posts")
-}
-
-func (c *Client4) GetConfigRoute() string {
- return fmt.Sprintf("/config")
-}
-
-func (c *Client4) GetLicenseRoute() string {
- return fmt.Sprintf("/license")
-}
-
-func (c *Client4) GetPostRoute(postId string) string {
- return fmt.Sprintf(c.GetPostsRoute()+"/%v", postId)
-}
-
-func (c *Client4) GetFilesRoute() string {
- return fmt.Sprintf("/files")
-}
-
-func (c *Client4) GetFileRoute(fileId string) string {
- return fmt.Sprintf(c.GetFilesRoute()+"/%v", fileId)
-}
-
-func (c *Client4) GetPluginsRoute() string {
- return fmt.Sprintf("/plugins")
-}
-
-func (c *Client4) GetPluginRoute(pluginId string) string {
- return fmt.Sprintf(c.GetPluginsRoute()+"/%v", pluginId)
-}
-
-func (c *Client4) GetSystemRoute() string {
- return fmt.Sprintf("/system")
-}
-
-func (c *Client4) GetTestEmailRoute() string {
- return fmt.Sprintf("/email/test")
-}
-
-func (c *Client4) GetDatabaseRoute() string {
- return fmt.Sprintf("/database")
-}
-
-func (c *Client4) GetCacheRoute() string {
- return fmt.Sprintf("/caches")
-}
-
-func (c *Client4) GetClusterRoute() string {
- return fmt.Sprintf("/cluster")
-}
-
-func (c *Client4) GetIncomingWebhooksRoute() string {
- return fmt.Sprintf("/hooks/incoming")
-}
-
-func (c *Client4) GetIncomingWebhookRoute(hookID string) string {
- return fmt.Sprintf(c.GetIncomingWebhooksRoute()+"/%v", hookID)
-}
-
-func (c *Client4) GetComplianceReportsRoute() string {
- return fmt.Sprintf("/compliance/reports")
-}
-
-func (c *Client4) GetComplianceReportRoute(reportId string) string {
- return fmt.Sprintf("/compliance/reports/%v", reportId)
-}
-
-func (c *Client4) GetOutgoingWebhooksRoute() string {
- return fmt.Sprintf("/hooks/outgoing")
-}
-
-func (c *Client4) GetOutgoingWebhookRoute(hookID string) string {
- return fmt.Sprintf(c.GetOutgoingWebhooksRoute()+"/%v", hookID)
-}
-
-func (c *Client4) GetPreferencesRoute(userId string) string {
- return fmt.Sprintf(c.GetUserRoute(userId) + "/preferences")
-}
-
-func (c *Client4) GetUserStatusRoute(userId string) string {
- return fmt.Sprintf(c.GetUserRoute(userId) + "/status")
-}
-
-func (c *Client4) GetUserStatusesRoute() string {
- return fmt.Sprintf(c.GetUsersRoute() + "/status")
-}
-
-func (c *Client4) GetSamlRoute() string {
- return fmt.Sprintf("/saml")
-}
-
-func (c *Client4) GetLdapRoute() string {
- return fmt.Sprintf("/ldap")
-}
-
-func (c *Client4) GetBrandRoute() string {
- return fmt.Sprintf("/brand")
-}
-
-func (c *Client4) GetDataRetentionRoute() string {
- return fmt.Sprintf("/data_retention")
-}
-
-func (c *Client4) GetElasticsearchRoute() string {
- return fmt.Sprintf("/elasticsearch")
-}
-
-func (c *Client4) GetCommandsRoute() string {
- return fmt.Sprintf("/commands")
-}
-
-func (c *Client4) GetCommandRoute(commandId string) string {
- return fmt.Sprintf(c.GetCommandsRoute()+"/%v", commandId)
-}
-
-func (c *Client4) GetEmojisRoute() string {
- return fmt.Sprintf("/emoji")
-}
-
-func (c *Client4) GetEmojiRoute(emojiId string) string {
- return fmt.Sprintf(c.GetEmojisRoute()+"/%v", emojiId)
-}
-
-func (c *Client4) GetReactionsRoute() string {
- return fmt.Sprintf("/reactions")
-}
-
-func (c *Client4) GetOAuthAppsRoute() string {
- return fmt.Sprintf("/oauth/apps")
-}
-
-func (c *Client4) GetOAuthAppRoute(appId string) string {
- return fmt.Sprintf("/oauth/apps/%v", appId)
-}
-
-func (c *Client4) GetOpenGraphRoute() string {
- return fmt.Sprintf("/opengraph")
-}
-
-func (c *Client4) GetJobsRoute() string {
- return fmt.Sprintf("/jobs")
-}
-
-func (c *Client4) GetAnalyticsRoute() string {
- return fmt.Sprintf("/analytics")
-}
-
-func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
- return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
-}
-
-func (c *Client4) DoApiPost(url string, data string) (*http.Response, *AppError) {
- return c.DoApiRequest(http.MethodPost, c.ApiUrl+url, data, "")
-}
-
-func (c *Client4) DoApiPut(url string, data string) (*http.Response, *AppError) {
- return c.DoApiRequest(http.MethodPut, c.ApiUrl+url, data, "")
-}
-
-func (c *Client4) DoApiDelete(url string) (*http.Response, *AppError) {
- return c.DoApiRequest(http.MethodDelete, c.ApiUrl+url, "", "")
-}
-
-func (c *Client4) DoApiRequest(method, url, data, etag string) (*http.Response, *AppError) {
- rq, _ := http.NewRequest(method, url, strings.NewReader(data))
- rq.Close = true
-
- if len(etag) > 0 {
- rq.Header.Set(HEADER_ETAG_CLIENT, etag)
- }
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
- } else if rp.StatusCode == 304 {
- return rp, nil
- } else if rp.StatusCode >= 300 {
- defer closeBody(rp)
- return rp, AppErrorFromJson(rp.Body)
- } else {
- return rp, nil
- }
-}
-
-func (c *Client4) DoUploadFile(url string, data []byte, contentType string) (*FileUploadResponse, *Response) {
- rq, _ := http.NewRequest("POST", c.ApiUrl+url, bytes.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return nil, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return FileUploadResponseFromJson(rp.Body), BuildResponse(rp)
- }
- }
-}
-
-func (c *Client4) DoEmojiUploadFile(url string, data []byte, contentType string) (*Emoji, *Response) {
- rq, _ := http.NewRequest("POST", c.ApiUrl+url, bytes.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return nil, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return EmojiFromJson(rp.Body), BuildResponse(rp)
- }
- }
-}
-
-func (c *Client4) DoUploadImportTeam(url string, data []byte, contentType string) (map[string]string, *Response) {
- rq, _ := http.NewRequest("POST", c.ApiUrl+url, bytes.NewReader(data))
- rq.Header.Set("Content-Type", contentType)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, BuildErrorResponse(rp, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0))
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return nil, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return MapFromJson(rp.Body), BuildResponse(rp)
- }
- }
-}
-
-// CheckStatusOK is a convenience function for checking the standard OK response
-// from the web service.
-func CheckStatusOK(r *http.Response) bool {
- m := MapFromJson(r.Body)
- defer closeBody(r)
-
- if m != nil && m[STATUS] == STATUS_OK {
- return true
- }
-
- return false
-}
-
-// Authentication Section
-
-// LoginById authenticates a user by user id and password.
-func (c *Client4) LoginById(id string, password string) (*User, *Response) {
- m := make(map[string]string)
- m["id"] = id
- m["password"] = password
- return c.login(m)
-}
-
-// Login authenticates a user by login id, which can be username, email or some sort
-// of SSO identifier based on server configuration, and a password.
-func (c *Client4) Login(loginId string, password string) (*User, *Response) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- return c.login(m)
-}
-
-// LoginByLdap authenticates a user by LDAP id and password.
-func (c *Client4) LoginByLdap(loginId string, password string) (*User, *Response) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- m["ldap_only"] = "true"
- return c.login(m)
-}
-
-// LoginWithDevice authenticates a user by login id (username, email or some sort
-// of SSO identifier based on configuration), password and attaches a device id to
-// the session.
-func (c *Client4) LoginWithDevice(loginId string, password string, deviceId string) (*User, *Response) {
- m := make(map[string]string)
- m["login_id"] = loginId
- m["password"] = password
- m["device_id"] = deviceId
- return c.login(m)
-}
-
-func (c *Client4) login(m map[string]string) (*User, *Response) {
- if r, err := c.DoApiPost("/users/login", MapToJson(m)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- c.AuthToken = r.Header.Get(HEADER_TOKEN)
- c.AuthType = HEADER_BEARER
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Logout terminates the current user's session.
-func (c *Client4) Logout() (bool, *Response) {
- if r, err := c.DoApiPost("/users/logout", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- c.AuthToken = ""
- c.AuthType = HEADER_BEARER
-
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// SwitchAccountType changes a user's login type from one type to another.
-func (c *Client4) SwitchAccountType(switchRequest *SwitchRequest) (string, *Response) {
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/login/switch", switchRequest.ToJson()); err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body)["follow_link"], BuildResponse(r)
- }
-}
-
-// User Section
-
-// CreateUser creates a user in the system based on the provided user struct.
-func (c *Client4) CreateUser(user *User) (*User, *Response) {
- if r, err := c.DoApiPost(c.GetUsersRoute(), user.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CreateUserWithHash creates a user in the system based on the provided user struct and hash created.
-func (c *Client4) CreateUserWithHash(user *User, hash, data string) (*User, *Response) {
- var query string
- if hash != "" && data != "" {
- query = fmt.Sprintf("?d=%v&h=%v", url.QueryEscape(data), hash)
- } else {
- err := NewAppError("MissingHashOrData", "api.user.create_user.missing_hash_or_data.app_error", nil, "", http.StatusBadRequest)
- return nil, &Response{StatusCode: err.StatusCode, Error: err}
- }
- if r, err := c.DoApiPost(c.GetUsersRoute()+query, user.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CreateUserWithInviteId creates a user in the system based on the provided invited id.
-func (c *Client4) CreateUserWithInviteId(user *User, inviteId string) (*User, *Response) {
- var query string
- if inviteId != "" {
- query = fmt.Sprintf("?iid=%v", url.QueryEscape(inviteId))
- } else {
- err := NewAppError("MissingInviteId", "api.user.create_user.missing_invite_id.app_error", nil, "", http.StatusBadRequest)
- return nil, &Response{StatusCode: err.StatusCode, Error: err}
- }
- if r, err := c.DoApiPost(c.GetUsersRoute()+query, user.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetMe returns the logged in user.
-func (c *Client4) GetMe(etag string) (*User, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(ME), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUser returns a user based on the provided user id string.
-func (c *Client4) GetUser(userId, etag string) (*User, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUserByUsername returns a user based on the provided user name string.
-func (c *Client4) GetUserByUsername(userName, etag string) (*User, *Response) {
- if r, err := c.DoApiGet(c.GetUserByUsernameRoute(userName), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUserByEmail returns a user based on the provided user email string.
-func (c *Client4) GetUserByEmail(email, etag string) (*User, *Response) {
- if r, err := c.DoApiGet(c.GetUserByEmailRoute(email), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AutocompleteUsersInTeam returns the users on a team based on search term.
-func (c *Client4) AutocompleteUsersInTeam(teamId string, username string, etag string) (*UserAutocomplete, *Response) {
- query := fmt.Sprintf("?in_team=%v&name=%v", teamId, username)
- if r, err := c.DoApiGet(c.GetUsersRoute()+"/autocomplete"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAutocompleteFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AutocompleteUsersInChannel returns the users in a channel based on search term.
-func (c *Client4) AutocompleteUsersInChannel(teamId string, channelId string, username string, etag string) (*UserAutocomplete, *Response) {
- query := fmt.Sprintf("?in_team=%v&in_channel=%v&name=%v", teamId, channelId, username)
- if r, err := c.DoApiGet(c.GetUsersRoute()+"/autocomplete"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAutocompleteFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AutocompleteUsers returns the users in the system based on search term.
-func (c *Client4) AutocompleteUsers(username string, etag string) (*UserAutocomplete, *Response) {
- query := fmt.Sprintf("?name=%v", username)
- if r, err := c.DoApiGet(c.GetUsersRoute()+"/autocomplete"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAutocompleteFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetProfileImage gets user's profile image. Must be logged in or be a system administrator.
-func (c *Client4) GetProfileImage(userId, etag string) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/image", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetProfileImage", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// GetUsers returns a page of users on the system. Page counting starts at 0.
-func (c *Client4) GetUsers(page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersInTeam returns a page of users on a team. Page counting starts at 0.
-func (c *Client4) GetUsersInTeam(teamId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?in_team=%v&page=%v&per_page=%v", teamId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetNewUsersInTeam returns a page of users on a team. Page counting starts at 0.
-func (c *Client4) GetNewUsersInTeam(teamId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?sort=create_at&in_team=%v&page=%v&per_page=%v", teamId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetRecentlyActiveUsersInTeam returns a page of users on a team. Page counting starts at 0.
-func (c *Client4) GetRecentlyActiveUsersInTeam(teamId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?sort=last_activity_at&in_team=%v&page=%v&per_page=%v", teamId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersNotInTeam returns a page of users who are not in a team. Page counting starts at 0.
-func (c *Client4) GetUsersNotInTeam(teamId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?not_in_team=%v&page=%v&per_page=%v", teamId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersInChannel returns a page of users on a team. Page counting starts at 0.
-func (c *Client4) GetUsersInChannel(channelId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?in_channel=%v&page=%v&per_page=%v", channelId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersNotInChannel returns a page of users on a team. Page counting starts at 0.
-func (c *Client4) GetUsersNotInChannel(teamId, channelId string, page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?in_team=%v&not_in_channel=%v&page=%v&per_page=%v", teamId, channelId, page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersWithoutTeam returns a page of users on the system that aren't on any teams. Page counting starts at 0.
-func (c *Client4) GetUsersWithoutTeam(page int, perPage int, etag string) ([]*User, *Response) {
- query := fmt.Sprintf("?without_team=1&page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUsersRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersByIds returns a list of users based on the provided user ids.
-func (c *Client4) GetUsersByIds(userIds []string) ([]*User, *Response) {
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/ids", ArrayToJson(userIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersByUsernames returns a list of users based on the provided usernames.
-func (c *Client4) GetUsersByUsernames(usernames []string) ([]*User, *Response) {
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/usernames", ArrayToJson(usernames)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SearchUsers returns a list of users based on some search criteria.
-func (c *Client4) SearchUsers(search *UserSearch) ([]*User, *Response) {
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/search", search.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateUser updates a user in the system based on the provided user struct.
-func (c *Client4) UpdateUser(user *User) (*User, *Response) {
- if r, err := c.DoApiPut(c.GetUserRoute(user.Id), user.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PatchUser partially updates a user in the system. Any missing fields are not updated.
-func (c *Client4) PatchUser(userId string, patch *UserPatch) (*User, *Response) {
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/patch", patch.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateUserAuth updates a user AuthData (uthData, authService and password) in the system.
-func (c *Client4) UpdateUserAuth(userId string, userAuth *UserAuth) (*UserAuth, *Response) {
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/auth", userAuth.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAuthFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateUserMfa activates multi-factor authentication for a user if activate
-// is true and a valid code is provided. If activate is false, then code is not
-// required and multi-factor authentication is disabled for the user.
-func (c *Client4) UpdateUserMfa(userId, code string, activate bool) (bool, *Response) {
- requestBody := make(map[string]interface{})
- requestBody["activate"] = activate
- requestBody["code"] = code
-
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/mfa", StringInterfaceToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// CheckUserMfa checks whether a user has MFA active on their account or not based on the
-// provided login id.
-func (c *Client4) CheckUserMfa(loginId string) (bool, *Response) {
- requestBody := make(map[string]interface{})
- requestBody["login_id"] = loginId
-
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/mfa", StringInterfaceToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- data := StringInterfaceFromJson(r.Body)
- if mfaRequired, ok := data["mfa_required"].(bool); !ok {
- return false, BuildResponse(r)
- } else {
- return mfaRequired, BuildResponse(r)
- }
- }
-}
-
-// GenerateMfaSecret will generate a new MFA secret for a user and return it as a string and
-// as a base64 encoded image QR code.
-func (c *Client4) GenerateMfaSecret(userId string) (*MfaSecret, *Response) {
- if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/mfa/generate", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MfaSecretFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateUserPassword updates a user's password. Must be logged in as the user or be a system administrator.
-func (c *Client4) UpdateUserPassword(userId, currentPassword, newPassword string) (bool, *Response) {
- requestBody := map[string]string{"current_password": currentPassword, "new_password": newPassword}
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/password", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UpdateUserRoles updates a user's roles in the system. A user can have "system_user" and "system_admin" roles.
-func (c *Client4) UpdateUserRoles(userId, roles string) (bool, *Response) {
- requestBody := map[string]string{"roles": roles}
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/roles", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UpdateUserActive updates status of a user whether active or not.
-func (c *Client4) UpdateUserActive(userId string, active bool) (bool, *Response) {
- requestBody := make(map[string]interface{})
- requestBody["active"] = active
-
- if r, err := c.DoApiPut(c.GetUserRoute(userId)+"/active", StringInterfaceToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// DeleteUser deactivates a user in the system based on the provided user id string.
-func (c *Client4) DeleteUser(userId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetUserRoute(userId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// SendPasswordResetEmail will send a link for password resetting to a user with the
-// provided email.
-func (c *Client4) SendPasswordResetEmail(email string) (bool, *Response) {
- requestBody := map[string]string{"email": email}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/password/reset/send", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// ResetPassword uses a recovery code to update reset a user's password.
-func (c *Client4) ResetPassword(token, newPassword string) (bool, *Response) {
- requestBody := map[string]string{"token": token, "new_password": newPassword}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/password/reset", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetSessions returns a list of sessions based on the provided user id string.
-func (c *Client4) GetSessions(userId, etag string) ([]*Session, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/sessions", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return SessionsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RevokeSession revokes a user session based on the provided user id and session id strings.
-func (c *Client4) RevokeSession(userId, sessionId string) (bool, *Response) {
- requestBody := map[string]string{"session_id": sessionId}
- if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/sessions/revoke", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// RevokeAllSessions revokes all sessions for the provided user id string.
-func (c *Client4) RevokeAllSessions(userId string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/sessions/revoke/all", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// AttachDeviceId attaches a mobile device ID to the current session.
-func (c *Client4) AttachDeviceId(deviceId string) (bool, *Response) {
- requestBody := map[string]string{"device_id": deviceId}
- if r, err := c.DoApiPut(c.GetUsersRoute()+"/sessions/device", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetTeamsUnreadForUser will return an array with TeamUnread objects that contain the amount
-// of unread messages and mentions the current user has for the teams it belongs to.
-// An optional team ID can be set to exclude that team from the results. Must be authenticated.
-func (c *Client4) GetTeamsUnreadForUser(userId, teamIdToExclude string) ([]*TeamUnread, *Response) {
- optional := ""
- if teamIdToExclude != "" {
- optional += fmt.Sprintf("?exclude_team=%s", url.QueryEscape(teamIdToExclude))
- }
-
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams/unread"+optional, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamsUnreadFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUserAudits returns a list of audit based on the provided user id string.
-func (c *Client4) GetUserAudits(userId string, page int, perPage int, etag string) (Audits, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/audits"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return AuditsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// VerifyUserEmail will verify a user's email using the supplied token.
-func (c *Client4) VerifyUserEmail(token string) (bool, *Response) {
- requestBody := map[string]string{"token": token}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/email/verify", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// SendVerificationEmail will send an email to the user with the provided email address, if
-// that user exists. The email will contain a link that can be used to verify the user's
-// email address.
-func (c *Client4) SendVerificationEmail(email string) (bool, *Response) {
- requestBody := map[string]string{"email": email}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/email/verify/send", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// SetProfileImage sets profile image of the user
-func (c *Client4) SetProfileImage(userId string, data []byte) (bool, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("image", "profile.png"); err != nil {
- return false, &Response{Error: NewAppError("SetProfileImage", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return false, &Response{Error: NewAppError("SetProfileImage", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if err := writer.Close(); err != nil {
- return false, &Response{Error: NewAppError("SetProfileImage", "model.client.set_profile_user.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetUserRoute(userId)+"/image", bytes.NewReader(body.Bytes()))
- rq.Header.Set("Content-Type", writer.FormDataContentType())
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- // set to http.StatusForbidden(403)
- return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetUserRoute(userId)+"/image", "model.client.connecting.app_error", nil, err.Error(), 403)}
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return false, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return CheckStatusOK(rp), BuildResponse(rp)
- }
- }
-}
-
-// CreateUserAccessToken will generate a user access token that can be used in place
-// of a session token to access the REST API. Must have the 'create_user_access_token'
-// permission and if generating for another user, must have the 'edit_other_users'
-// permission. A non-blank description is required.
-func (c *Client4) CreateUserAccessToken(userId, description string) (*UserAccessToken, *Response) {
- requestBody := map[string]string{"description": description}
- if r, err := c.DoApiPost(c.GetUserRoute(userId)+"/tokens", MapToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAccessTokenFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUserAccessToken will get a user access token's id, description and the user_id
-// of the user it is for. The actual token will not be returned. Must have the
-// 'read_user_access_token' permission and if getting for another user, must have the
-// 'edit_other_users' permission.
-func (c *Client4) GetUserAccessToken(tokenId string) (*UserAccessToken, *Response) {
- if r, err := c.DoApiGet(c.GetUserAccessTokenRoute(tokenId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAccessTokenFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUserAccessTokensForUser will get a paged list of user access tokens showing id,
-// description and user_id for each. The actual tokens will not be returned. Must have
-// the 'read_user_access_token' permission and if getting for another user, must have the
-// 'edit_other_users' permission.
-func (c *Client4) GetUserAccessTokensForUser(userId string, page, perPage int) ([]*UserAccessToken, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/tokens"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return UserAccessTokenListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RevokeUserAccessToken will revoke a user access token by id. Must have the
-// 'revoke_user_access_token' permission and if revoking for another user, must have the
-// 'edit_other_users' permission.
-func (c *Client4) RevokeUserAccessToken(tokenId string) (bool, *Response) {
- requestBody := map[string]string{"token_id": tokenId}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/tokens/revoke", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// DisableUserAccessToken will disable a user access token by id. Must have the
-// 'revoke_user_access_token' permission and if disabling for another user, must have the
-// 'edit_other_users' permission.
-func (c *Client4) DisableUserAccessToken(tokenId string) (bool, *Response) {
- requestBody := map[string]string{"token_id": tokenId}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/tokens/disable", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// EnableUserAccessToken will enable a user access token by id. Must have the
-// 'create_user_access_token' permission and if enabling for another user, must have the
-// 'edit_other_users' permission.
-func (c *Client4) EnableUserAccessToken(tokenId string) (bool, *Response) {
- requestBody := map[string]string{"token_id": tokenId}
- if r, err := c.DoApiPost(c.GetUsersRoute()+"/tokens/enable", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Team Section
-
-// CreateTeam creates a team in the system based on the provided team struct.
-func (c *Client4) CreateTeam(team *Team) (*Team, *Response) {
- if r, err := c.DoApiPost(c.GetTeamsRoute(), team.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeam returns a team based on the provided team id string.
-func (c *Client4) GetTeam(teamId, etag string) (*Team, *Response) {
- if r, err := c.DoApiGet(c.GetTeamRoute(teamId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetAllTeams returns all teams based on permissions.
-func (c *Client4) GetAllTeams(etag string, page int, perPage int) ([]*Team, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetTeamsRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeamByName returns a team based on the provided team name string.
-func (c *Client4) GetTeamByName(name, etag string) (*Team, *Response) {
- if r, err := c.DoApiGet(c.GetTeamByNameRoute(name), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SearchTeams returns teams matching the provided search term.
-func (c *Client4) SearchTeams(search *TeamSearch) ([]*Team, *Response) {
- if r, err := c.DoApiPost(c.GetTeamsRoute()+"/search", search.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// TeamExists returns true or false if the team exist or not.
-func (c *Client4) TeamExists(name, etag string) (bool, *Response) {
- if r, err := c.DoApiGet(c.GetTeamByNameRoute(name)+"/exists", etag); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapBoolFromJson(r.Body)["exists"], BuildResponse(r)
- }
-}
-
-// GetTeamsForUser returns a list of teams a user is on. Must be logged in as the user
-// or be a system administrator.
-func (c *Client4) GetTeamsForUser(userId, etag string) ([]*Team, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeamMember returns a team member based on the provided team and user id strings.
-func (c *Client4) GetTeamMember(teamId, userId, etag string) (*TeamMember, *Response) {
- if r, err := c.DoApiGet(c.GetTeamMemberRoute(teamId, userId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateTeamMemberRoles will update the roles on a team for a user.
-func (c *Client4) UpdateTeamMemberRoles(teamId, userId, newRoles string) (bool, *Response) {
- requestBody := map[string]string{"roles": newRoles}
- if r, err := c.DoApiPut(c.GetTeamMemberRoute(teamId, userId)+"/roles", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UpdateTeam will update a team.
-func (c *Client4) UpdateTeam(team *Team) (*Team, *Response) {
- if r, err := c.DoApiPut(c.GetTeamRoute(team.Id), team.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PatchTeam partially updates a team. Any missing fields are not updated.
-func (c *Client4) PatchTeam(teamId string, patch *TeamPatch) (*Team, *Response) {
- if r, err := c.DoApiPut(c.GetTeamRoute(teamId)+"/patch", patch.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SoftDeleteTeam deletes the team softly (archive only, not permanent delete).
-func (c *Client4) SoftDeleteTeam(teamId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetTeamRoute(teamId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// PermanentDeleteTeam deletes the team, should only be used when needed for
-// compliance and the like
-func (c *Client4) PermanentDeleteTeam(teamId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetTeamRoute(teamId) + "?permanent=true"); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetTeamMembers returns team members based on the provided team id string.
-func (c *Client4) GetTeamMembers(teamId string, page int, perPage int, etag string) ([]*TeamMember, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetTeamMembersRoute(teamId)+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeamMembersForUser returns the team members for a user.
-func (c *Client4) GetTeamMembersForUser(userId string, etag string) ([]*TeamMember, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/teams/members", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeamMembersByIds will return an array of team members based on the
-// team id and a list of user ids provided. Must be authenticated.
-func (c *Client4) GetTeamMembersByIds(teamId string, userIds []string) ([]*TeamMember, *Response) {
- if r, err := c.DoApiPost(fmt.Sprintf("/teams/%v/members/ids", teamId), ArrayToJson(userIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AddTeamMember adds user to a team and return a team member.
-func (c *Client4) AddTeamMember(teamId, userId string) (*TeamMember, *Response) {
- member := &TeamMember{TeamId: teamId, UserId: userId}
-
- if r, err := c.DoApiPost(c.GetTeamMembersRoute(teamId), member.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AddTeamMemberFromInvite adds a user to a team and return a team member using an invite id
-// or an invite hash/data pair.
-func (c *Client4) AddTeamMemberFromInvite(hash, dataToHash, inviteId string) (*TeamMember, *Response) {
- var query string
-
- if inviteId != "" {
- query += fmt.Sprintf("?invite_id=%v", inviteId)
- }
-
- if hash != "" && dataToHash != "" {
- query += fmt.Sprintf("?hash=%v&data=%v", hash, dataToHash)
- }
-
- if r, err := c.DoApiPost(c.GetTeamsRoute()+"/members/invite"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AddTeamMembers adds a number of users to a team and returns the team members.
-func (c *Client4) AddTeamMembers(teamId string, userIds []string) ([]*TeamMember, *Response) {
- var members []*TeamMember
- for _, userId := range userIds {
- member := &TeamMember{TeamId: teamId, UserId: userId}
- members = append(members, member)
- }
-
- if r, err := c.DoApiPost(c.GetTeamMembersRoute(teamId)+"/batch", TeamMembersToJson(members)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RemoveTeamMember will remove a user from a team.
-func (c *Client4) RemoveTeamMember(teamId, userId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetTeamMemberRoute(teamId, userId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetTeamStats returns a team stats based on the team id string.
-// Must be authenticated.
-func (c *Client4) GetTeamStats(teamId, etag string) (*TeamStats, *Response) {
- if r, err := c.DoApiGet(c.GetTeamStatsRoute(teamId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamStatsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetTeamUnread will return a TeamUnread object that contains the amount of
-// unread messages and mentions the user has for the specified team.
-// Must be authenticated.
-func (c *Client4) GetTeamUnread(teamId, userId string) (*TeamUnread, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+c.GetTeamRoute(teamId)+"/unread", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamUnreadFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ImportTeam will import an exported team from other app into a existing team.
-func (c *Client4) ImportTeam(data []byte, filesize int, importFrom, filename, teamId string) (map[string]string, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("file", filename); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if part, err := writer.CreateFormField("filesize"); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.file_size.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, strings.NewReader(strconv.Itoa(filesize))); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.file_size.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if part, err := writer.CreateFormField("importFrom"); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.import_from.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, strings.NewReader(importFrom)); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.import_from.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if err := writer.Close(); err != nil {
- return nil, &Response{Error: NewAppError("UploadImportTeam", "model.client.upload_post_attachment.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- return c.DoUploadImportTeam(c.GetTeamImportRoute(teamId), body.Bytes(), writer.FormDataContentType())
-}
-
-// InviteUsersToTeam invite users by email to the team.
-func (c *Client4) InviteUsersToTeam(teamId string, userEmails []string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/invite/email", ArrayToJson(userEmails)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetTeamInviteInfo returns a team object from an invite id containing sanitized information.
-func (c *Client4) GetTeamInviteInfo(inviteId string) (*Team, *Response) {
- if r, err := c.DoApiGet(c.GetTeamsRoute()+"/invite/"+inviteId, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return TeamFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Channel Section
-
-// CreateChannel creates a channel based on the provided channel struct.
-func (c *Client4) CreateChannel(channel *Channel) (*Channel, *Response) {
- if r, err := c.DoApiPost(c.GetChannelsRoute(), channel.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateChannel update a channel based on the provided channel struct.
-func (c *Client4) UpdateChannel(channel *Channel) (*Channel, *Response) {
- if r, err := c.DoApiPut(c.GetChannelRoute(channel.Id), channel.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PatchChannel partially updates a channel. Any missing fields are not updated.
-func (c *Client4) PatchChannel(channelId string, patch *ChannelPatch) (*Channel, *Response) {
- if r, err := c.DoApiPut(c.GetChannelRoute(channelId)+"/patch", patch.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RestoreChannel restores a previously deleted channel. Any missing fields are not updated.
-func (c *Client4) RestoreChannel(channelId string) (*Channel, *Response) {
- if r, err := c.DoApiPost(c.GetChannelRoute(channelId)+"/restore", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CreateDirectChannel creates a direct message channel based on the two user
-// ids provided.
-func (c *Client4) CreateDirectChannel(userId1, userId2 string) (*Channel, *Response) {
- requestBody := []string{userId1, userId2}
- if r, err := c.DoApiPost(c.GetChannelsRoute()+"/direct", ArrayToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CreateGroupChannel creates a group message channel based on userIds provided
-func (c *Client4) CreateGroupChannel(userIds []string) (*Channel, *Response) {
- if r, err := c.DoApiPost(c.GetChannelsRoute()+"/group", ArrayToJson(userIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannel returns a channel based on the provided channel id string.
-func (c *Client4) GetChannel(channelId, etag string) (*Channel, *Response) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelStats returns statistics for a channel.
-func (c *Client4) GetChannelStats(channelId string, etag string) (*ChannelStats, *Response) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/stats", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelStatsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPinnedPosts gets a list of pinned posts.
-func (c *Client4) GetPinnedPosts(channelId string, etag string) (*PostList, *Response) {
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/pinned", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPublicChannelsForTeam returns a list of public channels based on the provided team id string.
-func (c *Client4) GetPublicChannelsForTeam(teamId string, page int, perPage int, etag string) ([]*Channel, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetChannelsForTeamRoute(teamId)+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelSliceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetDeletedChannelsForTeam returns a list of public channels based on the provided team id string.
-func (c *Client4) GetDeletedChannelsForTeam(teamId string, page int, perPage int, etag string) ([]*Channel, *Response) {
- query := fmt.Sprintf("/deleted?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetChannelsForTeamRoute(teamId)+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelSliceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPublicChannelsByIdsForTeam returns a list of public channels based on provided team id string
-func (c *Client4) GetPublicChannelsByIdsForTeam(teamId string, channelIds []string) ([]*Channel, *Response) {
- if r, err := c.DoApiPost(c.GetChannelsForTeamRoute(teamId)+"/ids", ArrayToJson(channelIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelSliceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelsForTeamForUser returns a list channels of on a team for a user.
-func (c *Client4) GetChannelsForTeamForUser(teamId, userId, etag string) ([]*Channel, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+c.GetTeamRoute(teamId)+"/channels", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelSliceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SearchChannels returns the channels on a team matching the provided search term.
-func (c *Client4) SearchChannels(teamId string, search *ChannelSearch) ([]*Channel, *Response) {
- if r, err := c.DoApiPost(c.GetChannelsForTeamRoute(teamId)+"/search", search.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelSliceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteChannel deletes channel based on the provided channel id string.
-func (c *Client4) DeleteChannel(channelId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetChannelRoute(channelId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetChannelByName returns a channel based on the provided channel name and team id strings.
-func (c *Client4) GetChannelByName(channelName, teamId string, etag string) (*Channel, *Response) {
- if r, err := c.DoApiGet(c.GetChannelByNameRoute(channelName, teamId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelByNameForTeamName returns a channel based on the provided channel name and team name strings.
-func (c *Client4) GetChannelByNameForTeamName(channelName, teamName string, etag string) (*Channel, *Response) {
- if r, err := c.DoApiGet(c.GetChannelByNameForTeamNameRoute(channelName, teamName), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelMembers gets a page of channel members.
-func (c *Client4) GetChannelMembers(channelId string, page, perPage int, etag string) (*ChannelMembers, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetChannelMembersRoute(channelId)+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelMembersByIds gets the channel members in a channel for a list of user ids.
-func (c *Client4) GetChannelMembersByIds(channelId string, userIds []string) (*ChannelMembers, *Response) {
- if r, err := c.DoApiPost(c.GetChannelMembersRoute(channelId)+"/ids", ArrayToJson(userIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMembersFromJson(r.Body), BuildResponse(r)
-
- }
-}
-
-// GetChannelMember gets a channel member.
-func (c *Client4) GetChannelMember(channelId, userId, etag string) (*ChannelMember, *Response) {
- if r, err := c.DoApiGet(c.GetChannelMemberRoute(channelId, userId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelMembersForUser gets all the channel members for a user on a team.
-func (c *Client4) GetChannelMembersForUser(userId, teamId, etag string) (*ChannelMembers, *Response) {
- if r, err := c.DoApiGet(fmt.Sprintf(c.GetUserRoute(userId)+"/teams/%v/channels/members", teamId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMembersFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ViewChannel performs a view action for a user. Synonymous with switching channels or marking channels as read by a user.
-func (c *Client4) ViewChannel(userId string, view *ChannelView) (*ChannelViewResponse, *Response) {
- url := fmt.Sprintf(c.GetChannelsRoute()+"/members/%v/view", userId)
- if r, err := c.DoApiPost(url, view.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelViewResponseFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetChannelUnread will return a ChannelUnread object that contains the number of
-// unread messages and mentions for a user.
-func (c *Client4) GetChannelUnread(channelId, userId string) (*ChannelUnread, *Response) {
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+c.GetChannelRoute(channelId)+"/unread", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelUnreadFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateChannelRoles will update the roles on a channel for a user.
-func (c *Client4) UpdateChannelRoles(channelId, userId, roles string) (bool, *Response) {
- requestBody := map[string]string{"roles": roles}
- if r, err := c.DoApiPut(c.GetChannelMemberRoute(channelId, userId)+"/roles", MapToJson(requestBody)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UpdateChannelNotifyProps will update the notification properties on a channel for a user.
-func (c *Client4) UpdateChannelNotifyProps(channelId, userId string, props map[string]string) (bool, *Response) {
- if r, err := c.DoApiPut(c.GetChannelMemberRoute(channelId, userId)+"/notify_props", MapToJson(props)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// AddChannelMember adds user to channel and return a channel member.
-func (c *Client4) AddChannelMember(channelId, userId string) (*ChannelMember, *Response) {
- requestBody := map[string]string{"user_id": userId}
- if r, err := c.DoApiPost(c.GetChannelMembersRoute(channelId)+"", MapToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AddChannelMemberWithRootId adds user to channel and return a channel member. Post add to channel message has the postRootId.
-func (c *Client4) AddChannelMemberWithRootId(channelId, userId, postRootId string) (*ChannelMember, *Response) {
- requestBody := map[string]string{"user_id": userId, "post_root_id": postRootId}
- if r, err := c.DoApiPost(c.GetChannelMembersRoute(channelId)+"", MapToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ChannelMemberFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RemoveUserFromChannel will delete the channel member object for a user, effectively removing the user from a channel.
-func (c *Client4) RemoveUserFromChannel(channelId, userId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetChannelMemberRoute(channelId, userId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Post Section
-
-// CreatePost creates a post based on the provided post struct.
-func (c *Client4) CreatePost(post *Post) (*Post, *Response) {
- if r, err := c.DoApiPost(c.GetPostsRoute(), post.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdatePost updates a post based on the provided post struct.
-func (c *Client4) UpdatePost(postId string, post *Post) (*Post, *Response) {
- if r, err := c.DoApiPut(c.GetPostRoute(postId), post.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PatchPost partially updates a post. Any missing fields are not updated.
-func (c *Client4) PatchPost(postId string, patch *PostPatch) (*Post, *Response) {
- if r, err := c.DoApiPut(c.GetPostRoute(postId)+"/patch", patch.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PinPost pin a post based on provided post id string.
-func (c *Client4) PinPost(postId string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPostRoute(postId)+"/pin", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UnpinPost unpin a post based on provided post id string.
-func (c *Client4) UnpinPost(postId string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPostRoute(postId)+"/unpin", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetPost gets a single post.
-func (c *Client4) GetPost(postId string, etag string) (*Post, *Response) {
- if r, err := c.DoApiGet(c.GetPostRoute(postId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeletePost deletes a post from the provided post id string.
-func (c *Client4) DeletePost(postId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetPostRoute(postId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetPostThread gets a post with all the other posts in the same thread.
-func (c *Client4) GetPostThread(postId string, etag string) (*PostList, *Response) {
- if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/thread", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPostsForChannel gets a page of posts with an array for ordering for a channel.
-func (c *Client4) GetPostsForChannel(channelId string, page, perPage int, etag string) (*PostList, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/posts"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetFlaggedPostsForUser returns flagged posts of a user based on user id string.
-func (c *Client4) GetFlaggedPostsForUser(userId string, page int, perPage int) (*PostList, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/posts/flagged"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetFlaggedPostsForUserInTeam returns flagged posts in team of a user based on user id string.
-func (c *Client4) GetFlaggedPostsForUserInTeam(userId string, teamId string, page int, perPage int) (*PostList, *Response) {
- if len(teamId) == 0 || len(teamId) != 26 {
- return nil, &Response{StatusCode: http.StatusBadRequest, Error: NewAppError("GetFlaggedPostsForUserInTeam", "model.client.get_flagged_posts_in_team.missing_parameter.app_error", nil, "", http.StatusBadRequest)}
- }
-
- query := fmt.Sprintf("?team_id=%v&page=%v&per_page=%v", teamId, page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/posts/flagged"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetFlaggedPostsForUserInChannel returns flagged posts in channel of a user based on user id string.
-func (c *Client4) GetFlaggedPostsForUserInChannel(userId string, channelId string, page int, perPage int) (*PostList, *Response) {
- if len(channelId) == 0 || len(channelId) != 26 {
- return nil, &Response{StatusCode: http.StatusBadRequest, Error: NewAppError("GetFlaggedPostsForUserInChannel", "model.client.get_flagged_posts_in_channel.missing_parameter.app_error", nil, "", http.StatusBadRequest)}
- }
-
- query := fmt.Sprintf("?channel_id=%v&page=%v&per_page=%v", channelId, page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/posts/flagged"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPostsSince gets posts created after a specified time as Unix time in milliseconds.
-func (c *Client4) GetPostsSince(channelId string, time int64) (*PostList, *Response) {
- query := fmt.Sprintf("?since=%v", time)
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/posts"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPostsAfter gets a page of posts that were posted after the post provided.
-func (c *Client4) GetPostsAfter(channelId, postId string, page, perPage int, etag string) (*PostList, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v&after=%v", page, perPage, postId)
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/posts"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetPostsBefore gets a page of posts that were posted before the post provided.
-func (c *Client4) GetPostsBefore(channelId, postId string, page, perPage int, etag string) (*PostList, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v&before=%v", page, perPage, postId)
- if r, err := c.DoApiGet(c.GetChannelRoute(channelId)+"/posts"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SearchPosts returns any posts with matching terms string.
-func (c *Client4) SearchPosts(teamId string, terms string, isOrSearch bool) (*PostList, *Response) {
- requestBody := map[string]interface{}{"terms": terms, "is_or_search": isOrSearch}
- if r, err := c.DoApiPost(c.GetTeamRoute(teamId)+"/posts/search", StringInterfaceToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PostListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DoPostAction performs a post action.
-func (c *Client4) DoPostAction(postId, actionId string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPostRoute(postId)+"/actions/"+actionId, ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// File Section
-
-// UploadFile will upload a file to a channel, to be later attached to a post.
-func (c *Client4) UploadFile(data []byte, channelId string, filename string) (*FileUploadResponse, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("files", filename); err != nil {
- return nil, &Response{Error: NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return nil, &Response{Error: NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if part, err := writer.CreateFormField("channel_id"); err != nil {
- return nil, &Response{Error: NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, strings.NewReader(channelId)); err != nil {
- return nil, &Response{Error: NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if err := writer.Close(); err != nil {
- return nil, &Response{Error: NewAppError("UploadPostAttachment", "model.client.upload_post_attachment.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- return c.DoUploadFile(c.GetFilesRoute(), body.Bytes(), writer.FormDataContentType())
-}
-
-// GetFile gets the bytes for a file by id.
-func (c *Client4) GetFile(fileId string) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetFile", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// DownloadFile gets the bytes for a file by id, optionally adding headers to force the browser to download it
-func (c *Client4) DownloadFile(fileId string, download bool) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+fmt.Sprintf("?download=%v", download), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("DownloadFile", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// GetFileThumbnail gets the bytes for a file by id.
-func (c *Client4) GetFileThumbnail(fileId string) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/thumbnail", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetFileThumbnail", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// DownloadFileThumbnail gets the bytes for a file by id, optionally adding headers to force the browser to download it.
-func (c *Client4) DownloadFileThumbnail(fileId string, download bool) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+fmt.Sprintf("/thumbnail?download=%v", download), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("DownloadFileThumbnail", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// GetFileLink gets the public link of a file by id.
-func (c *Client4) GetFileLink(fileId string) (string, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/link", ""); err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- return MapFromJson(r.Body)["link"], BuildResponse(r)
- }
-}
-
-// GetFilePreview gets the bytes for a file by id.
-func (c *Client4) GetFilePreview(fileId string) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/preview", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetFilePreview", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// DownloadFilePreview gets the bytes for a file by id.
-func (c *Client4) DownloadFilePreview(fileId string, download bool) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+fmt.Sprintf("/preview?download=%v", download), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("DownloadFilePreview", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// GetFileInfo gets all the file info objects.
-func (c *Client4) GetFileInfo(fileId string) (*FileInfo, *Response) {
- if r, err := c.DoApiGet(c.GetFileRoute(fileId)+"/info", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return FileInfoFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetFileInfosForPost gets all the file info objects attached to a post.
-func (c *Client4) GetFileInfosForPost(postId string, etag string) ([]*FileInfo, *Response) {
- if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/files/info", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return FileInfosFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// General/System Section
-
-// GetPing will return ok if the running goRoutines are below the threshold and unhealthy for above.
-func (c *Client4) GetPing() (string, *Response) {
- if r, err := c.DoApiGet(c.GetSystemRoute()+"/ping", ""); r != nil && r.StatusCode == 500 {
- defer r.Body.Close()
- return "unhealthy", BuildErrorResponse(r, err)
- } else if err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body)["status"], BuildResponse(r)
- }
-}
-
-// TestEmail will attempt to connect to the configured SMTP server.
-func (c *Client4) TestEmail() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetTestEmailRoute(), ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetConfig will retrieve the server config with some sanitized items.
-func (c *Client4) GetConfig() (*Config, *Response) {
- if r, err := c.DoApiGet(c.GetConfigRoute(), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ConfigFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ReloadConfig will reload the server configuration.
-func (c *Client4) ReloadConfig() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetConfigRoute()+"/reload", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetOldClientConfig will retrieve the parts of the server configuration needed by the
-// client, formatted in the old format.
-func (c *Client4) GetOldClientConfig(etag string) (map[string]string, *Response) {
- if r, err := c.DoApiGet(c.GetConfigRoute()+"/client?format=old", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOldClientLicense will retrieve the parts of the server license needed by the
-// client, formatted in the old format.
-func (c *Client4) GetOldClientLicense(etag string) (map[string]string, *Response) {
- if r, err := c.DoApiGet(c.GetLicenseRoute()+"/client?format=old", etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DatabaseRecycle will recycle the connections. Discard current connection and get new one.
-func (c *Client4) DatabaseRecycle() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetDatabaseRoute()+"/recycle", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// InvalidateCaches will purge the cache and can affect the performance while is cleaning.
-func (c *Client4) InvalidateCaches() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetCacheRoute()+"/invalidate", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// UpdateConfig will update the server configuration.
-func (c *Client4) UpdateConfig(config *Config) (*Config, *Response) {
- if r, err := c.DoApiPut(c.GetConfigRoute(), config.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ConfigFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UploadLicenseFile will add a license file to the system.
-func (c *Client4) UploadLicenseFile(data []byte) (bool, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("license", "test-license.mattermost-license"); err != nil {
- return false, &Response{Error: NewAppError("UploadLicenseFile", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return false, &Response{Error: NewAppError("UploadLicenseFile", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if err := writer.Close(); err != nil {
- return false, &Response{Error: NewAppError("UploadLicenseFile", "model.client.set_profile_user.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetLicenseRoute(), bytes.NewReader(body.Bytes()))
- rq.Header.Set("Content-Type", writer.FormDataContentType())
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetLicenseRoute(), "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return false, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return CheckStatusOK(rp), BuildResponse(rp)
- }
- }
-}
-
-// RemoveLicenseFile will remove the server license it exists. Note that this will
-// disable all enterprise features.
-func (c *Client4) RemoveLicenseFile() (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetLicenseRoute()); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetAnalyticsOld will retrieve analytics using the old format. New format is not
-// available but the "/analytics" endpoint is reserved for it. The "name" argument is optional
-// and defaults to "standard". The "teamId" argument is optional and will limit results
-// to a specific team.
-func (c *Client4) GetAnalyticsOld(name, teamId string) (AnalyticsRows, *Response) {
- query := fmt.Sprintf("?name=%v&teamId=%v", name, teamId)
- if r, err := c.DoApiGet(c.GetAnalyticsRoute()+"/old"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return AnalyticsRowsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Webhooks Section
-
-// CreateIncomingWebhook creates an incoming webhook for a channel.
-func (c *Client4) CreateIncomingWebhook(hook *IncomingWebhook) (*IncomingWebhook, *Response) {
- if r, err := c.DoApiPost(c.GetIncomingWebhooksRoute(), hook.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return IncomingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateIncomingWebhook updates an incoming webhook for a channel.
-func (c *Client4) UpdateIncomingWebhook(hook *IncomingWebhook) (*IncomingWebhook, *Response) {
- if r, err := c.DoApiPut(c.GetIncomingWebhookRoute(hook.Id), hook.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return IncomingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetIncomingWebhooks returns a page of incoming webhooks on the system. Page counting starts at 0.
-func (c *Client4) GetIncomingWebhooks(page int, perPage int, etag string) ([]*IncomingWebhook, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetIncomingWebhooksRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return IncomingWebhookListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetIncomingWebhooksForTeam returns a page of incoming webhooks for a team. Page counting starts at 0.
-func (c *Client4) GetIncomingWebhooksForTeam(teamId string, page int, perPage int, etag string) ([]*IncomingWebhook, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v&team_id=%v", page, perPage, teamId)
- if r, err := c.DoApiGet(c.GetIncomingWebhooksRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return IncomingWebhookListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetIncomingWebhook returns an Incoming webhook given the hook ID
-func (c *Client4) GetIncomingWebhook(hookID string, etag string) (*IncomingWebhook, *Response) {
- if r, err := c.DoApiGet(c.GetIncomingWebhookRoute(hookID), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return IncomingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteIncomingWebhook deletes and Incoming Webhook given the hook ID
-func (c *Client4) DeleteIncomingWebhook(hookID string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetIncomingWebhookRoute(hookID)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// CreateOutgoingWebhook creates an outgoing webhook for a team or channel.
-func (c *Client4) CreateOutgoingWebhook(hook *OutgoingWebhook) (*OutgoingWebhook, *Response) {
- if r, err := c.DoApiPost(c.GetOutgoingWebhooksRoute(), hook.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateOutgoingWebhook creates an outgoing webhook for a team or channel.
-func (c *Client4) UpdateOutgoingWebhook(hook *OutgoingWebhook) (*OutgoingWebhook, *Response) {
- if r, err := c.DoApiPut(c.GetOutgoingWebhookRoute(hook.Id), hook.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOutgoingWebhooks returns a page of outgoing webhooks on the system. Page counting starts at 0.
-func (c *Client4) GetOutgoingWebhooks(page int, perPage int, etag string) ([]*OutgoingWebhook, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetOutgoingWebhooksRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOutgoingWebhook outgoing webhooks on the system requested by Hook Id.
-func (c *Client4) GetOutgoingWebhook(hookId string) (*OutgoingWebhook, *Response) {
- if r, err := c.DoApiGet(c.GetOutgoingWebhookRoute(hookId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOutgoingWebhooksForChannel returns a page of outgoing webhooks for a channel. Page counting starts at 0.
-func (c *Client4) GetOutgoingWebhooksForChannel(channelId string, page int, perPage int, etag string) ([]*OutgoingWebhook, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v&channel_id=%v", page, perPage, channelId)
- if r, err := c.DoApiGet(c.GetOutgoingWebhooksRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOutgoingWebhooksForTeam returns a page of outgoing webhooks for a team. Page counting starts at 0.
-func (c *Client4) GetOutgoingWebhooksForTeam(teamId string, page int, perPage int, etag string) ([]*OutgoingWebhook, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v&team_id=%v", page, perPage, teamId)
- if r, err := c.DoApiGet(c.GetOutgoingWebhooksRoute()+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RegenOutgoingHookToken regenerate the outgoing webhook token.
-func (c *Client4) RegenOutgoingHookToken(hookId string) (*OutgoingWebhook, *Response) {
- if r, err := c.DoApiPost(c.GetOutgoingWebhookRoute(hookId)+"/regen_token", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OutgoingWebhookFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteOutgoingWebhook delete the outgoing webhook on the system requested by Hook Id.
-func (c *Client4) DeleteOutgoingWebhook(hookId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetOutgoingWebhookRoute(hookId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Preferences Section
-
-// GetPreferences returns the user's preferences.
-func (c *Client4) GetPreferences(userId string) (Preferences, *Response) {
- if r, err := c.DoApiGet(c.GetPreferencesRoute(userId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- preferences, _ := PreferencesFromJson(r.Body)
- defer closeBody(r)
- return preferences, BuildResponse(r)
- }
-}
-
-// UpdatePreferences saves the user's preferences.
-func (c *Client4) UpdatePreferences(userId string, preferences *Preferences) (bool, *Response) {
- if r, err := c.DoApiPut(c.GetPreferencesRoute(userId), preferences.ToJson()); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return true, BuildResponse(r)
- }
-}
-
-// DeletePreferences deletes the user's preferences.
-func (c *Client4) DeletePreferences(userId string, preferences *Preferences) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPreferencesRoute(userId)+"/delete", preferences.ToJson()); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return true, BuildResponse(r)
- }
-}
-
-// GetPreferencesByCategory returns the user's preferences from the provided category string.
-func (c *Client4) GetPreferencesByCategory(userId string, category string) (Preferences, *Response) {
- url := fmt.Sprintf(c.GetPreferencesRoute(userId)+"/%s", category)
- if r, err := c.DoApiGet(url, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- preferences, _ := PreferencesFromJson(r.Body)
- defer closeBody(r)
- return preferences, BuildResponse(r)
- }
-}
-
-// GetPreferenceByCategoryAndName returns the user's preferences from the provided category and preference name string.
-func (c *Client4) GetPreferenceByCategoryAndName(userId string, category string, preferenceName string) (*Preference, *Response) {
- url := fmt.Sprintf(c.GetPreferencesRoute(userId)+"/%s/name/%v", category, preferenceName)
- if r, err := c.DoApiGet(url, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PreferenceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// SAML Section
-
-// GetSamlMetadata returns metadata for the SAML configuration.
-func (c *Client4) GetSamlMetadata() (string, *Response) {
- if r, err := c.DoApiGet(c.GetSamlRoute()+"/metadata", ""); err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- buf := new(bytes.Buffer)
- buf.ReadFrom(r.Body)
- return buf.String(), BuildResponse(r)
- }
-}
-
-func samlFileToMultipart(data []byte, filename string) ([]byte, *multipart.Writer, error) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("certificate", filename); err != nil {
- return nil, nil, err
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return nil, nil, err
- }
-
- if err := writer.Close(); err != nil {
- return nil, nil, err
- }
-
- return body.Bytes(), writer, nil
-}
-
-// UploadSamlIdpCertificate will upload an IDP certificate for SAML and set the config to use it.
-func (c *Client4) UploadSamlIdpCertificate(data []byte, filename string) (bool, *Response) {
- body, writer, err := samlFileToMultipart(data, filename)
- if err != nil {
- return false, &Response{Error: NewAppError("UploadSamlIdpCertificate", "model.client.upload_saml_cert.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- _, resp := c.DoUploadFile(c.GetSamlRoute()+"/certificate/idp", body, writer.FormDataContentType())
- return resp.Error == nil, resp
-}
-
-// UploadSamlPublicCertificate will upload a public certificate for SAML and set the config to use it.
-func (c *Client4) UploadSamlPublicCertificate(data []byte, filename string) (bool, *Response) {
- body, writer, err := samlFileToMultipart(data, filename)
- if err != nil {
- return false, &Response{Error: NewAppError("UploadSamlPublicCertificate", "model.client.upload_saml_cert.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- _, resp := c.DoUploadFile(c.GetSamlRoute()+"/certificate/public", body, writer.FormDataContentType())
- return resp.Error == nil, resp
-}
-
-// UploadSamlPrivateCertificate will upload a private key for SAML and set the config to use it.
-func (c *Client4) UploadSamlPrivateCertificate(data []byte, filename string) (bool, *Response) {
- body, writer, err := samlFileToMultipart(data, filename)
- if err != nil {
- return false, &Response{Error: NewAppError("UploadSamlPrivateCertificate", "model.client.upload_saml_cert.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- _, resp := c.DoUploadFile(c.GetSamlRoute()+"/certificate/private", body, writer.FormDataContentType())
- return resp.Error == nil, resp
-}
-
-// DeleteSamlIdpCertificate deletes the SAML IDP certificate from the server and updates the config to not use it and disable SAML.
-func (c *Client4) DeleteSamlIdpCertificate() (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetSamlRoute() + "/certificate/idp"); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// DeleteSamlPublicCertificate deletes the SAML IDP certificate from the server and updates the config to not use it and disable SAML.
-func (c *Client4) DeleteSamlPublicCertificate() (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetSamlRoute() + "/certificate/public"); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// DeleteSamlPrivateCertificate deletes the SAML IDP certificate from the server and updates the config to not use it and disable SAML.
-func (c *Client4) DeleteSamlPrivateCertificate() (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetSamlRoute() + "/certificate/private"); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetSamlCertificateStatus returns metadata for the SAML configuration.
-func (c *Client4) GetSamlCertificateStatus() (*SamlCertificateStatus, *Response) {
- if r, err := c.DoApiGet(c.GetSamlRoute()+"/certificate/status", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return SamlCertificateStatusFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Compliance Section
-
-// CreateComplianceReport creates an incoming webhook for a channel.
-func (c *Client4) CreateComplianceReport(report *Compliance) (*Compliance, *Response) {
- if r, err := c.DoApiPost(c.GetComplianceReportsRoute(), report.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ComplianceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetComplianceReports returns list of compliance reports.
-func (c *Client4) GetComplianceReports(page, perPage int) (Compliances, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetComplianceReportsRoute()+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CompliancesFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetComplianceReport returns a compliance report.
-func (c *Client4) GetComplianceReport(reportId string) (*Compliance, *Response) {
- if r, err := c.DoApiGet(c.GetComplianceReportRoute(reportId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ComplianceFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DownloadComplianceReport returns a full compliance report as a file.
-func (c *Client4) DownloadComplianceReport(reportId string) ([]byte, *Response) {
- var rq *http.Request
- rq, _ = http.NewRequest("GET", c.ApiUrl+c.GetComplianceReportRoute(reportId), nil)
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, "BEARER "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, &Response{Error: NewAppError("DownloadComplianceReport", "model.client.connecting.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return nil, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else if data, err := ioutil.ReadAll(rp.Body); err != nil {
- return nil, BuildErrorResponse(rp, NewAppError("DownloadComplianceReport", "model.client.read_file.app_error", nil, err.Error(), rp.StatusCode))
- } else {
- return data, BuildResponse(rp)
- }
- }
-}
-
-// Cluster Section
-
-// GetClusterStatus returns the status of all the configured cluster nodes.
-func (c *Client4) GetClusterStatus() ([]*ClusterInfo, *Response) {
- if r, err := c.DoApiGet(c.GetClusterRoute()+"/status", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ClusterInfosFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// LDAP Section
-
-// SyncLdap will force a sync with the configured LDAP server.
-func (c *Client4) SyncLdap() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetLdapRoute()+"/sync", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// TestLdap will attempt to connect to the configured LDAP server and return OK if configured
-// correctly.
-func (c *Client4) TestLdap() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetLdapRoute()+"/test", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Audits Section
-
-// GetAudits returns a list of audits for the whole system.
-func (c *Client4) GetAudits(page int, perPage int, etag string) (Audits, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet("/audits"+query, etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return AuditsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Brand Section
-
-// GetBrandImage retrieves the previously uploaded brand image.
-func (c *Client4) GetBrandImage() ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetBrandRoute()+"/image", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if r.StatusCode >= 300 {
- return nil, BuildErrorResponse(r, AppErrorFromJson(r.Body))
- } else if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetBrandImage", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// UploadBrandImage sets the brand image for the system.
-func (c *Client4) UploadBrandImage(data []byte) (bool, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("image", "brand.png"); err != nil {
- return false, &Response{Error: NewAppError("UploadBrandImage", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(data)); err != nil {
- return false, &Response{Error: NewAppError("UploadBrandImage", "model.client.set_profile_user.no_file.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- if err := writer.Close(); err != nil {
- return false, &Response{Error: NewAppError("UploadBrandImage", "model.client.set_profile_user.writer.app_error", nil, err.Error(), http.StatusBadRequest)}
- }
-
- rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetBrandRoute()+"/image", bytes.NewReader(body.Bytes()))
- rq.Header.Set("Content-Type", writer.FormDataContentType())
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return false, &Response{StatusCode: http.StatusForbidden, Error: NewAppError(c.GetBrandRoute()+"/image", "model.client.connecting.app_error", nil, err.Error(), http.StatusForbidden)}
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return false, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return CheckStatusOK(rp), BuildResponse(rp)
- }
- }
-}
-
-// Logs Section
-
-// GetLogs page of logs as a string array.
-func (c *Client4) GetLogs(page, perPage int) ([]string, *Response) {
- query := fmt.Sprintf("?page=%v&logs_per_page=%v", page, perPage)
- if r, err := c.DoApiGet("/logs"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ArrayFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// PostLog is a convenience Web Service call so clients can log messages into
-// the server-side logs. For example we typically log javascript error messages
-// into the server-side. It returns the log message if the logging was successful.
-func (c *Client4) PostLog(message map[string]string) (map[string]string, *Response) {
- if r, err := c.DoApiPost("/logs", MapToJson(message)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// OAuth Section
-
-// CreateOAuthApp will register a new OAuth 2.0 client application with Mattermost acting as an OAuth 2.0 service provider.
-func (c *Client4) CreateOAuthApp(app *OAuthApp) (*OAuthApp, *Response) {
- if r, err := c.DoApiPost(c.GetOAuthAppsRoute(), app.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateOAuthApp
-func (c *Client4) UpdateOAuthApp(app *OAuthApp) (*OAuthApp, *Response) {
- if r, err := c.DoApiPut(c.GetOAuthAppRoute(app.Id), app.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOAuthApps gets a page of registered OAuth 2.0 client applications with Mattermost acting as an OAuth 2.0 service provider.
-func (c *Client4) GetOAuthApps(page, perPage int) ([]*OAuthApp, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetOAuthAppsRoute()+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOAuthApp gets a registered OAuth 2.0 client application with Mattermost acting as an OAuth 2.0 service provider.
-func (c *Client4) GetOAuthApp(appId string) (*OAuthApp, *Response) {
- if r, err := c.DoApiGet(c.GetOAuthAppRoute(appId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetOAuthAppInfo gets a sanitized version of a registered OAuth 2.0 client application with Mattermost acting as an OAuth 2.0 service provider.
-func (c *Client4) GetOAuthAppInfo(appId string) (*OAuthApp, *Response) {
- if r, err := c.DoApiGet(c.GetOAuthAppRoute(appId)+"/info", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteOAuthApp deletes a registered OAuth 2.0 client application.
-func (c *Client4) DeleteOAuthApp(appId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetOAuthAppRoute(appId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// RegenerateOAuthAppSecret regenerates the client secret for a registered OAuth 2.0 client application.
-func (c *Client4) RegenerateOAuthAppSecret(appId string) (*OAuthApp, *Response) {
- if r, err := c.DoApiPost(c.GetOAuthAppRoute(appId)+"/regen_secret", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetAuthorizedOAuthAppsForUser gets a page of OAuth 2.0 client applications the user has authorized to use access their account.
-func (c *Client4) GetAuthorizedOAuthAppsForUser(userId string, page, perPage int) ([]*OAuthApp, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetUserRoute(userId)+"/oauth/apps/authorized"+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return OAuthAppListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// AuthorizeOAuthApp will authorize an OAuth 2.0 client application to access a user's account and provide a redirect link to follow.
-func (c *Client4) AuthorizeOAuthApp(authRequest *AuthorizeRequest) (string, *Response) {
- if r, err := c.DoApiRequest(http.MethodPost, c.Url+"/oauth/authorize", authRequest.ToJson(), ""); err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body)["redirect"], BuildResponse(r)
- }
-}
-
-// DeauthorizeOAuthApp will deauthorize an OAuth 2.0 client application from accessing a user's account.
-func (c *Client4) DeauthorizeOAuthApp(appId string) (bool, *Response) {
- requestData := map[string]string{"client_id": appId}
- if r, err := c.DoApiRequest(http.MethodPost, c.Url+"/oauth/deauthorize", MapToJson(requestData), ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Elasticsearch Section
-
-// TestElasticsearch will attempt to connect to the configured Elasticsearch server and return OK if configured
-// correctly.
-func (c *Client4) TestElasticsearch() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetElasticsearchRoute()+"/test", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// PurgeElasticsearchIndexes immediately deletes all Elasticsearch indexes.
-func (c *Client4) PurgeElasticsearchIndexes() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetElasticsearchRoute()+"/purge_indexes", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Data Retention Section
-
-// GetDataRetentionPolicy will get the current server data retention policy details.
-func (c *Client4) GetDataRetentionPolicy() (*DataRetentionPolicy, *Response) {
- if r, err := c.DoApiGet(c.GetDataRetentionRoute()+"/policy", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return DataRetentionPolicyFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Commands Section
-
-// CreateCommand will create a new command if the user have the right permissions.
-func (c *Client4) CreateCommand(cmd *Command) (*Command, *Response) {
- if r, err := c.DoApiPost(c.GetCommandsRoute(), cmd.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateCommand updates a command based on the provided Command struct
-func (c *Client4) UpdateCommand(cmd *Command) (*Command, *Response) {
- if r, err := c.DoApiPut(c.GetCommandRoute(cmd.Id), cmd.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteCommand deletes a command based on the provided command id string
-func (c *Client4) DeleteCommand(commandId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetCommandRoute(commandId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// ListCommands will retrieve a list of commands available in the team.
-func (c *Client4) ListCommands(teamId string, customOnly bool) ([]*Command, *Response) {
- query := fmt.Sprintf("?team_id=%v&custom_only=%v", teamId, customOnly)
- if r, err := c.DoApiGet(c.GetCommandsRoute()+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ExecuteCommand executes a given slash command.
-func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, *Response) {
- commandArgs := &CommandArgs{
- ChannelId: channelId,
- Command: command,
- }
- if r, err := c.DoApiPost(c.GetCommandsRoute()+"/execute", commandArgs.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandResponseFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ExecuteCommand executes a given slash command against the specified team
-// Use this when executing slash commands in a DM/GM, since the team id cannot be inferred in that case
-func (c *Client4) ExecuteCommandWithTeam(channelId, teamId, command string) (*CommandResponse, *Response) {
- commandArgs := &CommandArgs{
- ChannelId: channelId,
- TeamId: teamId,
- Command: command,
- }
- if r, err := c.DoApiPost(c.GetCommandsRoute()+"/execute", commandArgs.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandResponseFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ListCommands will retrieve a list of commands available in the team.
-func (c *Client4) ListAutocompleteCommands(teamId string) ([]*Command, *Response) {
- if r, err := c.DoApiGet(c.GetTeamAutoCompleteCommandsRoute(teamId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CommandListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RegenCommandToken will create a new token if the user have the right permissions.
-func (c *Client4) RegenCommandToken(commandId string) (string, *Response) {
- if r, err := c.DoApiPut(c.GetCommandRoute(commandId)+"/regen_token", ""); err != nil {
- return "", BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body)["token"], BuildResponse(r)
- }
-}
-
-// Status Section
-
-// GetUserStatus returns a user based on the provided user id string.
-func (c *Client4) GetUserStatus(userId, etag string) (*Status, *Response) {
- if r, err := c.DoApiGet(c.GetUserStatusRoute(userId), etag); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return StatusFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetUsersStatusesByIds returns a list of users status based on the provided user ids.
-func (c *Client4) GetUsersStatusesByIds(userIds []string) ([]*Status, *Response) {
- if r, err := c.DoApiPost(c.GetUserStatusesRoute()+"/ids", ArrayToJson(userIds)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return StatusListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// UpdateUserStatus sets a user's status based on the provided user id string.
-func (c *Client4) UpdateUserStatus(userId string, userStatus *Status) (*Status, *Response) {
- if r, err := c.DoApiPut(c.GetUserStatusRoute(userId), userStatus.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return StatusFromJson(r.Body), BuildResponse(r)
-
- }
-}
-
-// Webrtc Section
-
-// GetWebrtcToken returns a valid token, stun server and turn server with credentials to
-// use with the Mattermost WebRTC service.
-func (c *Client4) GetWebrtcToken() (*WebrtcInfoResponse, *Response) {
- if r, err := c.DoApiGet("/webrtc/token", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return WebrtcInfoResponseFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Emoji Section
-
-// CreateEmoji will save an emoji to the server if the current user has permission
-// to do so. If successful, the provided emoji will be returned with its Id field
-// filled in. Otherwise, an error will be returned.
-func (c *Client4) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoji, *Response) {
- body := &bytes.Buffer{}
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("image", filename); err != nil {
- return nil, &Response{StatusCode: http.StatusForbidden, Error: NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)}
- } else if _, err = io.Copy(part, bytes.NewBuffer(image)); err != nil {
- return nil, &Response{StatusCode: http.StatusForbidden, Error: NewAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error(), 0)}
- }
-
- if err := writer.WriteField("emoji", emoji.ToJson()); err != nil {
- return nil, &Response{StatusCode: http.StatusForbidden, Error: NewAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error(), 0)}
- }
-
- if err := writer.Close(); err != nil {
- return nil, &Response{StatusCode: http.StatusForbidden, Error: NewAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error(), 0)}
- }
-
- return c.DoEmojiUploadFile(c.GetEmojisRoute(), body.Bytes(), writer.FormDataContentType())
-}
-
-// GetEmojiList returns a page of custom emoji on the system.
-func (c *Client4) GetEmojiList(page, perPage int) ([]*Emoji, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
- if r, err := c.DoApiGet(c.GetEmojisRoute()+query, ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return EmojiListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteEmoji delete an custom emoji on the provided emoji id string.
-func (c *Client4) DeleteEmoji(emojiId string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetEmojiRoute(emojiId)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetEmoji returns a custom emoji in the system on the provided emoji id string.
-func (c *Client4) GetEmoji(emojiId string) (*Emoji, *Response) {
- if r, err := c.DoApiGet(c.GetEmojiRoute(emojiId), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return EmojiFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetEmojiImage returns the emoji image.
-func (c *Client4) GetEmojiImage(emojiId string) ([]byte, *Response) {
- if r, err := c.DoApiGet(c.GetEmojiRoute(emojiId)+"/image", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
-
- if data, err := ioutil.ReadAll(r.Body); err != nil {
- return nil, BuildErrorResponse(r, NewAppError("GetEmojiImage", "model.client.read_file.app_error", nil, err.Error(), r.StatusCode))
- } else {
- return data, BuildResponse(r)
- }
- }
-}
-
-// Reaction Section
-
-// SaveReaction saves an emoji reaction for a post. Returns the saved reaction if successful, otherwise an error will be returned.
-func (c *Client4) SaveReaction(reaction *Reaction) (*Reaction, *Response) {
- if r, err := c.DoApiPost(c.GetReactionsRoute(), reaction.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ReactionFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetReactions returns a list of reactions to a post.
-func (c *Client4) GetReactions(postId string) ([]*Reaction, *Response) {
- if r, err := c.DoApiGet(c.GetPostRoute(postId)+"/reactions", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ReactionsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// DeleteReaction deletes reaction of a user in a post.
-func (c *Client4) DeleteReaction(reaction *Reaction) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetUserRoute(reaction.UserId) + c.GetPostRoute(reaction.PostId) + fmt.Sprintf("/reactions/%v", reaction.EmojiName)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Open Graph Metadata Section
-
-// OpenGraph return the open graph metadata for a particular url if the site have the metadata
-func (c *Client4) OpenGraph(url string) (map[string]string, *Response) {
- requestBody := make(map[string]string)
- requestBody["url"] = url
-
- if r, err := c.DoApiPost(c.GetOpenGraphRoute(), MapToJson(requestBody)); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return MapFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Jobs Section
-
-// GetJob gets a single job.
-func (c *Client4) GetJob(id string) (*Job, *Response) {
- if r, err := c.DoApiGet(c.GetJobsRoute()+fmt.Sprintf("/%v", id), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return JobFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// Get all jobs, sorted with the job that was created most recently first.
-func (c *Client4) GetJobs(page int, perPage int) ([]*Job, *Response) {
- if r, err := c.DoApiGet(c.GetJobsRoute()+fmt.Sprintf("?page=%v&per_page=%v", page, perPage), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return JobsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// GetJobsByType gets all jobs of a given type, sorted with the job that was created most recently first.
-func (c *Client4) GetJobsByType(jobType string, page int, perPage int) ([]*Job, *Response) {
- if r, err := c.DoApiGet(c.GetJobsRoute()+fmt.Sprintf("/type/%v?page=%v&per_page=%v", jobType, page, perPage), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return JobsFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CreateJob creates a job based on the provided job struct.
-func (c *Client4) CreateJob(job *Job) (*Job, *Response) {
- if r, err := c.DoApiPost(c.GetJobsRoute(), job.ToJson()); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return JobFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// CancelJob requests the cancellation of the job with the provided Id.
-func (c *Client4) CancelJob(jobId string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetJobsRoute()+fmt.Sprintf("/%v/cancel", jobId), ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// Plugin Section
-
-// UploadPlugin takes an io.Reader stream pointing to the contents of a .tar.gz plugin.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) UploadPlugin(file io.Reader) (*Manifest, *Response) {
- body := new(bytes.Buffer)
- writer := multipart.NewWriter(body)
-
- if part, err := writer.CreateFormFile("plugin", "plugin.tar.gz"); err != nil {
- return nil, &Response{Error: NewAppError("UploadPlugin", "model.client.writer.app_error", nil, err.Error(), 0)}
- } else if _, err = io.Copy(part, file); err != nil {
- return nil, &Response{Error: NewAppError("UploadPlugin", "model.client.writer.app_error", nil, err.Error(), 0)}
- }
-
- if err := writer.Close(); err != nil {
- return nil, &Response{Error: NewAppError("UploadPlugin", "model.client.writer.app_error", nil, err.Error(), 0)}
- }
-
- rq, _ := http.NewRequest("POST", c.ApiUrl+c.GetPluginsRoute(), body)
- rq.Header.Set("Content-Type", writer.FormDataContentType())
- rq.Close = true
-
- if len(c.AuthToken) > 0 {
- rq.Header.Set(HEADER_AUTH, c.AuthType+" "+c.AuthToken)
- }
-
- if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, BuildErrorResponse(rp, NewAppError("UploadPlugin", "model.client.connecting.app_error", nil, err.Error(), 0))
- } else {
- defer closeBody(rp)
-
- if rp.StatusCode >= 300 {
- return nil, BuildErrorResponse(rp, AppErrorFromJson(rp.Body))
- } else {
- return ManifestFromJson(rp.Body), BuildResponse(rp)
- }
- }
-}
-
-// GetPlugins will return a list of plugin manifests for currently active plugins.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) GetPlugins() (*PluginsResponse, *Response) {
- if r, err := c.DoApiGet(c.GetPluginsRoute(), ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return PluginsResponseFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// RemovePlugin will deactivate and delete a plugin.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) RemovePlugin(id string) (bool, *Response) {
- if r, err := c.DoApiDelete(c.GetPluginRoute(id)); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// GetWebappPlugins will return a list of plugins that the webapp should download.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) GetWebappPlugins() ([]*Manifest, *Response) {
- if r, err := c.DoApiGet(c.GetPluginsRoute()+"/webapp", ""); err != nil {
- return nil, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return ManifestListFromJson(r.Body), BuildResponse(r)
- }
-}
-
-// ActivatePlugin will activate an plugin installed.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) ActivatePlugin(id string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPluginRoute(id)+"/activate", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
-
-// DeactivatePlugin will deactivate an active plugin.
-// WARNING: PLUGINS ARE STILL EXPERIMENTAL. THIS FUNCTION IS SUBJECT TO CHANGE.
-func (c *Client4) DeactivatePlugin(id string) (bool, *Response) {
- if r, err := c.DoApiPost(c.GetPluginRoute(id)+"/deactivate", ""); err != nil {
- return false, BuildErrorResponse(r, err)
- } else {
- defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/cluster_discovery.go b/vendor/github.com/mattermost/platform/model/cluster_discovery.go
deleted file mode 100644
index 89e5fc95..00000000
--- a/vendor/github.com/mattermost/platform/model/cluster_discovery.go
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "os"
-)
-
-const (
- CDS_OFFLINE_AFTER_MILLIS = 1000 * 60 * 30 // 30 minutes
- CDS_TYPE_APP = "mattermost_app"
-)
-
-type ClusterDiscovery struct {
- Id string `json:"id"`
- Type string `json:"type"`
- ClusterName string `json:"cluster_name"`
- Hostname string `json:"hostname"`
- GossipPort int32 `json:"gossip_port"`
- Port int32 `json:"port"`
- CreateAt int64 `json:"create_at"`
- LastPingAt int64 `json:"last_ping_at"`
-}
-
-func (o *ClusterDiscovery) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- if o.CreateAt == 0 {
- o.CreateAt = GetMillis()
- o.LastPingAt = o.CreateAt
- }
-}
-
-func (o *ClusterDiscovery) AutoFillHostname() {
- // attempt to set the hostname from the OS
- if len(o.Hostname) == 0 {
- if hn, err := os.Hostname(); err == nil {
- o.Hostname = hn
- }
- }
-}
-
-func (o *ClusterDiscovery) AutoFillIpAddress() {
- // attempt to set the hostname to the first non-local IP address
- if len(o.Hostname) == 0 {
- o.Hostname = GetServerIpAddress()
- }
-}
-
-func (o *ClusterDiscovery) IsEqual(in *ClusterDiscovery) bool {
- if in == nil {
- return false
- }
-
- if o.Type != in.Type {
- return false
- }
-
- if o.ClusterName != in.ClusterName {
- return false
- }
-
- if o.Hostname != in.Hostname {
- return false
- }
-
- return true
-}
-
-func FilterClusterDiscovery(vs []*ClusterDiscovery, f func(*ClusterDiscovery) bool) []*ClusterDiscovery {
- copy := make([]*ClusterDiscovery, 0)
- for _, v := range vs {
- if f(v) {
- copy = append(copy, v)
- }
- }
-
- return copy
-}
-
-func (o *ClusterDiscovery) IsValid() *AppError {
- if len(o.Id) != 26 {
- return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ClusterName) == 0 {
- return NewAppError("ClusterDiscovery.IsValid", "ClusterName must be set", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Type) == 0 {
- return NewAppError("ClusterDiscovery.IsValid", "Type must be set", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Hostname) == 0 {
- return NewAppError("ClusterDiscovery.IsValid", "Hostname must be set", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("ClusterDiscovery.IsValid", "CreateAt must be set", nil, "", http.StatusBadRequest)
- }
-
- if o.LastPingAt == 0 {
- return NewAppError("ClusterDiscovery.IsValid", "LastPingAt must be set", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *ClusterDiscovery) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- }
-
- return string(b)
-}
-
-func ClusterDiscoveryFromJson(data io.Reader) *ClusterDiscovery {
- decoder := json.NewDecoder(data)
- var me ClusterDiscovery
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/cluster_info.go b/vendor/github.com/mattermost/platform/model/cluster_info.go
deleted file mode 100644
index c4f7e89a..00000000
--- a/vendor/github.com/mattermost/platform/model/cluster_info.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "strings"
-)
-
-type ClusterInfo struct {
- Id string `json:"id"`
- Version string `json:"version"`
- ConfigHash string `json:"config_hash"`
- IpAddress string `json:"ipaddress"`
- Hostname string `json:"hostname"`
-}
-
-func (me *ClusterInfo) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (me *ClusterInfo) Copy() *ClusterInfo {
- json := me.ToJson()
- return ClusterInfoFromJson(strings.NewReader(json))
-}
-
-func ClusterInfoFromJson(data io.Reader) *ClusterInfo {
- decoder := json.NewDecoder(data)
- var me ClusterInfo
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
-
-func ClusterInfosToJson(objmap []*ClusterInfo) string {
- if b, err := json.Marshal(objmap); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ClusterInfosFromJson(data io.Reader) []*ClusterInfo {
- decoder := json.NewDecoder(data)
-
- var objmap []*ClusterInfo
- if err := decoder.Decode(&objmap); err != nil {
- return make([]*ClusterInfo, 0)
- } else {
- return objmap
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/cluster_message.go b/vendor/github.com/mattermost/platform/model/cluster_message.go
deleted file mode 100644
index a6dec2e7..00000000
--- a/vendor/github.com/mattermost/platform/model/cluster_message.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- CLUSTER_EVENT_PUBLISH = "publish"
- CLUSTER_EVENT_UPDATE_STATUS = "update_status"
- CLUSTER_EVENT_INVALIDATE_ALL_CACHES = "inv_all_caches"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_REACTIONS = "inv_reactions"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOK = "inv_webhook"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_POSTS = "inv_channel_posts"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS_NOTIFY_PROPS = "inv_channel_members_notify_props"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBERS = "inv_channel_members"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_BY_NAME = "inv_channel_name"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL = "inv_channel"
- CLUSTER_EVENT_INVALIDATE_CACHE_FOR_USER = "inv_user"
- CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_USER = "clear_session_user"
-
- CLUSTER_SEND_BEST_EFFORT = "best_effort"
- CLUSTER_SEND_RELIABLE = "reliable"
-)
-
-type ClusterMessage struct {
- Event string `json:"event"`
- SendType string `json:"-"`
- WaitForAllToSend bool `json:"-"`
- Data string `json:"data,omitempty"`
- Props map[string]string `json:"props,omitempty"`
-}
-
-func (o *ClusterMessage) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ClusterMessageFromJson(data io.Reader) *ClusterMessage {
- decoder := json.NewDecoder(data)
- var o ClusterMessage
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/cluster_stats.go b/vendor/github.com/mattermost/platform/model/cluster_stats.go
deleted file mode 100644
index 879487c6..00000000
--- a/vendor/github.com/mattermost/platform/model/cluster_stats.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type ClusterStats struct {
- Id string `json:"id"`
- TotalWebsocketConnections int `json:"total_websocket_connections"`
- TotalReadDbConnections int `json:"total_read_db_connections"`
- TotalMasterDbConnections int `json:"total_master_db_connections"`
-}
-
-func (me *ClusterStats) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ClusterStatsFromJson(data io.Reader) *ClusterStats {
- decoder := json.NewDecoder(data)
- var me ClusterStats
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/command.go b/vendor/github.com/mattermost/platform/model/command.go
deleted file mode 100644
index 69da41c1..00000000
--- a/vendor/github.com/mattermost/platform/model/command.go
+++ /dev/null
@@ -1,157 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "strings"
-)
-
-const (
- COMMAND_METHOD_POST = "P"
- COMMAND_METHOD_GET = "G"
- MIN_TRIGGER_LENGTH = 1
- MAX_TRIGGER_LENGTH = 128
-)
-
-type Command struct {
- Id string `json:"id"`
- Token string `json:"token"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- CreatorId string `json:"creator_id"`
- TeamId string `json:"team_id"`
- Trigger string `json:"trigger"`
- Method string `json:"method"`
- Username string `json:"username"`
- IconURL string `json:"icon_url"`
- AutoComplete bool `json:"auto_complete"`
- AutoCompleteDesc string `json:"auto_complete_desc"`
- AutoCompleteHint string `json:"auto_complete_hint"`
- DisplayName string `json:"display_name"`
- Description string `json:"description"`
- URL string `json:"url"`
-}
-
-func (o *Command) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func CommandFromJson(data io.Reader) *Command {
- decoder := json.NewDecoder(data)
- var o Command
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func CommandListToJson(l []*Command) string {
- b, err := json.Marshal(l)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func CommandListFromJson(data io.Reader) []*Command {
- decoder := json.NewDecoder(data)
- var o []*Command
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
-
-func (o *Command) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Token) != 26 {
- return NewAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.CreatorId) != 26 {
- return NewAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.TeamId) != 26 {
- return NewAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Trigger) < MIN_TRIGGER_LENGTH || len(o.Trigger) > MAX_TRIGGER_LENGTH || strings.Index(o.Trigger, "/") == 0 || strings.Contains(o.Trigger, " ") {
- return NewAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.URL) == 0 || len(o.URL) > 1024 {
- return NewAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !IsValidHttpUrl(o.URL) {
- return NewAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(o.Method == COMMAND_METHOD_GET || o.Method == COMMAND_METHOD_POST) {
- return NewAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.DisplayName) > 64 {
- return NewAppError("Command.IsValid", "model.command.is_valid.display_name.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Description) > 128 {
- return NewAppError("Command.IsValid", "model.command.is_valid.description.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *Command) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- if o.Token == "" {
- o.Token = NewId()
- }
-
- o.CreateAt = GetMillis()
- o.UpdateAt = o.CreateAt
-}
-
-func (o *Command) PreUpdate() {
- o.UpdateAt = GetMillis()
-}
-
-func (o *Command) Sanitize() {
- o.Token = ""
- o.CreatorId = ""
- o.Method = ""
- o.URL = ""
- o.Username = ""
- o.IconURL = ""
-}
diff --git a/vendor/github.com/mattermost/platform/model/command_args.go b/vendor/github.com/mattermost/platform/model/command_args.go
deleted file mode 100644
index 76b03a2f..00000000
--- a/vendor/github.com/mattermost/platform/model/command_args.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-
- goi18n "github.com/nicksnyder/go-i18n/i18n"
-)
-
-type CommandArgs struct {
- UserId string `json:"user_id"`
- ChannelId string `json:"channel_id"`
- TeamId string `json:"team_id"`
- RootId string `json:"root_id"`
- ParentId string `json:"parent_id"`
- Command string `json:"command"`
- SiteURL string `json:"-"`
- T goi18n.TranslateFunc `json:"-"`
- Session Session `json:"-"`
-}
-
-func (o *CommandArgs) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func CommandArgsFromJson(data io.Reader) *CommandArgs {
- decoder := json.NewDecoder(data)
- var o CommandArgs
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/command_response.go b/vendor/github.com/mattermost/platform/model/command_response.go
deleted file mode 100644
index a3a171ce..00000000
--- a/vendor/github.com/mattermost/platform/model/command_response.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "io/ioutil"
- "strings"
-)
-
-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"`
- Username string `json:"username"`
- IconURL string `json:"icon_url"`
- Type string `json:"type"`
- Props StringInterface `json:"props"`
- GotoLocation string `json:"goto_location"`
- Attachments []*SlackAttachment `json:"attachments"`
-}
-
-func (o *CommandResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func CommandResponseFromHTTPBody(contentType string, body io.Reader) *CommandResponse {
- if strings.TrimSpace(strings.Split(contentType, ";")[0]) == "application/json" {
- return CommandResponseFromJson(body)
- }
- if b, err := ioutil.ReadAll(body); err == nil {
- return CommandResponseFromPlainText(string(b))
- }
- return nil
-}
-
-func CommandResponseFromPlainText(text string) *CommandResponse {
- return &CommandResponse{
- Text: text,
- }
-}
-
-func CommandResponseFromJson(data io.Reader) *CommandResponse {
- decoder := json.NewDecoder(data)
- var o CommandResponse
-
- if err := decoder.Decode(&o); err != nil {
- return nil
- }
-
- o.Attachments = StringifySlackFieldValue(o.Attachments)
-
- return &o
-}
diff --git a/vendor/github.com/mattermost/platform/model/command_webhook.go b/vendor/github.com/mattermost/platform/model/command_webhook.go
deleted file mode 100644
index 0b00e00b..00000000
--- a/vendor/github.com/mattermost/platform/model/command_webhook.go
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "net/http"
-)
-
-type CommandWebhook struct {
- Id string
- CreateAt int64
- CommandId string
- UserId string
- ChannelId string
- RootId string
- ParentId string
- UseCount int
-}
-
-const (
- COMMAND_WEBHOOK_LIFETIME = 1000 * 60 * 30
-)
-
-func (o *CommandWebhook) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- if o.CreateAt == 0 {
- o.CreateAt = GetMillis()
- }
-}
-
-func (o *CommandWebhook) IsValid() *AppError {
- if len(o.Id) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.CommandId) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.command_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.UserId) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ChannelId) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.channel_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.RootId) != 0 && len(o.RootId) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.root_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ParentId) != 0 && len(o.ParentId) != 26 {
- return NewAppError("CommandWebhook.IsValid", "model.command_hook.parent_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/compliance.go b/vendor/github.com/mattermost/platform/model/compliance.go
deleted file mode 100644
index 3134ddba..00000000
--- a/vendor/github.com/mattermost/platform/model/compliance.go
+++ /dev/null
@@ -1,133 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "strings"
-)
-
-const (
- COMPLIANCE_STATUS_CREATED = "created"
- COMPLIANCE_STATUS_RUNNING = "running"
- COMPLIANCE_STATUS_FINISHED = "finished"
- COMPLIANCE_STATUS_FAILED = "failed"
- COMPLIANCE_STATUS_REMOVED = "removed"
-
- COMPLIANCE_TYPE_DAILY = "daily"
- COMPLIANCE_TYPE_ADHOC = "adhoc"
-)
-
-type Compliance struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UserId string `json:"user_id"`
- Status string `json:"status"`
- Count int `json:"count"`
- Desc string `json:"desc"`
- Type string `json:"type"`
- StartAt int64 `json:"start_at"`
- EndAt int64 `json:"end_at"`
- Keywords string `json:"keywords"`
- Emails string `json:"emails"`
-}
-
-type Compliances []Compliance
-
-func (o *Compliance) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (me *Compliance) PreSave() {
- if me.Id == "" {
- me.Id = NewId()
- }
-
- if me.Status == "" {
- me.Status = COMPLIANCE_STATUS_CREATED
- }
-
- me.Count = 0
- me.Emails = strings.ToLower(me.Emails)
- me.Keywords = strings.ToLower(me.Keywords)
-
- me.CreateAt = GetMillis()
-}
-
-func (me *Compliance) JobName() string {
- jobName := me.Type
- if me.Type == COMPLIANCE_TYPE_DAILY {
- jobName += "-" + me.Desc
- }
-
- jobName += "-" + me.Id
-
- return jobName
-}
-
-func (me *Compliance) IsValid() *AppError {
-
- if len(me.Id) != 26 {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if me.CreateAt == 0 {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(me.Desc) > 512 || len(me.Desc) == 0 {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.desc.app_error", nil, "", http.StatusBadRequest)
- }
-
- if me.StartAt == 0 {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.start_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if me.EndAt == 0 {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.end_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if me.EndAt <= me.StartAt {
- return NewAppError("Compliance.IsValid", "model.compliance.is_valid.start_end_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func ComplianceFromJson(data io.Reader) *Compliance {
- decoder := json.NewDecoder(data)
- var o Compliance
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o Compliances) ToJson() string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func CompliancesFromJson(data io.Reader) Compliances {
- decoder := json.NewDecoder(data)
- var o Compliances
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/compliance_post.go b/vendor/github.com/mattermost/platform/model/compliance_post.go
deleted file mode 100644
index 3751c586..00000000
--- a/vendor/github.com/mattermost/platform/model/compliance_post.go
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "regexp"
- "time"
-)
-
-type CompliancePost struct {
-
- // From Team
- TeamName string
- TeamDisplayName string
-
- // From Channel
- ChannelName string
- ChannelDisplayName string
-
- // From User
- UserUsername string
- UserEmail string
- UserNickname string
-
- // From Post
- PostId string
- PostCreateAt int64
- PostUpdateAt int64
- PostDeleteAt int64
- PostRootId string
- PostParentId string
- PostOriginalId string
- PostMessage string
- PostType string
- PostProps string
- PostHashtags string
- PostFileIds string
-}
-
-func CompliancePostHeader() []string {
- return []string{
- "TeamName",
- "TeamDisplayName",
-
- "ChannelName",
- "ChannelDisplayName",
-
- "UserUsername",
- "UserEmail",
- "UserNickname",
-
- "PostId",
- "PostCreateAt",
- "PostUpdateAt",
- "PostDeleteAt",
- "PostRootId",
- "PostParentId",
- "PostOriginalId",
- "PostMessage",
- "PostType",
- "PostProps",
- "PostHashtags",
- "PostFileIds",
- }
-}
-
-func cleanComplianceStrings(in string) string {
- if matched, _ := regexp.MatchString("^\\s*(=|\\+|\\-)", in); matched {
- return "'" + in
-
- } else {
- return in
- }
-}
-
-func (me *CompliancePost) Row() []string {
-
- postDeleteAt := ""
- if me.PostDeleteAt > 0 {
- postDeleteAt = time.Unix(0, me.PostDeleteAt*int64(1000*1000)).Format(time.RFC3339)
- }
-
- postUpdateAt := ""
- if me.PostUpdateAt != me.PostCreateAt {
- postUpdateAt = time.Unix(0, me.PostUpdateAt*int64(1000*1000)).Format(time.RFC3339)
- }
-
- return []string{
- cleanComplianceStrings(me.TeamName),
- cleanComplianceStrings(me.TeamDisplayName),
-
- cleanComplianceStrings(me.ChannelName),
- cleanComplianceStrings(me.ChannelDisplayName),
-
- cleanComplianceStrings(me.UserUsername),
- cleanComplianceStrings(me.UserEmail),
- cleanComplianceStrings(me.UserNickname),
-
- me.PostId,
- time.Unix(0, me.PostCreateAt*int64(1000*1000)).Format(time.RFC3339),
- postUpdateAt,
- postDeleteAt,
-
- me.PostRootId,
- me.PostParentId,
- me.PostOriginalId,
- cleanComplianceStrings(me.PostMessage),
- me.PostType,
- me.PostProps,
- me.PostHashtags,
- me.PostFileIds,
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/config.go b/vendor/github.com/mattermost/platform/model/config.go
deleted file mode 100644
index fb34d1a0..00000000
--- a/vendor/github.com/mattermost/platform/model/config.go
+++ /dev/null
@@ -1,2168 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "net/url"
- "strings"
- "time"
-)
-
-const (
- CONN_SECURITY_NONE = ""
- CONN_SECURITY_PLAIN = "PLAIN"
- CONN_SECURITY_TLS = "TLS"
- CONN_SECURITY_STARTTLS = "STARTTLS"
-
- IMAGE_DRIVER_LOCAL = "local"
- IMAGE_DRIVER_S3 = "amazons3"
-
- DATABASE_DRIVER_MYSQL = "mysql"
- DATABASE_DRIVER_POSTGRES = "postgres"
-
- MINIO_ACCESS_KEY = "minioaccesskey"
- MINIO_SECRET_KEY = "miniosecretkey"
- MINIO_BUCKET = "mattermost-test"
-
- PASSWORD_MAXIMUM_LENGTH = 64
- PASSWORD_MINIMUM_LENGTH = 5
-
- SERVICE_GITLAB = "gitlab"
- SERVICE_GOOGLE = "google"
- SERVICE_OFFICE365 = "office365"
-
- WEBSERVER_MODE_REGULAR = "regular"
- WEBSERVER_MODE_GZIP = "gzip"
- WEBSERVER_MODE_DISABLED = "disabled"
-
- GENERIC_NO_CHANNEL_NOTIFICATION = "generic_no_channel"
- GENERIC_NOTIFICATION = "generic"
- FULL_NOTIFICATION = "full"
-
- DIRECT_MESSAGE_ANY = "any"
- DIRECT_MESSAGE_TEAM = "team"
-
- SHOW_USERNAME = "username"
- SHOW_NICKNAME_FULLNAME = "nickname_full_name"
- SHOW_FULLNAME = "full_name"
-
- PERMISSIONS_ALL = "all"
- PERMISSIONS_CHANNEL_ADMIN = "channel_admin"
- PERMISSIONS_TEAM_ADMIN = "team_admin"
- PERMISSIONS_SYSTEM_ADMIN = "system_admin"
-
- FAKE_SETTING = "********************************"
-
- RESTRICT_EMOJI_CREATION_ALL = "all"
- RESTRICT_EMOJI_CREATION_ADMIN = "admin"
- RESTRICT_EMOJI_CREATION_SYSTEM_ADMIN = "system_admin"
-
- PERMISSIONS_DELETE_POST_ALL = "all"
- PERMISSIONS_DELETE_POST_TEAM_ADMIN = "team_admin"
- PERMISSIONS_DELETE_POST_SYSTEM_ADMIN = "system_admin"
-
- ALLOW_EDIT_POST_ALWAYS = "always"
- ALLOW_EDIT_POST_NEVER = "never"
- ALLOW_EDIT_POST_TIME_LIMIT = "time_limit"
-
- EMAIL_BATCHING_BUFFER_SIZE = 256
- EMAIL_BATCHING_INTERVAL = 30
-
- EMAIL_NOTIFICATION_CONTENTS_FULL = "full"
- EMAIL_NOTIFICATION_CONTENTS_GENERIC = "generic"
-
- SITENAME_MAX_LENGTH = 30
-
- SERVICE_SETTINGS_DEFAULT_SITE_URL = ""
- SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE = ""
- SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE = ""
- SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT = 300
- SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT = 300
- SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS = 10
- SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM = ""
- SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS = ":8065"
-
- TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM = 50
- TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT = ""
- TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT = ""
- TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT = 300
-
- SQL_SETTINGS_DEFAULT_DATA_SOURCE = "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"
-
- EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION = ""
-
- SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK = "https://about.mattermost.com/default-terms/"
- SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK = "https://about.mattermost.com/default-privacy-policy/"
- SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK = "https://about.mattermost.com/default-about/"
- SUPPORT_SETTINGS_DEFAULT_HELP_LINK = "https://about.mattermost.com/default-help/"
- SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK = "https://about.mattermost.com/default-report-a-problem/"
- SUPPORT_SETTINGS_DEFAULT_ADMINISTRATORS_GUIDE_LINK = "https://about.mattermost.com/administrators-guide/"
- SUPPORT_SETTINGS_DEFAULT_TROUBLESHOOTING_FORUM_LINK = "https://about.mattermost.com/troubleshooting-forum/"
- SUPPORT_SETTINGS_DEFAULT_COMMERCIAL_SUPPORT_LINK = "https://about.mattermost.com/commercial-support/"
- SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL = "feedback@mattermost.com"
-
- LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE = ""
- LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME = ""
-
- SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE = ""
- SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE = ""
-
- NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK = "https://about.mattermost.com/downloads/"
- NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK = "https://about.mattermost.com/mattermost-android-app/"
- NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK = "https://about.mattermost.com/mattermost-ios-app/"
-
- WEBRTC_SETTINGS_DEFAULT_STUN_URI = ""
- WEBRTC_SETTINGS_DEFAULT_TURN_URI = ""
-
- ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS = 2500
-
- ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR = "#f2a93b"
- ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR = "#333333"
-
- TEAM_SETTINGS_DEFAULT_TEAM_TEXT = "default"
-
- ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL = ""
- ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME = ""
- ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD = ""
- ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_REPLICAS = 1
- ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_SHARDS = 1
- ELASTICSEARCH_SETTINGS_DEFAULT_AGGREGATE_POSTS_AFTER_DAYS = 365
- ELASTICSEARCH_SETTINGS_DEFAULT_POSTS_AGGREGATOR_JOB_START_TIME = "03:00"
- ELASTICSEARCH_SETTINGS_DEFAULT_INDEX_PREFIX = ""
- ELASTICSEARCH_SETTINGS_DEFAULT_LIVE_INDEXING_BATCH_SIZE = 1
- ELASTICSEARCH_SETTINGS_DEFAULT_BULK_INDEXING_TIME_WINDOW_SECONDS = 3600
- ELASTICSEARCH_SETTINGS_DEFAULT_REQUEST_TIMEOUT_SECONDS = 30
-
- DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS = 365
- DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS = 365
- DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME = "02:00"
-
- PLUGIN_SETTINGS_DEFAULT_DIRECTORY = "./plugins"
- PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY = "./client/plugins"
-)
-
-type ServiceSettings struct {
- SiteURL *string
- LicenseFileLocation *string
- ListenAddress *string
- ConnectionSecurity *string
- TLSCertFile *string
- TLSKeyFile *string
- UseLetsEncrypt *bool
- LetsEncryptCertificateCacheFile *string
- Forward80To443 *bool
- ReadTimeout *int
- WriteTimeout *int
- MaximumLoginAttempts *int
- GoroutineHealthThreshold *int
- GoogleDeveloperKey string
- EnableOAuthServiceProvider bool
- EnableIncomingWebhooks bool
- EnableOutgoingWebhooks bool
- EnableCommands *bool
- EnableOnlyAdminIntegrations *bool
- EnablePostUsernameOverride bool
- EnablePostIconOverride bool
- EnableAPIv3 *bool
- EnableLinkPreviews *bool
- EnableTesting bool
- EnableDeveloper *bool
- EnableSecurityFixAlert *bool
- EnableInsecureOutgoingConnections *bool
- AllowedUntrustedInternalConnections *string
- EnableMultifactorAuthentication *bool
- EnforceMultifactorAuthentication *bool
- EnableUserAccessTokens *bool
- AllowCorsFrom *string
- SessionLengthWebInDays *int
- SessionLengthMobileInDays *int
- SessionLengthSSOInDays *int
- SessionCacheInMinutes *int
- SessionIdleTimeoutInMinutes *int
- WebsocketSecurePort *int
- WebsocketPort *int
- WebserverMode *string
- EnableCustomEmoji *bool
- EnableEmojiPicker *bool
- RestrictCustomEmojiCreation *string
- RestrictPostDelete *string
- AllowEditPost *string
- PostEditTimeLimit *int
- TimeBetweenUserTypingUpdatesMilliseconds *int64
- EnablePostSearch *bool
- EnableUserTypingMessages *bool
- EnableChannelViewedMessages *bool
- EnableUserStatuses *bool
- ExperimentalEnableAuthenticationTransfer *bool
- ClusterLogTimeoutMilliseconds *int
- CloseUnusedDirectMessages *bool
- EnablePreviewFeatures *bool
- EnableTutorial *bool
-}
-
-func (s *ServiceSettings) SetDefaults() {
- if s.SiteURL == nil {
- s.SiteURL = NewString(SERVICE_SETTINGS_DEFAULT_SITE_URL)
- }
-
- if s.LicenseFileLocation == nil {
- s.LicenseFileLocation = NewString("")
- }
-
- if s.ListenAddress == nil {
- s.ListenAddress = NewString(SERVICE_SETTINGS_DEFAULT_LISTEN_AND_ADDRESS)
- }
-
- if s.EnableAPIv3 == nil {
- s.EnableAPIv3 = NewBool(true)
- }
-
- if s.EnableLinkPreviews == nil {
- s.EnableLinkPreviews = NewBool(false)
- }
-
- if s.EnableDeveloper == nil {
- s.EnableDeveloper = NewBool(false)
- }
-
- if s.EnableSecurityFixAlert == nil {
- s.EnableSecurityFixAlert = NewBool(true)
- }
-
- if s.EnableInsecureOutgoingConnections == nil {
- s.EnableInsecureOutgoingConnections = NewBool(false)
- }
-
- if s.AllowedUntrustedInternalConnections == nil {
- s.AllowedUntrustedInternalConnections = new(string)
- }
-
- if s.EnableMultifactorAuthentication == nil {
- s.EnableMultifactorAuthentication = NewBool(false)
- }
-
- if s.EnforceMultifactorAuthentication == nil {
- s.EnforceMultifactorAuthentication = NewBool(false)
- }
-
- if s.EnableUserAccessTokens == nil {
- s.EnableUserAccessTokens = NewBool(false)
- }
-
- if s.GoroutineHealthThreshold == nil {
- s.GoroutineHealthThreshold = NewInt(-1)
- }
-
- if s.ConnectionSecurity == nil {
- s.ConnectionSecurity = NewString("")
- }
-
- if s.TLSKeyFile == nil {
- s.TLSKeyFile = NewString(SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE)
- }
-
- if s.TLSCertFile == nil {
- s.TLSCertFile = NewString(SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE)
- }
-
- if s.UseLetsEncrypt == nil {
- s.UseLetsEncrypt = NewBool(false)
- }
-
- if s.LetsEncryptCertificateCacheFile == nil {
- s.LetsEncryptCertificateCacheFile = NewString("./config/letsencrypt.cache")
- }
-
- if s.ReadTimeout == nil {
- s.ReadTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT)
- }
-
- if s.WriteTimeout == nil {
- s.WriteTimeout = NewInt(SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT)
- }
-
- if s.MaximumLoginAttempts == nil {
- s.MaximumLoginAttempts = NewInt(SERVICE_SETTINGS_DEFAULT_MAX_LOGIN_ATTEMPTS)
- }
-
- if s.Forward80To443 == nil {
- s.Forward80To443 = NewBool(false)
- }
-
- if s.TimeBetweenUserTypingUpdatesMilliseconds == nil {
- s.TimeBetweenUserTypingUpdatesMilliseconds = NewInt64(5000)
- }
-
- if s.EnablePostSearch == nil {
- s.EnablePostSearch = NewBool(true)
- }
-
- if s.EnableUserTypingMessages == nil {
- s.EnableUserTypingMessages = NewBool(true)
- }
-
- if s.EnableChannelViewedMessages == nil {
- s.EnableChannelViewedMessages = NewBool(true)
- }
-
- if s.EnableUserStatuses == nil {
- s.EnableUserStatuses = NewBool(true)
- }
-
- if s.ClusterLogTimeoutMilliseconds == nil {
- s.ClusterLogTimeoutMilliseconds = NewInt(2000)
- }
-
- if s.CloseUnusedDirectMessages == nil {
- s.CloseUnusedDirectMessages = NewBool(false)
- }
-
- if s.EnableTutorial == nil {
- s.EnableTutorial = NewBool(true)
- }
-
- if s.SessionLengthWebInDays == nil {
- s.SessionLengthWebInDays = NewInt(30)
- }
-
- if s.SessionLengthMobileInDays == nil {
- s.SessionLengthMobileInDays = NewInt(30)
- }
-
- if s.SessionLengthSSOInDays == nil {
- s.SessionLengthSSOInDays = NewInt(30)
- }
-
- if s.SessionCacheInMinutes == nil {
- s.SessionCacheInMinutes = NewInt(10)
- }
-
- if s.SessionIdleTimeoutInMinutes == nil {
- s.SessionIdleTimeoutInMinutes = NewInt(0)
- }
-
- if s.EnableCommands == nil {
- s.EnableCommands = NewBool(false)
- }
-
- if s.EnableOnlyAdminIntegrations == nil {
- s.EnableOnlyAdminIntegrations = NewBool(true)
- }
-
- if s.WebsocketPort == nil {
- s.WebsocketPort = NewInt(80)
- }
-
- if s.WebsocketSecurePort == nil {
- s.WebsocketSecurePort = NewInt(443)
- }
-
- if s.AllowCorsFrom == nil {
- s.AllowCorsFrom = NewString(SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM)
- }
-
- if s.WebserverMode == nil {
- s.WebserverMode = NewString("gzip")
- } else if *s.WebserverMode == "regular" {
- *s.WebserverMode = "gzip"
- }
-
- if s.EnableCustomEmoji == nil {
- s.EnableCustomEmoji = NewBool(false)
- }
-
- if s.EnableEmojiPicker == nil {
- s.EnableEmojiPicker = NewBool(true)
- }
-
- if s.RestrictCustomEmojiCreation == nil {
- s.RestrictCustomEmojiCreation = NewString(RESTRICT_EMOJI_CREATION_ALL)
- }
-
- if s.RestrictPostDelete == nil {
- s.RestrictPostDelete = NewString(PERMISSIONS_DELETE_POST_ALL)
- }
-
- if s.AllowEditPost == nil {
- s.AllowEditPost = NewString(ALLOW_EDIT_POST_ALWAYS)
- }
-
- if s.ExperimentalEnableAuthenticationTransfer == nil {
- s.ExperimentalEnableAuthenticationTransfer = NewBool(true)
- }
-
- if s.PostEditTimeLimit == nil {
- s.PostEditTimeLimit = NewInt(300)
- }
-
- if s.EnablePreviewFeatures == nil {
- s.EnablePreviewFeatures = NewBool(true)
- }
-}
-
-type ClusterSettings struct {
- Enable *bool
- ClusterName *string
- OverrideHostname *string
- UseIpAddress *bool
- UseExperimentalGossip *bool
- ReadOnlyConfig *bool
- GossipPort *int
- StreamingPort *int
-}
-
-func (s *ClusterSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.ClusterName == nil {
- s.ClusterName = NewString("")
- }
-
- if s.OverrideHostname == nil {
- s.OverrideHostname = NewString("")
- }
-
- if s.UseIpAddress == nil {
- s.UseIpAddress = NewBool(true)
- }
-
- if s.UseExperimentalGossip == nil {
- s.UseExperimentalGossip = NewBool(false)
- }
-
- if s.ReadOnlyConfig == nil {
- s.ReadOnlyConfig = NewBool(true)
- }
-
- if s.GossipPort == nil {
- s.GossipPort = NewInt(8074)
- }
-
- if s.StreamingPort == nil {
- s.StreamingPort = NewInt(8075)
- }
-}
-
-type MetricsSettings struct {
- Enable *bool
- BlockProfileRate *int
- ListenAddress *string
-}
-
-func (s *MetricsSettings) SetDefaults() {
- if s.ListenAddress == nil {
- s.ListenAddress = NewString(":8067")
- }
-
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.BlockProfileRate == nil {
- s.BlockProfileRate = NewInt(0)
- }
-}
-
-type AnalyticsSettings struct {
- MaxUsersForStatistics *int
-}
-
-func (s *AnalyticsSettings) SetDefaults() {
- if s.MaxUsersForStatistics == nil {
- s.MaxUsersForStatistics = NewInt(ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS)
- }
-}
-
-type SSOSettings struct {
- Enable bool
- Secret string
- Id string
- Scope string
- AuthEndpoint string
- TokenEndpoint string
- UserApiEndpoint string
-}
-
-type SqlSettings struct {
- DriverName *string
- DataSource *string
- DataSourceReplicas []string
- DataSourceSearchReplicas []string
- MaxIdleConns *int
- MaxOpenConns *int
- Trace bool
- AtRestEncryptKey string
- QueryTimeout *int
-}
-
-func (s *SqlSettings) SetDefaults() {
- if s.DriverName == nil {
- s.DriverName = NewString(DATABASE_DRIVER_MYSQL)
- }
-
- if s.DataSource == nil {
- s.DataSource = NewString(SQL_SETTINGS_DEFAULT_DATA_SOURCE)
- }
-
- if len(s.AtRestEncryptKey) == 0 {
- s.AtRestEncryptKey = NewRandomString(32)
- }
-
- if s.MaxIdleConns == nil {
- s.MaxIdleConns = NewInt(20)
- }
-
- if s.MaxOpenConns == nil {
- s.MaxOpenConns = NewInt(300)
- }
-
- if s.QueryTimeout == nil {
- s.QueryTimeout = NewInt(30)
- }
-}
-
-type LogSettings struct {
- EnableConsole bool
- ConsoleLevel string
- EnableFile bool
- FileLevel string
- FileFormat string
- FileLocation string
- EnableWebhookDebugging bool
- EnableDiagnostics *bool
-}
-
-func (s *LogSettings) SetDefaults() {
- if s.EnableDiagnostics == nil {
- s.EnableDiagnostics = NewBool(true)
- }
-}
-
-type PasswordSettings struct {
- MinimumLength *int
- Lowercase *bool
- Number *bool
- Uppercase *bool
- Symbol *bool
-}
-
-func (s *PasswordSettings) SetDefaults() {
- if s.MinimumLength == nil {
- s.MinimumLength = NewInt(PASSWORD_MINIMUM_LENGTH)
- }
-
- if s.Lowercase == nil {
- s.Lowercase = NewBool(false)
- }
-
- if s.Number == nil {
- s.Number = NewBool(false)
- }
-
- if s.Uppercase == nil {
- s.Uppercase = NewBool(false)
- }
-
- if s.Symbol == nil {
- s.Symbol = NewBool(false)
- }
-}
-
-type FileSettings struct {
- EnableFileAttachments *bool
- EnableMobileUpload *bool
- EnableMobileDownload *bool
- MaxFileSize *int64
- DriverName *string
- Directory string
- EnablePublicLink bool
- PublicLinkSalt *string
- InitialFont string
- AmazonS3AccessKeyId string
- AmazonS3SecretAccessKey string
- AmazonS3Bucket string
- AmazonS3Region string
- AmazonS3Endpoint string
- AmazonS3SSL *bool
- AmazonS3SignV2 *bool
- AmazonS3SSE *bool
- AmazonS3Trace *bool
-}
-
-func (s *FileSettings) SetDefaults() {
- if s.DriverName == nil {
- s.DriverName = NewString(IMAGE_DRIVER_LOCAL)
- }
-
- if s.AmazonS3Endpoint == "" {
- // Defaults to "s3.amazonaws.com"
- s.AmazonS3Endpoint = "s3.amazonaws.com"
- }
-
- if s.AmazonS3SSL == nil {
- s.AmazonS3SSL = NewBool(true) // Secure by default.
- }
-
- if s.AmazonS3SignV2 == nil {
- s.AmazonS3SignV2 = new(bool)
- // Signature v2 is not enabled by default.
- }
-
- if s.AmazonS3SSE == nil {
- s.AmazonS3SSE = NewBool(false) // Not Encrypted by default.
- }
-
- if s.AmazonS3Trace == nil {
- s.AmazonS3Trace = NewBool(false)
- }
-
- if s.EnableFileAttachments == nil {
- s.EnableFileAttachments = NewBool(true)
- }
-
- if s.EnableMobileUpload == nil {
- s.EnableMobileUpload = NewBool(true)
- }
-
- if s.EnableMobileDownload == nil {
- s.EnableMobileDownload = NewBool(true)
- }
-
- if s.MaxFileSize == nil {
- s.MaxFileSize = NewInt64(52428800) // 50 MB
- }
-
- if s.PublicLinkSalt == nil || len(*s.PublicLinkSalt) == 0 {
- s.PublicLinkSalt = NewString(NewRandomString(32))
- }
-
- if s.InitialFont == "" {
- // Defaults to "luximbi.ttf"
- s.InitialFont = "luximbi.ttf"
- }
-
- if s.Directory == "" {
- s.Directory = "./data/"
- }
-}
-
-type EmailSettings struct {
- EnableSignUpWithEmail bool
- EnableSignInWithEmail *bool
- EnableSignInWithUsername *bool
- SendEmailNotifications bool
- UseChannelInEmailNotifications *bool
- RequireEmailVerification bool
- FeedbackName string
- FeedbackEmail string
- FeedbackOrganization *string
- EnableSMTPAuth *bool
- SMTPUsername string
- SMTPPassword string
- SMTPServer string
- SMTPPort string
- ConnectionSecurity string
- InviteSalt string
- SendPushNotifications *bool
- PushNotificationServer *string
- PushNotificationContents *string
- EnableEmailBatching *bool
- EmailBatchingBufferSize *int
- EmailBatchingInterval *int
- SkipServerCertificateVerification *bool
- EmailNotificationContentsType *string
- LoginButtonColor *string
- LoginButtonBorderColor *string
- LoginButtonTextColor *string
-}
-
-func (s *EmailSettings) SetDefaults() {
- if len(s.InviteSalt) == 0 {
- s.InviteSalt = NewRandomString(32)
- }
-
- if s.EnableSignInWithEmail == nil {
- s.EnableSignInWithEmail = NewBool(s.EnableSignUpWithEmail)
- }
-
- if s.EnableSignInWithUsername == nil {
- s.EnableSignInWithUsername = NewBool(false)
- }
-
- if s.UseChannelInEmailNotifications == nil {
- s.UseChannelInEmailNotifications = NewBool(false)
- }
-
- if s.SendPushNotifications == nil {
- s.SendPushNotifications = NewBool(false)
- }
-
- if s.PushNotificationServer == nil {
- s.PushNotificationServer = NewString("")
- }
-
- if s.PushNotificationContents == nil {
- s.PushNotificationContents = NewString(GENERIC_NOTIFICATION)
- }
-
- if s.FeedbackOrganization == nil {
- s.FeedbackOrganization = NewString(EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION)
- }
-
- if s.EnableEmailBatching == nil {
- s.EnableEmailBatching = NewBool(false)
- }
-
- if s.EmailBatchingBufferSize == nil {
- s.EmailBatchingBufferSize = NewInt(EMAIL_BATCHING_BUFFER_SIZE)
- }
-
- if s.EmailBatchingInterval == nil {
- s.EmailBatchingInterval = NewInt(EMAIL_BATCHING_INTERVAL)
- }
-
- if s.EnableSMTPAuth == nil {
- s.EnableSMTPAuth = new(bool)
- if s.ConnectionSecurity == CONN_SECURITY_NONE {
- *s.EnableSMTPAuth = false
- } else {
- *s.EnableSMTPAuth = true
- }
- }
-
- if s.ConnectionSecurity == CONN_SECURITY_PLAIN {
- s.ConnectionSecurity = CONN_SECURITY_NONE
- }
-
- if s.SkipServerCertificateVerification == nil {
- s.SkipServerCertificateVerification = NewBool(false)
- }
-
- if s.EmailNotificationContentsType == nil {
- s.EmailNotificationContentsType = NewString(EMAIL_NOTIFICATION_CONTENTS_FULL)
- }
-
- if s.LoginButtonColor == nil {
- s.LoginButtonColor = NewString("#0000")
- }
-
- if s.LoginButtonBorderColor == nil {
- s.LoginButtonBorderColor = NewString("#2389D7")
- }
-
- if s.LoginButtonTextColor == nil {
- s.LoginButtonTextColor = NewString("#2389D7")
- }
-}
-
-type RateLimitSettings struct {
- Enable *bool
- PerSec *int
- MaxBurst *int
- MemoryStoreSize *int
- VaryByRemoteAddr bool
- VaryByHeader string
-}
-
-func (s *RateLimitSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.PerSec == nil {
- s.PerSec = NewInt(10)
- }
-
- if s.MaxBurst == nil {
- s.MaxBurst = NewInt(100)
- }
-
- if s.MemoryStoreSize == nil {
- s.MemoryStoreSize = NewInt(10000)
- }
-}
-
-type PrivacySettings struct {
- ShowEmailAddress bool
- ShowFullName bool
-}
-
-type SupportSettings struct {
- TermsOfServiceLink *string
- PrivacyPolicyLink *string
- AboutLink *string
- HelpLink *string
- ReportAProblemLink *string
- SupportEmail *string
-}
-
-func (s *SupportSettings) SetDefaults() {
- if !IsSafeLink(s.TermsOfServiceLink) {
- *s.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
- }
-
- if s.TermsOfServiceLink == nil {
- s.TermsOfServiceLink = NewString(SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK)
- }
-
- if !IsSafeLink(s.PrivacyPolicyLink) {
- *s.PrivacyPolicyLink = ""
- }
-
- if s.PrivacyPolicyLink == nil {
- s.PrivacyPolicyLink = NewString(SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK)
- }
-
- if !IsSafeLink(s.AboutLink) {
- *s.AboutLink = ""
- }
-
- if s.AboutLink == nil {
- s.AboutLink = NewString(SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK)
- }
-
- if !IsSafeLink(s.HelpLink) {
- *s.HelpLink = ""
- }
-
- if s.HelpLink == nil {
- s.HelpLink = NewString(SUPPORT_SETTINGS_DEFAULT_HELP_LINK)
- }
-
- if !IsSafeLink(s.ReportAProblemLink) {
- *s.ReportAProblemLink = ""
- }
-
- if s.ReportAProblemLink == nil {
- s.ReportAProblemLink = NewString(SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK)
- }
-
- if s.SupportEmail == nil {
- s.SupportEmail = NewString(SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL)
- }
-}
-
-type AnnouncementSettings struct {
- EnableBanner *bool
- BannerText *string
- BannerColor *string
- BannerTextColor *string
- AllowBannerDismissal *bool
-}
-
-func (s *AnnouncementSettings) SetDefaults() {
- if s.EnableBanner == nil {
- s.EnableBanner = NewBool(false)
- }
-
- if s.BannerText == nil {
- s.BannerText = NewString("")
- }
-
- if s.BannerColor == nil {
- s.BannerColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR)
- }
-
- if s.BannerTextColor == nil {
- s.BannerTextColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR)
- }
-
- if s.AllowBannerDismissal == nil {
- s.AllowBannerDismissal = NewBool(true)
- }
-}
-
-type ThemeSettings struct {
- EnableThemeSelection *bool
- DefaultTheme *string
- AllowCustomThemes *bool
- AllowedThemes []string
-}
-
-func (s *ThemeSettings) SetDefaults() {
- if s.EnableThemeSelection == nil {
- s.EnableThemeSelection = NewBool(true)
- }
-
- if s.DefaultTheme == nil {
- s.DefaultTheme = NewString(TEAM_SETTINGS_DEFAULT_TEAM_TEXT)
- }
-
- if s.AllowCustomThemes == nil {
- s.AllowCustomThemes = NewBool(true)
- }
-
- if s.AllowedThemes == nil {
- s.AllowedThemes = []string{}
- }
-}
-
-type TeamSettings struct {
- SiteName string
- MaxUsersPerTeam *int
- EnableTeamCreation bool
- EnableUserCreation bool
- EnableOpenServer *bool
- RestrictCreationToDomains string
- EnableCustomBrand *bool
- CustomBrandText *string
- CustomDescriptionText *string
- RestrictDirectMessage *string
- RestrictTeamInvite *string
- RestrictPublicChannelManagement *string
- RestrictPrivateChannelManagement *string
- RestrictPublicChannelCreation *string
- RestrictPrivateChannelCreation *string
- RestrictPublicChannelDeletion *string
- RestrictPrivateChannelDeletion *string
- RestrictPrivateChannelManageMembers *string
- EnableXToLeaveChannelsFromLHS *bool
- UserStatusAwayTimeout *int64
- MaxChannelsPerTeam *int64
- MaxNotificationsPerChannel *int64
- EnableConfirmNotificationsToChannel *bool
- TeammateNameDisplay *string
- ExperimentalTownSquareIsReadOnly *bool
- ExperimentalPrimaryTeam *string
-}
-
-func (s *TeamSettings) SetDefaults() {
- if s.MaxUsersPerTeam == nil {
- s.MaxUsersPerTeam = NewInt(TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM)
- }
-
- if s.EnableCustomBrand == nil {
- s.EnableCustomBrand = NewBool(false)
- }
-
- if s.CustomBrandText == nil {
- s.CustomBrandText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT)
- }
-
- if s.CustomDescriptionText == nil {
- s.CustomDescriptionText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT)
- }
-
- if s.EnableOpenServer == nil {
- s.EnableOpenServer = NewBool(false)
- }
-
- if s.RestrictDirectMessage == nil {
- s.RestrictDirectMessage = NewString(DIRECT_MESSAGE_ANY)
- }
-
- if s.RestrictTeamInvite == nil {
- s.RestrictTeamInvite = NewString(PERMISSIONS_ALL)
- }
-
- if s.RestrictPublicChannelManagement == nil {
- s.RestrictPublicChannelManagement = NewString(PERMISSIONS_ALL)
- }
-
- if s.RestrictPrivateChannelManagement == nil {
- s.RestrictPrivateChannelManagement = NewString(PERMISSIONS_ALL)
- }
-
- if s.RestrictPublicChannelCreation == nil {
- s.RestrictPublicChannelCreation = new(string)
- // If this setting does not exist, assume migration from <3.6, so use management setting as default.
- if *s.RestrictPublicChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
- *s.RestrictPublicChannelCreation = PERMISSIONS_TEAM_ADMIN
- } else {
- *s.RestrictPublicChannelCreation = *s.RestrictPublicChannelManagement
- }
- }
-
- if s.RestrictPrivateChannelCreation == nil {
- // If this setting does not exist, assume migration from <3.6, so use management setting as default.
- if *s.RestrictPrivateChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
- s.RestrictPrivateChannelCreation = NewString(PERMISSIONS_TEAM_ADMIN)
- } else {
- s.RestrictPrivateChannelCreation = NewString(*s.RestrictPrivateChannelManagement)
- }
- }
-
- if s.RestrictPublicChannelDeletion == nil {
- // If this setting does not exist, assume migration from <3.6, so use management setting as default.
- s.RestrictPublicChannelDeletion = NewString(*s.RestrictPublicChannelManagement)
- }
-
- if s.RestrictPrivateChannelDeletion == nil {
- // If this setting does not exist, assume migration from <3.6, so use management setting as default.
- s.RestrictPrivateChannelDeletion = NewString(*s.RestrictPrivateChannelManagement)
- }
-
- if s.RestrictPrivateChannelManageMembers == nil {
- s.RestrictPrivateChannelManageMembers = NewString(PERMISSIONS_ALL)
- }
-
- if s.EnableXToLeaveChannelsFromLHS == nil {
- s.EnableXToLeaveChannelsFromLHS = NewBool(false)
- }
-
- if s.UserStatusAwayTimeout == nil {
- s.UserStatusAwayTimeout = NewInt64(TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT)
- }
-
- if s.MaxChannelsPerTeam == nil {
- s.MaxChannelsPerTeam = NewInt64(2000)
- }
-
- if s.MaxNotificationsPerChannel == nil {
- s.MaxNotificationsPerChannel = NewInt64(1000)
- }
-
- if s.EnableConfirmNotificationsToChannel == nil {
- s.EnableConfirmNotificationsToChannel = NewBool(true)
- }
-
- if s.ExperimentalTownSquareIsReadOnly == nil {
- s.ExperimentalTownSquareIsReadOnly = NewBool(false)
- }
-
- if s.ExperimentalPrimaryTeam == nil {
- s.ExperimentalPrimaryTeam = NewString("")
- }
-}
-
-type ClientRequirements struct {
- AndroidLatestVersion string
- AndroidMinVersion string
- DesktopLatestVersion string
- DesktopMinVersion string
- IosLatestVersion string
- IosMinVersion string
-}
-
-type LdapSettings struct {
- // Basic
- Enable *bool
- EnableSync *bool
- LdapServer *string
- LdapPort *int
- ConnectionSecurity *string
- BaseDN *string
- BindUsername *string
- BindPassword *string
-
- // Filtering
- UserFilter *string
-
- // User Mapping
- FirstNameAttribute *string
- LastNameAttribute *string
- EmailAttribute *string
- UsernameAttribute *string
- NicknameAttribute *string
- IdAttribute *string
- PositionAttribute *string
-
- // Syncronization
- SyncIntervalMinutes *int
-
- // Advanced
- SkipCertificateVerification *bool
- QueryTimeout *int
- MaxPageSize *int
-
- // Customization
- LoginFieldName *string
-
- LoginButtonColor *string
- LoginButtonBorderColor *string
- LoginButtonTextColor *string
-}
-
-func (s *LdapSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- // When unset should default to LDAP Enabled
- if s.EnableSync == nil {
- s.EnableSync = NewBool(*s.Enable)
- }
-
- if s.LdapServer == nil {
- s.LdapServer = NewString("")
- }
-
- if s.LdapPort == nil {
- s.LdapPort = NewInt(389)
- }
-
- if s.ConnectionSecurity == nil {
- s.ConnectionSecurity = NewString("")
- }
-
- if s.BaseDN == nil {
- s.BaseDN = NewString("")
- }
-
- if s.BindUsername == nil {
- s.BindUsername = NewString("")
- }
-
- if s.BindPassword == nil {
- s.BindPassword = NewString("")
- }
-
- if s.UserFilter == nil {
- s.UserFilter = NewString("")
- }
-
- if s.FirstNameAttribute == nil {
- s.FirstNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE)
- }
-
- if s.LastNameAttribute == nil {
- s.LastNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE)
- }
-
- if s.EmailAttribute == nil {
- s.EmailAttribute = NewString(LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE)
- }
-
- if s.UsernameAttribute == nil {
- s.UsernameAttribute = NewString(LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE)
- }
-
- if s.NicknameAttribute == nil {
- s.NicknameAttribute = NewString(LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE)
- }
-
- if s.IdAttribute == nil {
- s.IdAttribute = NewString(LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE)
- }
-
- if s.PositionAttribute == nil {
- s.PositionAttribute = NewString(LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE)
- }
-
- if s.SyncIntervalMinutes == nil {
- s.SyncIntervalMinutes = NewInt(60)
- }
-
- if s.SkipCertificateVerification == nil {
- s.SkipCertificateVerification = NewBool(false)
- }
-
- if s.QueryTimeout == nil {
- s.QueryTimeout = NewInt(60)
- }
-
- if s.MaxPageSize == nil {
- s.MaxPageSize = NewInt(0)
- }
-
- if s.LoginFieldName == nil {
- s.LoginFieldName = NewString(LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME)
- }
-
- if s.LoginButtonColor == nil {
- s.LoginButtonColor = NewString("#0000")
- }
-
- if s.LoginButtonBorderColor == nil {
- s.LoginButtonBorderColor = NewString("#2389D7")
- }
-
- if s.LoginButtonTextColor == nil {
- s.LoginButtonTextColor = NewString("#2389D7")
- }
-}
-
-type ComplianceSettings struct {
- Enable *bool
- Directory *string
- EnableDaily *bool
-}
-
-func (s *ComplianceSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.Directory == nil {
- s.Directory = NewString("./data/")
- }
-
- if s.EnableDaily == nil {
- s.EnableDaily = NewBool(false)
- }
-}
-
-type LocalizationSettings struct {
- DefaultServerLocale *string
- DefaultClientLocale *string
- AvailableLocales *string
-}
-
-func (s *LocalizationSettings) SetDefaults() {
- if s.DefaultServerLocale == nil {
- s.DefaultServerLocale = NewString(DEFAULT_LOCALE)
- }
-
- if s.DefaultClientLocale == nil {
- s.DefaultClientLocale = NewString(DEFAULT_LOCALE)
- }
-
- if s.AvailableLocales == nil {
- s.AvailableLocales = NewString("")
- }
-}
-
-type SamlSettings struct {
- // Basic
- Enable *bool
- EnableSyncWithLdap *bool
-
- Verify *bool
- Encrypt *bool
-
- IdpUrl *string
- IdpDescriptorUrl *string
- AssertionConsumerServiceURL *string
-
- IdpCertificateFile *string
- PublicCertificateFile *string
- PrivateKeyFile *string
-
- // User Mapping
- FirstNameAttribute *string
- LastNameAttribute *string
- EmailAttribute *string
- UsernameAttribute *string
- NicknameAttribute *string
- LocaleAttribute *string
- PositionAttribute *string
-
- LoginButtonText *string
-
- LoginButtonColor *string
- LoginButtonBorderColor *string
- LoginButtonTextColor *string
-}
-
-func (s *SamlSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.EnableSyncWithLdap == nil {
- s.EnableSyncWithLdap = NewBool(false)
- }
-
- if s.Verify == nil {
- s.Verify = NewBool(true)
- }
-
- if s.Encrypt == nil {
- s.Encrypt = NewBool(true)
- }
-
- if s.IdpUrl == nil {
- s.IdpUrl = NewString("")
- }
-
- if s.IdpDescriptorUrl == nil {
- s.IdpDescriptorUrl = NewString("")
- }
-
- if s.IdpCertificateFile == nil {
- s.IdpCertificateFile = NewString("")
- }
-
- if s.PublicCertificateFile == nil {
- s.PublicCertificateFile = NewString("")
- }
-
- if s.PrivateKeyFile == nil {
- s.PrivateKeyFile = NewString("")
- }
-
- if s.AssertionConsumerServiceURL == nil {
- s.AssertionConsumerServiceURL = NewString("")
- }
-
- if s.LoginButtonText == nil || *s.LoginButtonText == "" {
- s.LoginButtonText = NewString(USER_AUTH_SERVICE_SAML_TEXT)
- }
-
- if s.FirstNameAttribute == nil {
- s.FirstNameAttribute = NewString(SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE)
- }
-
- if s.LastNameAttribute == nil {
- s.LastNameAttribute = NewString(SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE)
- }
-
- if s.EmailAttribute == nil {
- s.EmailAttribute = NewString(SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE)
- }
-
- if s.UsernameAttribute == nil {
- s.UsernameAttribute = NewString(SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE)
- }
-
- if s.NicknameAttribute == nil {
- s.NicknameAttribute = NewString(SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE)
- }
-
- if s.PositionAttribute == nil {
- s.PositionAttribute = NewString(SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE)
- }
-
- if s.LocaleAttribute == nil {
- s.LocaleAttribute = NewString(SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE)
- }
-
- if s.LoginButtonColor == nil {
- s.LoginButtonColor = NewString("#34a28b")
- }
-
- if s.LoginButtonBorderColor == nil {
- s.LoginButtonBorderColor = NewString("#2389D7")
- }
-
- if s.LoginButtonTextColor == nil {
- s.LoginButtonTextColor = NewString("#ffffff")
- }
-}
-
-type NativeAppSettings struct {
- AppDownloadLink *string
- AndroidAppDownloadLink *string
- IosAppDownloadLink *string
-}
-
-func (s *NativeAppSettings) SetDefaults() {
- if s.AppDownloadLink == nil {
- s.AppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK)
- }
-
- if s.AndroidAppDownloadLink == nil {
- s.AndroidAppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK)
- }
-
- if s.IosAppDownloadLink == nil {
- s.IosAppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK)
- }
-}
-
-type WebrtcSettings struct {
- Enable *bool
- GatewayWebsocketUrl *string
- GatewayAdminUrl *string
- GatewayAdminSecret *string
- StunURI *string
- TurnURI *string
- TurnUsername *string
- TurnSharedKey *string
-}
-
-func (s *WebrtcSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(false)
- }
-
- if s.GatewayWebsocketUrl == nil {
- s.GatewayWebsocketUrl = NewString("")
- }
-
- if s.GatewayAdminUrl == nil {
- s.GatewayAdminUrl = NewString("")
- }
-
- if s.GatewayAdminSecret == nil {
- s.GatewayAdminSecret = NewString("")
- }
-
- if s.StunURI == nil {
- s.StunURI = NewString(WEBRTC_SETTINGS_DEFAULT_STUN_URI)
- }
-
- if s.TurnURI == nil {
- s.TurnURI = NewString(WEBRTC_SETTINGS_DEFAULT_TURN_URI)
- }
-
- if s.TurnUsername == nil {
- s.TurnUsername = NewString("")
- }
-
- if s.TurnSharedKey == nil {
- s.TurnSharedKey = NewString("")
- }
-}
-
-type ElasticsearchSettings struct {
- ConnectionUrl *string
- Username *string
- Password *string
- EnableIndexing *bool
- EnableSearching *bool
- Sniff *bool
- PostIndexReplicas *int
- PostIndexShards *int
- AggregatePostsAfterDays *int
- PostsAggregatorJobStartTime *string
- IndexPrefix *string
- LiveIndexingBatchSize *int
- BulkIndexingTimeWindowSeconds *int
- RequestTimeoutSeconds *int
-}
-
-func (s *ElasticsearchSettings) SetDefaults() {
- if s.ConnectionUrl == nil {
- s.ConnectionUrl = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL)
- }
-
- if s.Username == nil {
- s.Username = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME)
- }
-
- if s.Password == nil {
- s.Password = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD)
- }
-
- if s.EnableIndexing == nil {
- s.EnableIndexing = NewBool(false)
- }
-
- if s.EnableSearching == nil {
- s.EnableSearching = NewBool(false)
- }
-
- if s.Sniff == nil {
- s.Sniff = NewBool(true)
- }
-
- if s.PostIndexReplicas == nil {
- s.PostIndexReplicas = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_REPLICAS)
- }
-
- if s.PostIndexShards == nil {
- s.PostIndexShards = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_SHARDS)
- }
-
- if s.AggregatePostsAfterDays == nil {
- s.AggregatePostsAfterDays = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_AGGREGATE_POSTS_AFTER_DAYS)
- }
-
- if s.PostsAggregatorJobStartTime == nil {
- s.PostsAggregatorJobStartTime = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_POSTS_AGGREGATOR_JOB_START_TIME)
- }
-
- if s.IndexPrefix == nil {
- s.IndexPrefix = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_INDEX_PREFIX)
- }
-
- if s.LiveIndexingBatchSize == nil {
- s.LiveIndexingBatchSize = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_LIVE_INDEXING_BATCH_SIZE)
- }
-
- if s.BulkIndexingTimeWindowSeconds == nil {
- s.BulkIndexingTimeWindowSeconds = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_BULK_INDEXING_TIME_WINDOW_SECONDS)
- }
-
- if s.RequestTimeoutSeconds == nil {
- s.RequestTimeoutSeconds = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_REQUEST_TIMEOUT_SECONDS)
- }
-}
-
-type DataRetentionSettings struct {
- EnableMessageDeletion *bool
- EnableFileDeletion *bool
- MessageRetentionDays *int
- FileRetentionDays *int
- DeletionJobStartTime *string
-}
-
-func (s *DataRetentionSettings) SetDefaults() {
- if s.EnableMessageDeletion == nil {
- s.EnableMessageDeletion = NewBool(false)
- }
-
- if s.EnableFileDeletion == nil {
- s.EnableFileDeletion = NewBool(false)
- }
-
- if s.MessageRetentionDays == nil {
- s.MessageRetentionDays = NewInt(DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS)
- }
-
- if s.FileRetentionDays == nil {
- s.FileRetentionDays = NewInt(DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS)
- }
-
- if s.DeletionJobStartTime == nil {
- s.DeletionJobStartTime = NewString(DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME)
- }
-}
-
-type JobSettings struct {
- RunJobs *bool
- RunScheduler *bool
-}
-
-func (s *JobSettings) SetDefaults() {
- if s.RunJobs == nil {
- s.RunJobs = NewBool(true)
- }
-
- if s.RunScheduler == nil {
- s.RunScheduler = NewBool(true)
- }
-}
-
-type PluginState struct {
- Enable bool
-}
-
-type PluginSettings struct {
- Enable *bool
- EnableUploads *bool
- Directory *string
- ClientDirectory *string
- Plugins map[string]interface{}
- PluginStates map[string]*PluginState
-}
-
-func (s *PluginSettings) SetDefaults() {
- if s.Enable == nil {
- s.Enable = NewBool(true)
- }
-
- if s.EnableUploads == nil {
- s.EnableUploads = NewBool(false)
- }
-
- if s.Directory == nil {
- s.Directory = NewString(PLUGIN_SETTINGS_DEFAULT_DIRECTORY)
- }
-
- if *s.Directory == "" {
- *s.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
- }
-
- if s.ClientDirectory == nil {
- s.ClientDirectory = NewString(PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY)
- }
-
- if *s.ClientDirectory == "" {
- *s.ClientDirectory = PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY
- }
-
- if s.Plugins == nil {
- s.Plugins = make(map[string]interface{})
- }
-
- if s.PluginStates == nil {
- s.PluginStates = make(map[string]*PluginState)
- }
-}
-
-type MessageExportSettings struct {
- EnableExport *bool
- DailyRunTime *string
- ExportFromTimestamp *int64
- BatchSize *int
-}
-
-func (s *MessageExportSettings) SetDefaults() {
- if s.EnableExport == nil {
- s.EnableExport = NewBool(false)
- }
-
- if s.DailyRunTime == nil {
- s.DailyRunTime = NewString("01:00")
- }
-
- if s.ExportFromTimestamp == nil {
- s.ExportFromTimestamp = NewInt64(0)
- }
-
- if s.EnableExport != nil && *s.EnableExport && *s.ExportFromTimestamp == int64(0) {
- // when the feature is enabled via the System Console, use the current timestamp as the start time for future exports
- s.ExportFromTimestamp = NewInt64(GetMillis())
- } else if s.EnableExport != nil && !*s.EnableExport {
- // when the feature is disabled, reset the timestamp so that the timestamp will be set if the feature is re-enabled
- s.ExportFromTimestamp = NewInt64(0)
- }
-
- if s.BatchSize == nil {
- s.BatchSize = NewInt(10000)
- }
-}
-
-type ConfigFunc func() *Config
-
-type Config struct {
- ServiceSettings ServiceSettings
- TeamSettings TeamSettings
- ClientRequirements ClientRequirements
- SqlSettings SqlSettings
- LogSettings LogSettings
- PasswordSettings PasswordSettings
- FileSettings FileSettings
- EmailSettings EmailSettings
- RateLimitSettings RateLimitSettings
- PrivacySettings PrivacySettings
- SupportSettings SupportSettings
- AnnouncementSettings AnnouncementSettings
- ThemeSettings ThemeSettings
- GitLabSettings SSOSettings
- GoogleSettings SSOSettings
- Office365Settings SSOSettings
- LdapSettings LdapSettings
- ComplianceSettings ComplianceSettings
- LocalizationSettings LocalizationSettings
- SamlSettings SamlSettings
- NativeAppSettings NativeAppSettings
- ClusterSettings ClusterSettings
- MetricsSettings MetricsSettings
- AnalyticsSettings AnalyticsSettings
- WebrtcSettings WebrtcSettings
- ElasticsearchSettings ElasticsearchSettings
- DataRetentionSettings DataRetentionSettings
- MessageExportSettings MessageExportSettings
- JobSettings JobSettings
- PluginSettings PluginSettings
-}
-
-func (o *Config) Clone() *Config {
- var ret Config
- if err := json.Unmarshal([]byte(o.ToJson()), &ret); err != nil {
- panic(err)
- }
- return &ret
-}
-
-func (o *Config) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *Config) GetSSOService(service string) *SSOSettings {
- switch service {
- case SERVICE_GITLAB:
- return &o.GitLabSettings
- case SERVICE_GOOGLE:
- return &o.GoogleSettings
- case SERVICE_OFFICE365:
- return &o.Office365Settings
- }
-
- return nil
-}
-
-func ConfigFromJson(data io.Reader) *Config {
- decoder := json.NewDecoder(data)
- var o Config
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *Config) SetDefaults() {
- o.LdapSettings.SetDefaults()
- o.SamlSettings.SetDefaults()
-
- if o.TeamSettings.TeammateNameDisplay == nil {
- o.TeamSettings.TeammateNameDisplay = NewString(SHOW_USERNAME)
-
- if *o.SamlSettings.Enable || *o.LdapSettings.Enable {
- *o.TeamSettings.TeammateNameDisplay = SHOW_FULLNAME
- }
- }
-
- o.SqlSettings.SetDefaults()
- o.FileSettings.SetDefaults()
- o.EmailSettings.SetDefaults()
- o.ServiceSettings.SetDefaults()
- o.PasswordSettings.SetDefaults()
- o.TeamSettings.SetDefaults()
- o.MetricsSettings.SetDefaults()
- o.SupportSettings.SetDefaults()
- o.AnnouncementSettings.SetDefaults()
- o.ThemeSettings.SetDefaults()
- o.ClusterSettings.SetDefaults()
- o.PluginSettings.SetDefaults()
- o.AnalyticsSettings.SetDefaults()
- o.ComplianceSettings.SetDefaults()
- o.LocalizationSettings.SetDefaults()
- o.ElasticsearchSettings.SetDefaults()
- o.NativeAppSettings.SetDefaults()
- o.DataRetentionSettings.SetDefaults()
- o.RateLimitSettings.SetDefaults()
- o.LogSettings.SetDefaults()
- o.JobSettings.SetDefaults()
- o.WebrtcSettings.SetDefaults()
- o.MessageExportSettings.SetDefaults()
-}
-
-func (o *Config) IsValid() *AppError {
- if len(*o.ServiceSettings.SiteURL) == 0 && *o.EmailSettings.EnableEmailBatching {
- return NewAppError("Config.IsValid", "model.config.is_valid.site_url_email_batching.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *o.ClusterSettings.Enable && *o.EmailSettings.EnableEmailBatching {
- return NewAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "", http.StatusBadRequest)
- }
-
- if err := o.TeamSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.SqlSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.FileSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.EmailSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.LdapSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.SamlSettings.isValid(); err != nil {
- return err
- }
-
- if *o.PasswordSettings.MinimumLength < PASSWORD_MINIMUM_LENGTH || *o.PasswordSettings.MinimumLength > PASSWORD_MAXIMUM_LENGTH {
- return NewAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PASSWORD_MINIMUM_LENGTH, "MaxLength": PASSWORD_MAXIMUM_LENGTH}, "", http.StatusBadRequest)
- }
-
- if err := o.RateLimitSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.WebrtcSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.ServiceSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.ElasticsearchSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.DataRetentionSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.LocalizationSettings.isValid(); err != nil {
- return err
- }
-
- if err := o.MessageExportSettings.isValid(o.FileSettings); err != nil {
- return err
- }
-
- return nil
-}
-
-func (ts *TeamSettings) isValid() *AppError {
- if *ts.MaxUsersPerTeam <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.max_users.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ts.MaxChannelsPerTeam <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ts.MaxNotificationsPerChannel <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(*ts.RestrictDirectMessage == DIRECT_MESSAGE_ANY || *ts.RestrictDirectMessage == DIRECT_MESSAGE_TEAM) {
- return NewAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(*ts.TeammateNameDisplay == SHOW_FULLNAME || *ts.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *ts.TeammateNameDisplay == SHOW_USERNAME) {
- return NewAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(ts.SiteName) > SITENAME_MAX_LENGTH {
- return NewAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]interface{}{"MaxLength": SITENAME_MAX_LENGTH}, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ss *SqlSettings) isValid() *AppError {
- if len(ss.AtRestEncryptKey) < 32 {
- return NewAppError("Config.IsValid", "model.config.is_valid.encrypt_sql.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(*ss.DriverName == DATABASE_DRIVER_MYSQL || *ss.DriverName == DATABASE_DRIVER_POSTGRES) {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_driver.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.MaxIdleConns <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_idle.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.QueryTimeout <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.DataSource) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.MaxOpenConns <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (fs *FileSettings) isValid() *AppError {
- if *fs.MaxFileSize <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.max_file_size.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(*fs.DriverName == IMAGE_DRIVER_LOCAL || *fs.DriverName == IMAGE_DRIVER_S3) {
- return NewAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*fs.PublicLinkSalt) < 32 {
- return NewAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (es *EmailSettings) isValid() *AppError {
- if !(es.ConnectionSecurity == CONN_SECURITY_NONE || es.ConnectionSecurity == CONN_SECURITY_TLS || es.ConnectionSecurity == CONN_SECURITY_STARTTLS || es.ConnectionSecurity == CONN_SECURITY_PLAIN) {
- return NewAppError("Config.IsValid", "model.config.is_valid.email_security.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(es.InviteSalt) < 32 {
- return NewAppError("Config.IsValid", "model.config.is_valid.email_salt.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *es.EmailBatchingBufferSize <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_buffer_size.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *es.EmailBatchingInterval < 30 {
- return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(*es.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_FULL || *es.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_GENERIC) {
- return NewAppError("Config.IsValid", "model.config.is_valid.email_notification_contents_type.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (rls *RateLimitSettings) isValid() *AppError {
- if *rls.MemoryStoreSize <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.rate_mem.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *rls.PerSec <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.rate_sec.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *rls.MaxBurst <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.max_burst.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ls *LdapSettings) isValid() *AppError {
- if !(*ls.ConnectionSecurity == CONN_SECURITY_NONE || *ls.ConnectionSecurity == CONN_SECURITY_TLS || *ls.ConnectionSecurity == CONN_SECURITY_STARTTLS) {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ls.SyncIntervalMinutes <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ls.MaxPageSize < 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ls.Enable {
- if *ls.LdapServer == "" {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_server", nil, "", http.StatusBadRequest)
- }
-
- if *ls.BaseDN == "" {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "", http.StatusBadRequest)
- }
-
- if *ls.EmailAttribute == "" {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "", http.StatusBadRequest)
- }
-
- if *ls.UsernameAttribute == "" {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_username", nil, "", http.StatusBadRequest)
- }
-
- if *ls.IdAttribute == "" {
- return NewAppError("Config.IsValid", "model.config.is_valid.ldap_id", nil, "", http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-func (ss *SamlSettings) isValid() *AppError {
- if *ss.Enable {
- if len(*ss.IdpUrl) == 0 || !IsValidHttpUrl(*ss.IdpUrl) {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*ss.IdpDescriptorUrl) {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.IdpCertificateFile) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.EmailAttribute) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.UsernameAttribute) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.Verify {
- if len(*ss.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*ss.AssertionConsumerServiceURL) {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if *ss.Encrypt {
- if len(*ss.PrivateKeyFile) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.PublicCertificateFile) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if len(*ss.EmailAttribute) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-func (ws *WebrtcSettings) isValid() *AppError {
- if *ws.Enable {
- if len(*ws.GatewayWebsocketUrl) == 0 || !IsValidWebsocketUrl(*ws.GatewayWebsocketUrl) {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_ws_url.app_error", nil, "", http.StatusBadRequest)
- } else if len(*ws.GatewayAdminUrl) == 0 || !IsValidHttpUrl(*ws.GatewayAdminUrl) {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_url.app_error", nil, "", http.StatusBadRequest)
- } else if len(*ws.GatewayAdminSecret) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_secret.app_error", nil, "", http.StatusBadRequest)
- } else if len(*ws.StunURI) != 0 && !IsValidTurnOrStunServer(*ws.StunURI) {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_stun_uri.app_error", nil, "", http.StatusBadRequest)
- } else if len(*ws.TurnURI) != 0 {
- if !IsValidTurnOrStunServer(*ws.TurnURI) {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_uri.app_error", nil, "", http.StatusBadRequest)
- }
- if len(*ws.TurnUsername) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_username.app_error", nil, "", http.StatusBadRequest)
- } else if len(*ws.TurnSharedKey) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_shared_key.app_error", nil, "", http.StatusBadRequest)
- }
- }
- }
-
- return nil
-}
-
-func (ss *ServiceSettings) isValid() *AppError {
- if !(*ss.ConnectionSecurity == CONN_SECURITY_NONE || *ss.ConnectionSecurity == CONN_SECURITY_TLS) {
- return NewAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.ReadTimeout <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.WriteTimeout <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.write_timeout.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.TimeBetweenUserTypingUpdatesMilliseconds < 1000 {
- return NewAppError("Config.IsValid", "model.config.is_valid.time_between_user_typing.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ss.MaximumLoginAttempts <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(*ss.SiteURL) != 0 {
- if _, err := url.ParseRequestURI(*ss.SiteURL); err != nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if len(*ss.ListenAddress) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ess *ElasticsearchSettings) isValid() *AppError {
- if *ess.EnableIndexing {
- if len(*ess.ConnectionUrl) == 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.connection_url.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if *ess.EnableSearching && !*ess.EnableIndexing {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.enable_searching.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ess.AggregatePostsAfterDays < 1 {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.aggregate_posts_after_days.app_error", nil, "", http.StatusBadRequest)
- }
-
- if _, err := time.Parse("15:04", *ess.PostsAggregatorJobStartTime); err != nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.posts_aggregator_job_start_time.app_error", nil, err.Error(), http.StatusBadRequest)
- }
-
- if *ess.LiveIndexingBatchSize < 1 {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.live_indexing_batch_size.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ess.BulkIndexingTimeWindowSeconds < 1 {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.bulk_indexing_time_window_seconds.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *ess.RequestTimeoutSeconds < 1 {
- return NewAppError("Config.IsValid", "model.config.is_valid.elastic_search.request_timeout_seconds.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (drs *DataRetentionSettings) isValid() *AppError {
- if *drs.MessageRetentionDays <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.message_retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
- }
-
- if *drs.FileRetentionDays <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.file_retention_days_too_low.app_error", nil, "", http.StatusBadRequest)
- }
-
- if _, err := time.Parse("15:04", *drs.DeletionJobStartTime); err != nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.data_retention.deletion_job_start_time.app_error", nil, err.Error(), http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (ls *LocalizationSettings) isValid() *AppError {
- if len(*ls.AvailableLocales) > 0 {
- if !strings.Contains(*ls.AvailableLocales, *ls.DefaultClientLocale) {
- return NewAppError("Config.IsValid", "model.config.is_valid.localization.available_locales.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-func (mes *MessageExportSettings) isValid(fs FileSettings) *AppError {
- if mes.EnableExport == nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.message_export.enable.app_error", nil, "", http.StatusBadRequest)
- }
- if *mes.EnableExport {
- if mes.ExportFromTimestamp == nil || *mes.ExportFromTimestamp < 0 || *mes.ExportFromTimestamp > GetMillis() {
- return NewAppError("Config.IsValid", "model.config.is_valid.message_export.export_from.app_error", nil, "", http.StatusBadRequest)
- } else if mes.DailyRunTime == nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, "", http.StatusBadRequest)
- } else if _, err := time.Parse("15:04", *mes.DailyRunTime); err != nil {
- return NewAppError("Config.IsValid", "model.config.is_valid.message_export.daily_runtime.app_error", nil, err.Error(), http.StatusBadRequest)
- } else if mes.BatchSize == nil || *mes.BatchSize < 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.message_export.batch_size.app_error", nil, "", http.StatusBadRequest)
- }
- }
- return nil
-}
-
-func (o *Config) GetSanitizeOptions() map[string]bool {
- options := map[string]bool{}
- options["fullname"] = o.PrivacySettings.ShowFullName
- options["email"] = o.PrivacySettings.ShowEmailAddress
-
- return options
-}
-
-func (o *Config) Sanitize() {
- if o.LdapSettings.BindPassword != nil && len(*o.LdapSettings.BindPassword) > 0 {
- *o.LdapSettings.BindPassword = FAKE_SETTING
- }
-
- *o.FileSettings.PublicLinkSalt = FAKE_SETTING
- if len(o.FileSettings.AmazonS3SecretAccessKey) > 0 {
- o.FileSettings.AmazonS3SecretAccessKey = FAKE_SETTING
- }
-
- o.EmailSettings.InviteSalt = FAKE_SETTING
- if len(o.EmailSettings.SMTPPassword) > 0 {
- o.EmailSettings.SMTPPassword = FAKE_SETTING
- }
-
- if len(o.GitLabSettings.Secret) > 0 {
- o.GitLabSettings.Secret = FAKE_SETTING
- }
-
- *o.SqlSettings.DataSource = FAKE_SETTING
- o.SqlSettings.AtRestEncryptKey = FAKE_SETTING
-
- for i := range o.SqlSettings.DataSourceReplicas {
- o.SqlSettings.DataSourceReplicas[i] = FAKE_SETTING
- }
-
- for i := range o.SqlSettings.DataSourceSearchReplicas {
- o.SqlSettings.DataSourceSearchReplicas[i] = FAKE_SETTING
- }
-
- *o.ElasticsearchSettings.Password = FAKE_SETTING
-}
diff --git a/vendor/github.com/mattermost/platform/model/data_retention_policy.go b/vendor/github.com/mattermost/platform/model/data_retention_policy.go
deleted file mode 100644
index 7284477e..00000000
--- a/vendor/github.com/mattermost/platform/model/data_retention_policy.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type DataRetentionPolicy struct {
- MessageDeletionEnabled bool `json:"message_deletion_enabled"`
- FileDeletionEnabled bool `json:"file_deletion_enabled"`
- MessageRetentionCutoff int64 `json:"message_retention_cutoff"`
- FileRetentionCutoff int64 `json:"file_retention_cutoff"`
-}
-
-func (me *DataRetentionPolicy) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func DataRetentionPolicyFromJson(data io.Reader) *DataRetentionPolicy {
- decoder := json.NewDecoder(data)
- var me DataRetentionPolicy
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/emoji.go b/vendor/github.com/mattermost/platform/model/emoji.go
deleted file mode 100644
index 272616d9..00000000
--- a/vendor/github.com/mattermost/platform/model/emoji.go
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-type Emoji struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- CreatorId string `json:"creator_id"`
- Name string `json:"name"`
-}
-
-func (emoji *Emoji) IsValid() *AppError {
- if len(emoji.Id) != 26 {
- return NewAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if emoji.CreateAt == 0 {
- return NewAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest)
- }
-
- if emoji.UpdateAt == 0 {
- return NewAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest)
- }
-
- if len(emoji.CreatorId) != 26 {
- return NewAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(emoji.Name) == 0 || len(emoji.Name) > 64 || !IsValidAlphaNumHyphenUnderscore(emoji.Name, false) {
- return NewAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (emoji *Emoji) PreSave() {
- if emoji.Id == "" {
- emoji.Id = NewId()
- }
-
- emoji.CreateAt = GetMillis()
- emoji.UpdateAt = emoji.CreateAt
-}
-
-func (emoji *Emoji) PreUpdate() {
- emoji.UpdateAt = GetMillis()
-}
-
-func (emoji *Emoji) ToJson() string {
- b, err := json.Marshal(emoji)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func EmojiFromJson(data io.Reader) *Emoji {
- decoder := json.NewDecoder(data)
- var emoji Emoji
- err := decoder.Decode(&emoji)
- if err == nil {
- return &emoji
- } else {
- return nil
- }
-}
-
-func EmojiListToJson(emojiList []*Emoji) string {
- b, err := json.Marshal(emojiList)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func EmojiListFromJson(data io.Reader) []*Emoji {
- decoder := json.NewDecoder(data)
- var emojiList []*Emoji
- err := decoder.Decode(&emojiList)
- if err == nil {
- return emojiList
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/file.go b/vendor/github.com/mattermost/platform/model/file.go
deleted file mode 100644
index f9258146..00000000
--- a/vendor/github.com/mattermost/platform/model/file.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- MaxImageSize = 6048 * 4032 // 24 megapixels, roughly 36MB as a raw image
-)
-
-var (
- IMAGE_EXTENSIONS = [5]string{".jpg", ".jpeg", ".gif", ".bmp", ".png"}
- IMAGE_MIME_TYPES = map[string]string{".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".gif": "image/gif", ".bmp": "image/bmp", ".png": "image/png", ".tiff": "image/tiff"}
-)
-
-type FileUploadResponse struct {
- FileInfos []*FileInfo `json:"file_infos"`
- ClientIds []string `json:"client_ids"`
-}
-
-func FileUploadResponseFromJson(data io.Reader) *FileUploadResponse {
- decoder := json.NewDecoder(data)
- var o FileUploadResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *FileUploadResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/file_info.go b/vendor/github.com/mattermost/platform/model/file_info.go
deleted file mode 100644
index 0ee2c50d..00000000
--- a/vendor/github.com/mattermost/platform/model/file_info.go
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "bytes"
- "encoding/json"
- "image"
- "image/gif"
- "io"
- "mime"
- "net/http"
- "path/filepath"
- "strings"
-)
-
-type FileInfo struct {
- Id string `json:"id"`
- CreatorId string `json:"user_id"`
- PostId string `json:"post_id,omitempty"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- Path string `json:"-"` // not sent back to the client
- ThumbnailPath string `json:"-"` // not sent back to the client
- PreviewPath string `json:"-"` // not sent back to the client
- Name string `json:"name"`
- Extension string `json:"extension"`
- Size int64 `json:"size"`
- MimeType string `json:"mime_type"`
- Width int `json:"width,omitempty"`
- Height int `json:"height,omitempty"`
- HasPreviewImage bool `json:"has_preview_image,omitempty"`
-}
-
-func (info *FileInfo) ToJson() string {
- b, err := json.Marshal(info)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func FileInfoFromJson(data io.Reader) *FileInfo {
- decoder := json.NewDecoder(data)
-
- var info FileInfo
- if err := decoder.Decode(&info); err != nil {
- return nil
- } else {
- return &info
- }
-}
-
-func FileInfosToJson(infos []*FileInfo) string {
- b, err := json.Marshal(infos)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func FileInfosFromJson(data io.Reader) []*FileInfo {
- decoder := json.NewDecoder(data)
-
- var infos []*FileInfo
- if err := decoder.Decode(&infos); err != nil {
- return nil
- } else {
- return infos
- }
-}
-
-func (o *FileInfo) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- if o.CreateAt == 0 {
- o.CreateAt = GetMillis()
- }
-
- if o.UpdateAt < o.CreateAt {
- o.UpdateAt = o.CreateAt
- }
-}
-
-func (o *FileInfo) IsValid() *AppError {
- if len(o.Id) != 26 {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.CreatorId) != 26 {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.PostId) != 0 && len(o.PostId) != 26 {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.Path == "" {
- return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *FileInfo) IsImage() bool {
- return strings.HasPrefix(o.MimeType, "image")
-}
-
-func GetInfoForBytes(name string, data []byte) (*FileInfo, *AppError) {
- info := &FileInfo{
- Name: name,
- Size: int64(len(data)),
- }
- var err *AppError
-
- extension := strings.ToLower(filepath.Ext(name))
- info.MimeType = mime.TypeByExtension(extension)
-
- if extension != "" && extension[0] == '.' {
- // The client expects a file extension without the leading period
- info.Extension = extension[1:]
- } else {
- info.Extension = extension
- }
-
- if info.IsImage() {
- // Only set the width and height if it's actually an image that we can understand
- if config, _, err := image.DecodeConfig(bytes.NewReader(data)); err == nil {
- info.Width = config.Width
- info.Height = config.Height
-
- if info.MimeType == "image/gif" {
- // Just show the gif itself instead of a preview image for animated gifs
- if gifConfig, err := gif.DecodeAll(bytes.NewReader(data)); err != nil {
- // Still return the rest of the info even though it doesn't appear to be an actual gif
- info.HasPreviewImage = true
- err = NewAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name, http.StatusBadRequest)
- } else {
- info.HasPreviewImage = len(gifConfig.Image) == 1
- }
- } else {
- info.HasPreviewImage = true
- }
- }
- }
-
- return info, err
-}
-
-func GetEtagForFileInfos(infos []*FileInfo) string {
- if len(infos) == 0 {
- return Etag()
- }
-
- var maxUpdateAt int64
-
- for _, info := range infos {
- if info.UpdateAt > maxUpdateAt {
- maxUpdateAt = info.UpdateAt
- }
- }
-
- return Etag(infos[0].PostId, maxUpdateAt)
-}
diff --git a/vendor/github.com/mattermost/platform/model/gitlab.go b/vendor/github.com/mattermost/platform/model/gitlab.go
deleted file mode 100644
index 8777614c..00000000
--- a/vendor/github.com/mattermost/platform/model/gitlab.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-const (
- USER_AUTH_SERVICE_GITLAB = "gitlab"
-)
diff --git a/vendor/github.com/mattermost/platform/model/incoming_webhook.go b/vendor/github.com/mattermost/platform/model/incoming_webhook.go
deleted file mode 100644
index 3e0488d2..00000000
--- a/vendor/github.com/mattermost/platform/model/incoming_webhook.go
+++ /dev/null
@@ -1,224 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "bytes"
- "encoding/json"
- "io"
- "net/http"
- "regexp"
-)
-
-const (
- DEFAULT_WEBHOOK_USERNAME = "webhook"
-)
-
-type IncomingWebhook struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- UserId string `json:"user_id"`
- ChannelId string `json:"channel_id"`
- TeamId string `json:"team_id"`
- DisplayName string `json:"display_name"`
- Description string `json:"description"`
- Username string `json:"username"`
- IconURL string `json:"icon_url"`
-}
-
-type IncomingWebhookRequest struct {
- Text string `json:"text"`
- Username string `json:"username"`
- IconURL string `json:"icon_url"`
- ChannelName string `json:"channel"`
- Props StringInterface `json:"props"`
- Attachments []*SlackAttachment `json:"attachments"`
- Type string `json:"type"`
-}
-
-func (o *IncomingWebhook) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func IncomingWebhookFromJson(data io.Reader) *IncomingWebhook {
- decoder := json.NewDecoder(data)
- var o IncomingWebhook
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func IncomingWebhookListToJson(l []*IncomingWebhook) string {
- b, err := json.Marshal(l)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func IncomingWebhookListFromJson(data io.Reader) []*IncomingWebhook {
- decoder := json.NewDecoder(data)
- var o []*IncomingWebhook
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
-
-func (o *IncomingWebhook) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.id.app_error", nil, "", http.StatusBadRequest)
-
- }
-
- if o.CreateAt == 0 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.UserId) != 26 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ChannelId) != 26 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.channel_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.TeamId) != 26 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.team_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.DisplayName) > 64 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.display_name.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Description) > 128 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.description.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Username) > 64 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.username.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.IconURL) > 1024 {
- return NewAppError("IncomingWebhook.IsValid", "model.incoming_hook.icon_url.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *IncomingWebhook) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- o.CreateAt = GetMillis()
- o.UpdateAt = o.CreateAt
-}
-
-func (o *IncomingWebhook) PreUpdate() {
- o.UpdateAt = GetMillis()
-}
-
-// escapeControlCharsFromPayload escapes control chars (\n, \t) from a byte slice.
-// Context:
-// JSON strings are not supposed to contain control characters such as \n, \t,
-// ... but some incoming webhooks might still send invalid JSON and we want to
-// try to handle that. An example invalid JSON string from an incoming webhook
-// might look like this (strings for both "text" and "fallback" attributes are
-// invalid JSON strings because they contain unescaped newlines and tabs):
-// `{
-// "text": "this is a test
-// that contains a newline and tabs",
-// "attachments": [
-// {
-// "fallback": "Required plain-text summary of the attachment
-// that contains a newline and tabs",
-// "color": "#36a64f",
-// ...
-// "text": "Optional text that appears within the attachment
-// that contains a newline and tabs",
-// ...
-// "thumb_url": "http://example.com/path/to/thumb.png"
-// }
-// ]
-// }`
-// This function will search for `"key": "value"` pairs, and escape \n, \t
-// from the value.
-func escapeControlCharsFromPayload(by []byte) []byte {
- // we'll search for `"text": "..."` or `"fallback": "..."`, ...
- keys := "text|fallback|pretext|author_name|title|value"
-
- // the regexp reads like this:
- // (?s): this flag let . match \n (default is false)
- // "(keys)": we search for the keys defined above
- // \s*:\s*: followed by 0..n spaces/tabs, a colon then 0..n spaces/tabs
- // ": a double-quote
- // (\\"|[^"])*: any number of times the `\"` string or any char but a double-quote
- // ": a double-quote
- r := `(?s)"(` + keys + `)"\s*:\s*"(\\"|[^"])*"`
- re := regexp.MustCompile(r)
-
- // the function that will escape \n and \t on the regexp matches
- repl := func(b []byte) []byte {
- if bytes.Contains(b, []byte("\n")) {
- b = bytes.Replace(b, []byte("\n"), []byte("\\n"), -1)
- }
- if bytes.Contains(b, []byte("\t")) {
- b = bytes.Replace(b, []byte("\t"), []byte("\\t"), -1)
- }
-
- return b
- }
-
- return re.ReplaceAllFunc(by, repl)
-}
-
-func decodeIncomingWebhookRequest(by []byte) (*IncomingWebhookRequest, error) {
- decoder := json.NewDecoder(bytes.NewReader(by))
- var o IncomingWebhookRequest
- err := decoder.Decode(&o)
- if err == nil {
- return &o, nil
- } else {
- return nil, err
- }
-}
-
-func IncomingWebhookRequestFromJson(data io.Reader) (*IncomingWebhookRequest, *AppError) {
- buf := new(bytes.Buffer)
- buf.ReadFrom(data)
- by := buf.Bytes()
-
- // Try to decode the JSON data. Only if it fails, try to escape control
- // characters from the strings contained in the JSON data.
- o, err := decodeIncomingWebhookRequest(by)
- if err != nil {
- o, err = decodeIncomingWebhookRequest(escapeControlCharsFromPayload(by))
- if err != nil {
- return nil, NewAppError("IncomingWebhookRequestFromJson", "Unable to parse incoming data", nil, err.Error(), http.StatusBadRequest)
- }
- }
-
- o.Attachments = StringifySlackFieldValue(o.Attachments)
-
- return o, nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/initial_load.go b/vendor/github.com/mattermost/platform/model/initial_load.go
deleted file mode 100644
index 71ba1769..00000000
--- a/vendor/github.com/mattermost/platform/model/initial_load.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type InitialLoad struct {
- User *User `json:"user"`
- TeamMembers []*TeamMember `json:"team_members"`
- Teams []*Team `json:"teams"`
- Preferences Preferences `json:"preferences"`
- ClientCfg map[string]string `json:"client_cfg"`
- LicenseCfg map[string]string `json:"license_cfg"`
- NoAccounts bool `json:"no_accounts"`
-}
-
-func (me *InitialLoad) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func InitialLoadFromJson(data io.Reader) *InitialLoad {
- decoder := json.NewDecoder(data)
- var o InitialLoad
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/job.go b/vendor/github.com/mattermost/platform/model/job.go
deleted file mode 100644
index 9a756602..00000000
--- a/vendor/github.com/mattermost/platform/model/job.go
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "time"
-)
-
-const (
- JOB_TYPE_DATA_RETENTION = "data_retention"
- JOB_TYPE_MESSAGE_EXPORT = "message_export"
- JOB_TYPE_ELASTICSEARCH_POST_INDEXING = "elasticsearch_post_indexing"
- JOB_TYPE_ELASTICSEARCH_POST_AGGREGATION = "elasticsearch_post_aggregation"
- JOB_TYPE_LDAP_SYNC = "ldap_sync"
-
- JOB_STATUS_PENDING = "pending"
- JOB_STATUS_IN_PROGRESS = "in_progress"
- JOB_STATUS_SUCCESS = "success"
- JOB_STATUS_ERROR = "error"
- JOB_STATUS_CANCEL_REQUESTED = "cancel_requested"
- JOB_STATUS_CANCELED = "canceled"
-)
-
-type Job struct {
- Id string `json:"id"`
- Type string `json:"type"`
- Priority int64 `json:"priority"`
- CreateAt int64 `json:"create_at"`
- StartAt int64 `json:"start_at"`
- LastActivityAt int64 `json:"last_activity_at"`
- Status string `json:"status"`
- Progress int64 `json:"progress"`
- Data map[string]string `json:"data"`
-}
-
-func (j *Job) IsValid() *AppError {
- if len(j.Id) != 26 {
- return NewAppError("Job.IsValid", "model.job.is_valid.id.app_error", nil, "id="+j.Id, http.StatusBadRequest)
- }
-
- if j.CreateAt == 0 {
- return NewAppError("Job.IsValid", "model.job.is_valid.create_at.app_error", nil, "id="+j.Id, http.StatusBadRequest)
- }
-
- switch j.Type {
- case JOB_TYPE_DATA_RETENTION:
- case JOB_TYPE_ELASTICSEARCH_POST_INDEXING:
- case JOB_TYPE_ELASTICSEARCH_POST_AGGREGATION:
- case JOB_TYPE_LDAP_SYNC:
- case JOB_TYPE_MESSAGE_EXPORT:
- default:
- return NewAppError("Job.IsValid", "model.job.is_valid.type.app_error", nil, "id="+j.Id, http.StatusBadRequest)
- }
-
- switch j.Status {
- case JOB_STATUS_PENDING:
- case JOB_STATUS_IN_PROGRESS:
- case JOB_STATUS_SUCCESS:
- case JOB_STATUS_ERROR:
- case JOB_STATUS_CANCEL_REQUESTED:
- case JOB_STATUS_CANCELED:
- default:
- return NewAppError("Job.IsValid", "model.job.is_valid.status.app_error", nil, "id="+j.Id, http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (js *Job) ToJson() string {
- if b, err := json.Marshal(js); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func JobFromJson(data io.Reader) *Job {
- var job Job
- if err := json.NewDecoder(data).Decode(&job); err == nil {
- return &job
- } else {
- return nil
- }
-}
-
-func JobsToJson(jobs []*Job) string {
- if b, err := json.Marshal(jobs); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func JobsFromJson(data io.Reader) []*Job {
- var jobs []*Job
- if err := json.NewDecoder(data).Decode(&jobs); err == nil {
- return jobs
- } else {
- return nil
- }
-}
-
-func (js *Job) DataToJson() string {
- if b, err := json.Marshal(js.Data); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-type Worker interface {
- Run()
- Stop()
- JobChannel() chan<- Job
-}
-
-type Scheduler interface {
- Name() string
- JobType() string
- Enabled(cfg *Config) bool
- NextScheduleTime(cfg *Config, now time.Time, pendingJobs bool, lastSuccessfulJob *Job) *time.Time
- ScheduleJob(cfg *Config, pendingJobs bool, lastSuccessfulJob *Job) (*Job, *AppError)
-}
diff --git a/vendor/github.com/mattermost/platform/model/ldap.go b/vendor/github.com/mattermost/platform/model/ldap.go
deleted file mode 100644
index 1453a4ad..00000000
--- a/vendor/github.com/mattermost/platform/model/ldap.go
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-const (
- USER_AUTH_SERVICE_LDAP = "ldap"
- LDAP_SYNC_TASK_NAME = "LDAP Syncronization"
-)
diff --git a/vendor/github.com/mattermost/platform/model/license.go b/vendor/github.com/mattermost/platform/model/license.go
deleted file mode 100644
index a81f882c..00000000
--- a/vendor/github.com/mattermost/platform/model/license.go
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-const (
- EXPIRED_LICENSE_ERROR = "api.license.add_license.expired.app_error"
- INVALID_LICENSE_ERROR = "api.license.add_license.invalid.app_error"
-)
-
-type LicenseRecord struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- Bytes string `json:"-"`
-}
-
-type License struct {
- Id string `json:"id"`
- IssuedAt int64 `json:"issued_at"`
- StartsAt int64 `json:"starts_at"`
- ExpiresAt int64 `json:"expires_at"`
- Customer *Customer `json:"customer"`
- Features *Features `json:"features"`
-}
-
-type Customer struct {
- Id string `json:"id"`
- Name string `json:"name"`
- Email string `json:"email"`
- Company string `json:"company"`
- PhoneNumber string `json:"phone_number"`
-}
-
-type Features struct {
- Users *int `json:"users"`
- LDAP *bool `json:"ldap"`
- MFA *bool `json:"mfa"`
- GoogleOAuth *bool `json:"google_oauth"`
- 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"`
- PasswordRequirements *bool `json:"password_requirements"`
- Elasticsearch *bool `json:"elastic_search"`
- Announcement *bool `json:"announcement"`
- ThemeManagement *bool `json:"theme_management"`
- EmailNotificationContents *bool `json:"email_notification_contents"`
- DataRetention *bool `json:"data_retention"`
- MessageExport *bool `json:"message_export"`
-
- // after we enabled more features for webrtc we'll need to control them with this
- 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,
- "metrics": *f.Metrics,
- "custom_brand": *f.CustomBrand,
- "mhpns": *f.MHPNS,
- "saml": *f.SAML,
- "password": *f.PasswordRequirements,
- "elastic_search": *f.Elasticsearch,
- "email_notification_contents": *f.EmailNotificationContents,
- "data_retention": *f.DataRetention,
- "message_export": *f.MessageExport,
- "future": *f.FutureFeatures,
- }
-}
-
-func (f *Features) SetDefaults() {
- if f.FutureFeatures == nil {
- f.FutureFeatures = NewBool(true)
- }
-
- if f.Users == nil {
- f.Users = NewInt(0)
- }
-
- if f.LDAP == nil {
- f.LDAP = NewBool(*f.FutureFeatures)
- }
-
- if f.MFA == nil {
- f.MFA = NewBool(*f.FutureFeatures)
- }
-
- if f.GoogleOAuth == nil {
- f.GoogleOAuth = NewBool(*f.FutureFeatures)
- }
-
- if f.Office365OAuth == nil {
- f.Office365OAuth = NewBool(*f.FutureFeatures)
- }
-
- if f.Compliance == nil {
- f.Compliance = NewBool(*f.FutureFeatures)
- }
-
- if f.Cluster == nil {
- f.Cluster = NewBool(*f.FutureFeatures)
- }
-
- if f.Metrics == nil {
- f.Metrics = NewBool(*f.FutureFeatures)
- }
-
- if f.CustomBrand == nil {
- f.CustomBrand = NewBool(*f.FutureFeatures)
- }
-
- if f.MHPNS == nil {
- f.MHPNS = NewBool(*f.FutureFeatures)
- }
-
- if f.SAML == nil {
- f.SAML = NewBool(*f.FutureFeatures)
- }
-
- if f.PasswordRequirements == nil {
- f.PasswordRequirements = NewBool(*f.FutureFeatures)
- }
-
- if f.Elasticsearch == nil {
- f.Elasticsearch = NewBool(*f.FutureFeatures)
- }
-
- if f.Announcement == nil {
- f.Announcement = NewBool(true)
- }
-
- if f.ThemeManagement == nil {
- f.ThemeManagement = NewBool(true)
- }
-
- if f.EmailNotificationContents == nil {
- f.EmailNotificationContents = NewBool(*f.FutureFeatures)
- }
-
- if f.DataRetention == nil {
- f.DataRetention = NewBool(*f.FutureFeatures)
- }
-
- if f.MessageExport == nil {
- f.MessageExport = NewBool(*f.FutureFeatures)
- }
-}
-
-func (l *License) IsExpired() bool {
- return l.ExpiresAt < GetMillis()
-}
-
-func (l *License) IsStarted() bool {
- return l.StartsAt < GetMillis()
-}
-
-func (l *License) ToJson() string {
- b, err := json.Marshal(l)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func LicenseFromJson(data io.Reader) *License {
- decoder := json.NewDecoder(data)
- var o License
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (lr *LicenseRecord) IsValid() *AppError {
- if len(lr.Id) != 26 {
- return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if lr.CreateAt == 0 {
- return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(lr.Bytes) == 0 || len(lr.Bytes) > 10000 {
- return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (lr *LicenseRecord) PreSave() {
- lr.CreateAt = GetMillis()
-}
diff --git a/vendor/github.com/mattermost/platform/model/manifest.go b/vendor/github.com/mattermost/platform/model/manifest.go
deleted file mode 100644
index 03d78f84..00000000
--- a/vendor/github.com/mattermost/platform/model/manifest.go
+++ /dev/null
@@ -1,246 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "io/ioutil"
- "os"
- "path/filepath"
-
- "gopkg.in/yaml.v2"
-)
-
-const (
- PLUGIN_CONFIG_TYPE_TEXT = "text"
- PLUGIN_CONFIG_TYPE_BOOL = "bool"
- PLUGIN_CONFIG_TYPE_RADIO = "radio"
- PLUGIN_CONFIG_TYPE_DROPDOWN = "dropdown"
- PLUGIN_CONFIG_TYPE_GENERATED = "generated"
- PLUGIN_CONFIG_TYPE_USERNAME = "username"
-)
-
-type PluginOption struct {
- // The display name for the option.
- DisplayName string `json:"display_name" yaml:"display_name"`
-
- // The string value for the option.
- Value string `json:"value" yaml:"value"`
-}
-
-type PluginSetting struct {
- // The key that the setting will be assigned to in the configuration file.
- Key string `json:"key" yaml:"key"`
-
- // The display name for the setting.
- DisplayName string `json:"display_name" yaml:"display_name"`
-
- // The type of the setting.
- //
- // "bool" will result in a boolean true or false setting.
- //
- // "dropdown" will result in a string setting that allows the user to select from a list of
- // pre-defined options.
- //
- // "generated" will result in a string setting that is set to a random, cryptographically secure
- // string.
- //
- // "radio" will result in a string setting that allows the user to select from a short selection
- // of pre-defined options.
- //
- // "text" will result in a string setting that can be typed in manually.
- //
- // "username" will result in a text setting that will autocomplete to a username.
- Type string `json:"type" yaml:"type"`
-
- // The help text to display to the user.
- HelpText string `json:"help_text" yaml:"help_text"`
-
- // The help text to display alongside the "Regenerate" button for settings of the "generated" type.
- RegenerateHelpText string `json:"regenerate_help_text,omitempty" yaml:"regenerate_help_text,omitempty"`
-
- // The placeholder to display for "text", "generated" and "username" types when blank.
- Placeholder string `json:"placeholder" yaml:"placeholder"`
-
- // The default value of the setting.
- Default interface{} `json:"default" yaml:"default"`
-
- // For "radio" or "dropdown" settings, this is the list of pre-defined options that the user can choose
- // from.
- Options []*PluginOption `json:"options,omitempty" yaml:"options,omitempty"`
-}
-
-type PluginSettingsSchema struct {
- // Optional text to display above the settings.
- Header string `json:"header" yaml:"header"`
-
- // Optional text to display below the settings.
- Footer string `json:"footer" yaml:"footer"`
-
- // A list of setting definitions.
- Settings []*PluginSetting `json:"settings" yaml:"settings"`
-}
-
-// The plugin manifest defines the metadata required to load and present your plugin. The manifest
-// file should be named plugin.json or plugin.yaml and placed in the top of your
-// plugin bundle.
-//
-// Example plugin.yaml:
-//
-// id: com.mycompany.myplugin
-// name: My Plugin
-// description: This is my plugin. It does stuff.
-// backend:
-// executable: myplugin
-// settings_schema:
-// settings:
-// - key: enable_extra_thing
-// type: bool
-// display_name: Enable Extra Thing
-// help_text: When true, an extra thing will be enabled!
-// default: false
-type Manifest struct {
- // The id is a globally unique identifier that represents your plugin. Ids are limited
- // to 190 characters. Reverse-DNS notation using a name you control is a good option.
- // For example, "com.mycompany.myplugin".
- Id string `json:"id" yaml:"id"`
-
- // The name to be displayed for the plugin.
- Name string `json:"name,omitempty" yaml:"name,omitempty"`
-
- // A description of what your plugin is and does.
- Description string `json:"description,omitempty" yaml:"description,omitempty"`
-
- // A version number for your plugin. Semantic versioning is recommended: http://semver.org
- Version string `json:"version" yaml:"version"`
-
- // If your plugin extends the server, you'll need define backend.
- Backend *ManifestBackend `json:"backend,omitempty" yaml:"backend,omitempty"`
-
- // If your plugin extends the web app, you'll need to define webapp.
- Webapp *ManifestWebapp `json:"webapp,omitempty" yaml:"webapp,omitempty"`
-
- // To allow administrators to configure your plugin via the Mattermost system console, you can
- // provide your settings schema.
- SettingsSchema *PluginSettingsSchema `json:"settings_schema,omitempty" yaml:"settings_schema,omitempty"`
-}
-
-type ManifestBackend struct {
- // The path to your executable binary. This should be relative to the root of your bundle and the
- // location of the manifest file.
- //
- // On Windows, this file must have a ".exe" extension.
- Executable string `json:"executable" yaml:"executable"`
-}
-
-type ManifestWebapp struct {
- // The path to your webapp bundle. This should be relative to the root of your bundle and the
- // location of the manifest file.
- BundlePath string `json:"bundle_path" yaml:"bundle_path"`
-}
-
-func (m *Manifest) ToJson() string {
- b, err := json.Marshal(m)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ManifestListToJson(m []*Manifest) string {
- b, err := json.Marshal(m)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ManifestFromJson(data io.Reader) *Manifest {
- decoder := json.NewDecoder(data)
- var m Manifest
- err := decoder.Decode(&m)
- if err == nil {
- return &m
- } else {
- return nil
- }
-}
-
-func ManifestListFromJson(data io.Reader) []*Manifest {
- decoder := json.NewDecoder(data)
- var manifests []*Manifest
- err := decoder.Decode(&manifests)
- if err == nil {
- return manifests
- } else {
- return nil
- }
-}
-
-func (m *Manifest) HasClient() bool {
- return m.Webapp != nil
-}
-
-func (m *Manifest) ClientManifest() *Manifest {
- cm := new(Manifest)
- *cm = *m
- cm.Name = ""
- cm.Description = ""
- cm.Backend = nil
- return cm
-}
-
-// FindManifest will find and parse the manifest in a given directory.
-//
-// In all cases other than a does-not-exist error, path is set to the path of the manifest file that was
-// found.
-//
-// Manifests are JSON or YAML files named plugin.json, plugin.yaml, or plugin.yml.
-func FindManifest(dir string) (manifest *Manifest, path string, err error) {
- for _, name := range []string{"plugin.yml", "plugin.yaml"} {
- path = filepath.Join(dir, name)
- f, ferr := os.Open(path)
- if ferr != nil {
- if !os.IsNotExist(ferr) {
- err = ferr
- return
- }
- continue
- }
- b, ioerr := ioutil.ReadAll(f)
- f.Close()
- if ioerr != nil {
- err = ioerr
- return
- }
- var parsed Manifest
- err = yaml.Unmarshal(b, &parsed)
- if err != nil {
- return
- }
- manifest = &parsed
- return
- }
-
- path = filepath.Join(dir, "plugin.json")
- f, ferr := os.Open(path)
- if ferr != nil {
- if os.IsNotExist(ferr) {
- path = ""
- }
- err = ferr
- return
- }
- defer f.Close()
- var parsed Manifest
- err = json.NewDecoder(f).Decode(&parsed)
- if err != nil {
- return
- }
- manifest = &parsed
- return
-}
diff --git a/vendor/github.com/mattermost/platform/model/message_export.go b/vendor/github.com/mattermost/platform/model/message_export.go
deleted file mode 100644
index b59b114d..00000000
--- a/vendor/github.com/mattermost/platform/model/message_export.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-type MessageExport struct {
- ChannelId *string
- ChannelDisplayName *string
-
- UserId *string
- UserEmail *string
-
- PostId *string
- PostCreateAt *int64
- PostMessage *string
- PostType *string
- PostFileIds StringArray
-}
diff --git a/vendor/github.com/mattermost/platform/model/mfa_secret.go b/vendor/github.com/mattermost/platform/model/mfa_secret.go
deleted file mode 100644
index 99580f5f..00000000
--- a/vendor/github.com/mattermost/platform/model/mfa_secret.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type MfaSecret struct {
- Secret string `json:"secret"`
- QRCode string `json:"qr_code"`
-}
-
-func (me *MfaSecret) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func MfaSecretFromJson(data io.Reader) *MfaSecret {
- decoder := json.NewDecoder(data)
- var me MfaSecret
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/oauth.go b/vendor/github.com/mattermost/platform/model/oauth.go
deleted file mode 100644
index 3139aefe..00000000
--- a/vendor/github.com/mattermost/platform/model/oauth.go
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "unicode/utf8"
-)
-
-const (
- OAUTH_ACTION_SIGNUP = "signup"
- OAUTH_ACTION_LOGIN = "login"
- OAUTH_ACTION_EMAIL_TO_SSO = "email_to_sso"
- OAUTH_ACTION_SSO_TO_EMAIL = "sso_to_email"
- OAUTH_ACTION_MOBILE = "mobile"
-)
-
-type OAuthApp struct {
- Id string `json:"id"`
- CreatorId string `json:"creator_id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- ClientSecret string `json:"client_secret"`
- Name string `json:"name"`
- Description string `json:"description"`
- IconURL string `json:"icon_url"`
- CallbackUrls StringArray `json:"callback_urls"`
- Homepage string `json:"homepage"`
- IsTrusted bool `json:"is_trusted"`
-}
-
-// IsValid validates the app and returns an error if it isn't configured
-// correctly.
-func (a *OAuthApp) IsValid() *AppError {
-
- if len(a.Id) != 26 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.app_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if a.CreateAt == 0 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.create_at.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if a.UpdateAt == 0 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.update_at.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if len(a.CreatorId) != 26 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.creator_id.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if len(a.ClientSecret) == 0 || len(a.ClientSecret) > 128 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.client_secret.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if len(a.Name) == 0 || len(a.Name) > 64 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.name.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if len(a.CallbackUrls) == 0 || len(fmt.Sprintf("%s", a.CallbackUrls)) > 1024 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.callback.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- for _, callback := range a.CallbackUrls {
- if !IsValidHttpUrl(callback) {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.callback.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if len(a.Homepage) == 0 || len(a.Homepage) > 256 || !IsValidHttpUrl(a.Homepage) {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.homepage.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(a.Description) > 512 {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.description.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
-
- if len(a.IconURL) > 0 {
- if len(a.IconURL) > 512 || !IsValidHttpUrl(a.IconURL) {
- return NewAppError("OAuthApp.IsValid", "model.oauth.is_valid.icon_url.app_error", nil, "app_id="+a.Id, http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-// PreSave will set the Id and ClientSecret if missing. It will also fill
-// in the CreateAt, UpdateAt times. It should be run before saving the app to the db.
-func (a *OAuthApp) PreSave() {
- if a.Id == "" {
- a.Id = NewId()
- }
-
- if a.ClientSecret == "" {
- a.ClientSecret = NewId()
- }
-
- a.CreateAt = GetMillis()
- a.UpdateAt = a.CreateAt
-}
-
-// PreUpdate should be run before updating the app in the db.
-func (a *OAuthApp) PreUpdate() {
- a.UpdateAt = GetMillis()
-}
-
-// ToJson convert a User to a json string
-func (a *OAuthApp) ToJson() string {
- b, err := json.Marshal(a)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// Generate a valid strong etag so the browser can cache the results
-func (a *OAuthApp) Etag() string {
- return Etag(a.Id, a.UpdateAt)
-}
-
-// Remove any private data from the app object
-func (a *OAuthApp) Sanitize() {
- a.ClientSecret = ""
-}
-
-func (a *OAuthApp) IsValidRedirectURL(url string) bool {
- for _, u := range a.CallbackUrls {
- if u == url {
- return true
- }
- }
-
- return false
-}
-
-// OAuthAppFromJson will decode the input and return a User
-func OAuthAppFromJson(data io.Reader) *OAuthApp {
- decoder := json.NewDecoder(data)
- var app OAuthApp
- err := decoder.Decode(&app)
- if err == nil {
- return &app
- } else {
- return nil
- }
-}
-
-func OAuthAppMapToJson(a map[string]*OAuthApp) string {
- b, err := json.Marshal(a)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func OAuthAppMapFromJson(data io.Reader) map[string]*OAuthApp {
- decoder := json.NewDecoder(data)
- var apps map[string]*OAuthApp
- err := decoder.Decode(&apps)
- if err == nil {
- return apps
- } else {
- return nil
- }
-}
-
-func OAuthAppListToJson(l []*OAuthApp) string {
- b, err := json.Marshal(l)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func OAuthAppListFromJson(data io.Reader) []*OAuthApp {
- decoder := json.NewDecoder(data)
- var o []*OAuthApp
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/outgoing_webhook.go b/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
deleted file mode 100644
index 477a277d..00000000
--- a/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
+++ /dev/null
@@ -1,284 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "strconv"
- "strings"
-)
-
-type OutgoingWebhook struct {
- Id string `json:"id"`
- Token string `json:"token"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- CreatorId string `json:"creator_id"`
- ChannelId string `json:"channel_id"`
- TeamId string `json:"team_id"`
- TriggerWords StringArray `json:"trigger_words"`
- TriggerWhen int `json:"trigger_when"`
- CallbackURLs StringArray `json:"callback_urls"`
- DisplayName string `json:"display_name"`
- Description string `json:"description"`
- ContentType string `json:"content_type"`
-}
-
-type OutgoingWebhookPayload struct {
- Token string `json:"token"`
- TeamId string `json:"team_id"`
- TeamDomain string `json:"team_domain"`
- ChannelId string `json:"channel_id"`
- ChannelName string `json:"channel_name"`
- Timestamp int64 `json:"timestamp"`
- UserId string `json:"user_id"`
- UserName string `json:"user_name"`
- PostId string `json:"post_id"`
- Text string `json:"text"`
- TriggerWord string `json:"trigger_word"`
- FileIds string `json:"file_ids"`
-}
-
-type OutgoingWebhookResponse struct {
- Text *string `json:"text"`
- Username string `json:"username"`
- IconURL string `json:"icon_url"`
- Props StringInterface `json:"props"`
- Type string `json:"type"`
- ResponseType string `json:"response_type"`
-}
-
-const OUTGOING_HOOK_RESPONSE_TYPE_COMMENT = "comment"
-
-func (o *OutgoingWebhookPayload) ToJSON() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *OutgoingWebhookPayload) ToFormValues() string {
- v := url.Values{}
- v.Set("token", o.Token)
- v.Set("team_id", o.TeamId)
- v.Set("team_domain", o.TeamDomain)
- v.Set("channel_id", o.ChannelId)
- v.Set("channel_name", o.ChannelName)
- v.Set("timestamp", strconv.FormatInt(o.Timestamp/1000, 10))
- v.Set("user_id", o.UserId)
- v.Set("user_name", o.UserName)
- v.Set("post_id", o.PostId)
- v.Set("text", o.Text)
- v.Set("trigger_word", o.TriggerWord)
- v.Set("file_ids", o.FileIds)
-
- return v.Encode()
-}
-
-func (o *OutgoingWebhook) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func OutgoingWebhookFromJson(data io.Reader) *OutgoingWebhook {
- decoder := json.NewDecoder(data)
- var o OutgoingWebhook
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func OutgoingWebhookListToJson(l []*OutgoingWebhook) string {
- b, err := json.Marshal(l)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func OutgoingWebhookListFromJson(data io.Reader) []*OutgoingWebhook {
- decoder := json.NewDecoder(data)
- var o []*OutgoingWebhook
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
-
-func (o *OutgoingWebhookResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func OutgoingWebhookResponseFromJson(data io.Reader) *OutgoingWebhookResponse {
- decoder := json.NewDecoder(data)
- var o OutgoingWebhookResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *OutgoingWebhook) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Token) != 26 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.CreatorId) != 26 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ChannelId) != 0 && len(o.ChannelId) != 26 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.TeamId) != 26 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.team_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(fmt.Sprintf("%s", o.TriggerWords)) > 1024 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.words.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.TriggerWords) != 0 {
- for _, triggerWord := range o.TriggerWords {
- if len(triggerWord) == 0 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.trigger_words.app_error", nil, "", http.StatusBadRequest)
- }
- }
- }
-
- if len(o.CallbackURLs) == 0 || len(fmt.Sprintf("%s", o.CallbackURLs)) > 1024 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.callback.app_error", nil, "", http.StatusBadRequest)
- }
-
- for _, callback := range o.CallbackURLs {
- if !IsValidHttpUrl(callback) {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.url.app_error", nil, "", http.StatusBadRequest)
- }
- }
-
- if len(o.DisplayName) > 64 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.display_name.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.Description) > 128 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.description.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ContentType) > 128 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.content_type.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.TriggerWhen > 1 {
- return NewAppError("OutgoingWebhook.IsValid", "model.outgoing_hook.is_valid.content_type.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *OutgoingWebhook) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- if o.Token == "" {
- o.Token = NewId()
- }
-
- o.CreateAt = GetMillis()
- o.UpdateAt = o.CreateAt
-}
-
-func (o *OutgoingWebhook) PreUpdate() {
- o.UpdateAt = GetMillis()
-}
-
-func (o *OutgoingWebhook) TriggerWordExactMatch(word string) bool {
- if len(word) == 0 {
- return false
- }
-
- for _, trigger := range o.TriggerWords {
- if trigger == word {
- return true
- }
- }
-
- return false
-}
-
-func (o *OutgoingWebhook) TriggerWordStartsWith(word string) bool {
- if len(word) == 0 {
- return false
- }
-
- for _, trigger := range o.TriggerWords {
- if strings.HasPrefix(word, trigger) {
- return true
- }
- }
-
- return false
-}
-
-func (o *OutgoingWebhook) GetTriggerWord(word string, isExactMatch bool) (triggerWord string) {
- if len(word) == 0 {
- return
- }
-
- if isExactMatch {
- for _, trigger := range o.TriggerWords {
- if trigger == word {
- triggerWord = trigger
- break
- }
- }
- } else {
- for _, trigger := range o.TriggerWords {
- if strings.HasPrefix(word, trigger) {
- triggerWord = trigger
- break
- }
- }
- }
-
- return triggerWord
-}
diff --git a/vendor/github.com/mattermost/platform/model/plugin_key_value.go b/vendor/github.com/mattermost/platform/model/plugin_key_value.go
deleted file mode 100644
index b7a7731c..00000000
--- a/vendor/github.com/mattermost/platform/model/plugin_key_value.go
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "net/http"
- "unicode/utf8"
-)
-
-const (
- KEY_VALUE_PLUGIN_ID_MAX_RUNES = 190
- KEY_VALUE_KEY_MAX_RUNES = 50
-)
-
-type PluginKeyValue struct {
- PluginId string `json:"plugin_id"`
- Key string `json:"key" db:"PKey"`
- Value []byte `json:"value" db:"PValue"`
-}
-
-func (kv *PluginKeyValue) IsValid() *AppError {
- if len(kv.PluginId) == 0 || utf8.RuneCountInString(kv.PluginId) > KEY_VALUE_PLUGIN_ID_MAX_RUNES {
- return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.plugin_id.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
- }
-
- if len(kv.Key) == 0 || utf8.RuneCountInString(kv.Key) > KEY_VALUE_KEY_MAX_RUNES {
- return NewAppError("PluginKeyValue.IsValid", "model.plugin_key_value.is_valid.key.app_error", map[string]interface{}{"Max": KEY_VALUE_KEY_MAX_RUNES, "Min": 0}, "key="+kv.Key, http.StatusBadRequest)
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/plugins_response.go b/vendor/github.com/mattermost/platform/model/plugins_response.go
deleted file mode 100644
index 74c89af2..00000000
--- a/vendor/github.com/mattermost/platform/model/plugins_response.go
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type PluginInfo struct {
- Manifest
- Prepackaged bool `json:"prepackaged"`
-}
-
-type PluginsResponse struct {
- Active []*PluginInfo `json:"active"`
- Inactive []*PluginInfo `json:"inactive"`
-}
-
-func (m *PluginsResponse) ToJson() string {
- b, err := json.Marshal(m)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func PluginsResponseFromJson(data io.Reader) *PluginsResponse {
- decoder := json.NewDecoder(data)
- var m PluginsResponse
- err := decoder.Decode(&m)
- if err == nil {
- return &m
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/post.go b/vendor/github.com/mattermost/platform/model/post.go
deleted file mode 100644
index 6b282fbf..00000000
--- a/vendor/github.com/mattermost/platform/model/post.go
+++ /dev/null
@@ -1,394 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "regexp"
- "strings"
- "unicode/utf8"
-)
-
-const (
- POST_SYSTEM_MESSAGE_PREFIX = "system_"
- POST_DEFAULT = ""
- POST_SLACK_ATTACHMENT = "slack_attachment"
- POST_SYSTEM_GENERIC = "system_generic"
- POST_JOIN_LEAVE = "system_join_leave" // Deprecated, use POST_JOIN_CHANNEL or POST_LEAVE_CHANNEL instead
- POST_JOIN_CHANNEL = "system_join_channel"
- POST_LEAVE_CHANNEL = "system_leave_channel"
- POST_JOIN_TEAM = "system_join_team"
- POST_LEAVE_TEAM = "system_leave_team"
- POST_ADD_REMOVE = "system_add_remove" // Deprecated, use POST_ADD_TO_CHANNEL or POST_REMOVE_FROM_CHANNEL instead
- POST_ADD_TO_CHANNEL = "system_add_to_channel"
- POST_REMOVE_FROM_CHANNEL = "system_remove_from_channel"
- POST_ADD_TO_TEAM = "system_add_to_team"
- POST_REMOVE_FROM_TEAM = "system_remove_from_team"
- POST_HEADER_CHANGE = "system_header_change"
- POST_DISPLAYNAME_CHANGE = "system_displayname_change"
- POST_PURPOSE_CHANGE = "system_purpose_change"
- POST_CHANNEL_DELETED = "system_channel_deleted"
- POST_EPHEMERAL = "system_ephemeral"
- POST_FILEIDS_MAX_RUNES = 150
- POST_FILENAMES_MAX_RUNES = 4000
- POST_HASHTAGS_MAX_RUNES = 1000
- POST_MESSAGE_MAX_RUNES = 4000
- POST_PROPS_MAX_RUNES = 8000
- POST_PROPS_MAX_USER_RUNES = POST_PROPS_MAX_RUNES - 400 // Leave some room for system / pre-save modifications
- POST_CUSTOM_TYPE_PREFIX = "custom_"
- PROPS_ADD_CHANNEL_MEMBER = "add_channel_member"
-)
-
-type Post struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- EditAt int64 `json:"edit_at"`
- DeleteAt int64 `json:"delete_at"`
- IsPinned bool `json:"is_pinned"`
- UserId string `json:"user_id"`
- ChannelId string `json:"channel_id"`
- RootId string `json:"root_id"`
- ParentId string `json:"parent_id"`
- OriginalId string `json:"original_id"`
- Message string `json:"message"`
- Type string `json:"type"`
- Props StringInterface `json:"props"`
- Hashtags string `json:"hashtags"`
- Filenames StringArray `json:"filenames,omitempty"` // Deprecated, do not use this field any more
- FileIds StringArray `json:"file_ids,omitempty"`
- PendingPostId string `json:"pending_post_id" db:"-"`
- HasReactions bool `json:"has_reactions,omitempty"`
-}
-
-type PostPatch struct {
- IsPinned *bool `json:"is_pinned"`
- Message *string `json:"message"`
- Props *StringInterface `json:"props"`
- FileIds *StringArray `json:"file_ids"`
- HasReactions *bool `json:"has_reactions"`
-}
-
-type PostForIndexing struct {
- Post
- TeamId string `json:"team_id"`
- ParentCreateAt *int64 `json:"parent_create_at"`
-}
-
-type PostAction struct {
- Id string `json:"id"`
- Name string `json:"name"`
- Integration *PostActionIntegration `json:"integration,omitempty"`
-}
-
-type PostActionIntegration struct {
- URL string `json:"url,omitempty"`
- Context StringInterface `json:"context,omitempty"`
-}
-
-type PostActionIntegrationRequest struct {
- UserId string `json:"user_id"`
- Context StringInterface `json:"context,omitempty"`
-}
-
-type PostActionIntegrationResponse struct {
- Update *Post `json:"update"`
- EphemeralText string `json:"ephemeral_text"`
-}
-
-func (o *Post) ToJson() string {
- copy := *o
- copy.StripActionIntegrations()
- b, err := json.Marshal(&copy)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func PostFromJson(data io.Reader) *Post {
- decoder := json.NewDecoder(data)
- var o Post
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *Post) Etag() string {
- return Etag(o.Id, o.UpdateAt)
-}
-
-func (o *Post) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("Post.IsValid", "model.post.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("Post.IsValid", "model.post.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.UserId) != 26 {
- return NewAppError("Post.IsValid", "model.post.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ChannelId) != 26 {
- return NewAppError("Post.IsValid", "model.post.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(len(o.RootId) == 26 || len(o.RootId) == 0) {
- return NewAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(len(o.ParentId) == 26 || len(o.ParentId) == 0) {
- return NewAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.ParentId) == 26 && len(o.RootId) == 0 {
- return NewAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "", http.StatusBadRequest)
- }
-
- if !(len(o.OriginalId) == 26 || len(o.OriginalId) == 0) {
- return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.Message) > POST_MESSAGE_MAX_RUNES {
- return NewAppError("Post.IsValid", "model.post.is_valid.msg.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.Hashtags) > POST_HASHTAGS_MAX_RUNES {
- return NewAppError("Post.IsValid", "model.post.is_valid.hashtags.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- switch o.Type {
- case
- POST_DEFAULT,
- POST_JOIN_LEAVE,
- POST_ADD_REMOVE,
- POST_JOIN_CHANNEL,
- POST_LEAVE_CHANNEL,
- POST_JOIN_TEAM,
- POST_LEAVE_TEAM,
- POST_ADD_TO_CHANNEL,
- POST_REMOVE_FROM_CHANNEL,
- POST_ADD_TO_TEAM,
- POST_REMOVE_FROM_TEAM,
- POST_SLACK_ATTACHMENT,
- POST_HEADER_CHANGE,
- POST_PURPOSE_CHANGE,
- POST_DISPLAYNAME_CHANGE,
- POST_CHANNEL_DELETED:
- default:
- if !strings.HasPrefix(o.Type, POST_CUSTOM_TYPE_PREFIX) {
- return NewAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type, http.StatusBadRequest)
- }
- }
-
- if utf8.RuneCountInString(ArrayToJson(o.Filenames)) > POST_FILENAMES_MAX_RUNES {
- return NewAppError("Post.IsValid", "model.post.is_valid.filenames.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(ArrayToJson(o.FileIds)) > POST_FILEIDS_MAX_RUNES {
- return NewAppError("Post.IsValid", "model.post.is_valid.file_ids.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(StringInterfaceToJson(o.Props)) > POST_PROPS_MAX_RUNES {
- return NewAppError("Post.IsValid", "model.post.is_valid.props.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *Post) SanitizeProps() {
- membersToSanitize := []string{
- PROPS_ADD_CHANNEL_MEMBER,
- }
-
- for _, member := range membersToSanitize {
- if _, ok := o.Props[member]; ok {
- delete(o.Props, member)
- }
- }
-}
-
-func (o *Post) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- o.OriginalId = ""
-
- if o.CreateAt == 0 {
- o.CreateAt = GetMillis()
- }
-
- o.UpdateAt = o.CreateAt
- o.PreCommit()
-}
-
-func (o *Post) PreCommit() {
- if o.Props == nil {
- o.Props = make(map[string]interface{})
- }
-
- if o.Filenames == nil {
- o.Filenames = []string{}
- }
-
- if o.FileIds == nil {
- o.FileIds = []string{}
- }
-
- o.GenerateActionIds()
-}
-
-func (o *Post) MakeNonNil() {
- if o.Props == nil {
- o.Props = make(map[string]interface{})
- }
-}
-
-func (o *Post) AddProp(key string, value interface{}) {
-
- o.MakeNonNil()
-
- o.Props[key] = value
-}
-
-func (o *Post) IsSystemMessage() bool {
- return len(o.Type) >= len(POST_SYSTEM_MESSAGE_PREFIX) && o.Type[:len(POST_SYSTEM_MESSAGE_PREFIX)] == POST_SYSTEM_MESSAGE_PREFIX
-}
-
-func (p *Post) Patch(patch *PostPatch) {
- if patch.IsPinned != nil {
- p.IsPinned = *patch.IsPinned
- }
-
- if patch.Message != nil {
- p.Message = *patch.Message
- }
-
- if patch.Props != nil {
- p.Props = *patch.Props
- }
-
- if patch.FileIds != nil {
- p.FileIds = *patch.FileIds
- }
-
- if patch.HasReactions != nil {
- p.HasReactions = *patch.HasReactions
- }
-}
-
-func (o *PostPatch) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- }
-
- return string(b)
-}
-
-func PostPatchFromJson(data io.Reader) *PostPatch {
- decoder := json.NewDecoder(data)
- var post PostPatch
- err := decoder.Decode(&post)
- if err != nil {
- return nil
- }
-
- return &post
-}
-
-var channelMentionRegexp = regexp.MustCompile(`\B~[a-zA-Z0-9\-_]+`)
-
-func (o *Post) ChannelMentions() (names []string) {
- if strings.Contains(o.Message, "~") {
- alreadyMentioned := make(map[string]bool)
- for _, match := range channelMentionRegexp.FindAllString(o.Message, -1) {
- name := match[1:]
- if !alreadyMentioned[name] {
- names = append(names, name)
- alreadyMentioned[name] = true
- }
- }
- }
- return
-}
-
-func (r *PostActionIntegrationRequest) ToJson() string {
- b, err := json.Marshal(r)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *Post) Attachments() []*SlackAttachment {
- if attachments, ok := o.Props["attachments"].([]*SlackAttachment); ok {
- return attachments
- }
- var ret []*SlackAttachment
- if attachments, ok := o.Props["attachments"].([]interface{}); ok {
- for _, attachment := range attachments {
- if enc, err := json.Marshal(attachment); err == nil {
- var decoded SlackAttachment
- if json.Unmarshal(enc, &decoded) == nil {
- ret = append(ret, &decoded)
- }
- }
- }
- }
- return ret
-}
-
-func (o *Post) StripActionIntegrations() {
- attachments := o.Attachments()
- if o.Props["attachments"] != nil {
- o.Props["attachments"] = attachments
- }
- for _, attachment := range attachments {
- for _, action := range attachment.Actions {
- action.Integration = nil
- }
- }
-}
-
-func (o *Post) GetAction(id string) *PostAction {
- for _, attachment := range o.Attachments() {
- for _, action := range attachment.Actions {
- if action.Id == id {
- return action
- }
- }
- }
- return nil
-}
-
-func (o *Post) GenerateActionIds() {
- if o.Props["attachments"] != nil {
- o.Props["attachments"] = o.Attachments()
- }
- if attachments, ok := o.Props["attachments"].([]*SlackAttachment); ok {
- for _, attachment := range attachments {
- for _, action := range attachment.Actions {
- if action.Id == "" {
- action.Id = NewId()
- }
- }
- }
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/post_list.go b/vendor/github.com/mattermost/platform/model/post_list.go
deleted file mode 100644
index 018f7d14..00000000
--- a/vendor/github.com/mattermost/platform/model/post_list.go
+++ /dev/null
@@ -1,134 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "sort"
-)
-
-type PostList struct {
- Order []string `json:"order"`
- Posts map[string]*Post `json:"posts"`
-}
-
-func NewPostList() *PostList {
- return &PostList{
- Order: make([]string, 0),
- Posts: make(map[string]*Post),
- }
-}
-
-func (o *PostList) StripActionIntegrations() {
- posts := o.Posts
- o.Posts = make(map[string]*Post)
- for id, post := range posts {
- pcopy := *post
- pcopy.StripActionIntegrations()
- o.Posts[id] = &pcopy
- }
-}
-
-func (o *PostList) ToJson() string {
- copy := *o
- copy.StripActionIntegrations()
- b, err := json.Marshal(&copy)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *PostList) MakeNonNil() {
- if o.Order == nil {
- o.Order = make([]string, 0)
- }
-
- if o.Posts == nil {
- o.Posts = make(map[string]*Post)
- }
-
- for _, v := range o.Posts {
- v.MakeNonNil()
- }
-}
-
-func (o *PostList) AddOrder(id string) {
-
- if o.Order == nil {
- o.Order = make([]string, 0, 128)
- }
-
- o.Order = append(o.Order, id)
-}
-
-func (o *PostList) AddPost(post *Post) {
-
- if o.Posts == nil {
- o.Posts = make(map[string]*Post)
- }
-
- o.Posts[post.Id] = post
-}
-
-func (o *PostList) Extend(other *PostList) {
- for _, postId := range other.Order {
- if _, ok := o.Posts[postId]; !ok {
- o.AddPost(other.Posts[postId])
- o.AddOrder(postId)
- }
- }
-}
-
-func (o *PostList) SortByCreateAt() {
- sort.Slice(o.Order, func(i, j int) bool {
- return o.Posts[o.Order[i]].CreateAt > o.Posts[o.Order[j]].CreateAt
- })
-}
-
-func (o *PostList) Etag() string {
-
- id := "0"
- var t int64 = 0
-
- for _, v := range o.Posts {
- if v.UpdateAt > t {
- t = v.UpdateAt
- id = v.Id
- } else if v.UpdateAt == t && v.Id > id {
- t = v.UpdateAt
- id = v.Id
- }
- }
-
- orderId := ""
- if len(o.Order) > 0 {
- orderId = o.Order[0]
- }
-
- return Etag(orderId, id, t)
-}
-
-func (o *PostList) IsChannelId(channelId string) bool {
- for _, v := range o.Posts {
- if v.ChannelId != channelId {
- return false
- }
- }
-
- return true
-}
-
-func PostListFromJson(data io.Reader) *PostList {
- decoder := json.NewDecoder(data)
- var o PostList
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/preference.go b/vendor/github.com/mattermost/platform/model/preference.go
deleted file mode 100644
index 5d462de8..00000000
--- a/vendor/github.com/mattermost/platform/model/preference.go
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "regexp"
- "strings"
- "unicode/utf8"
-)
-
-const (
- PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW = "direct_channel_show"
- PREFERENCE_CATEGORY_TUTORIAL_STEPS = "tutorial_step"
- PREFERENCE_CATEGORY_ADVANCED_SETTINGS = "advanced_settings"
- PREFERENCE_CATEGORY_FLAGGED_POST = "flagged_post"
- PREFERENCE_CATEGORY_FAVORITE_CHANNEL = "favorite_channel"
-
- PREFERENCE_CATEGORY_DISPLAY_SETTINGS = "display_settings"
- PREFERENCE_NAME_COLLAPSE_SETTING = "collapse_previews"
-
- PREFERENCE_CATEGORY_THEME = "theme"
- // the name for theme props is the team id
-
- PREFERENCE_CATEGORY_AUTHORIZED_OAUTH_APP = "oauth_app"
- // the name for oauth_app is the client_id and value is the current scope
-
- PREFERENCE_CATEGORY_LAST = "last"
- PREFERENCE_NAME_LAST_CHANNEL = "channel"
- PREFERENCE_NAME_LAST_TEAM = "team"
-
- PREFERENCE_CATEGORY_NOTIFICATIONS = "notifications"
- PREFERENCE_NAME_EMAIL_INTERVAL = "email_interval"
-
- PREFERENCE_EMAIL_INTERVAL_NO_BATCHING_SECONDS = "30" // the "immediate" setting is actually 30s
- PREFERENCE_EMAIL_INTERVAL_BATCHING_SECONDS = "900" // fifteen minutes is 900 seconds
-)
-
-type Preference struct {
- UserId string `json:"user_id"`
- Category string `json:"category"`
- Name string `json:"name"`
- Value string `json:"value"`
-}
-
-func (o *Preference) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func PreferenceFromJson(data io.Reader) *Preference {
- decoder := json.NewDecoder(data)
- var o Preference
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *Preference) IsValid() *AppError {
- if len(o.UserId) != 26 {
- return NewAppError("Preference.IsValid", "model.preference.is_valid.id.app_error", nil, "user_id="+o.UserId, http.StatusBadRequest)
- }
-
- if len(o.Category) == 0 || len(o.Category) > 32 {
- return NewAppError("Preference.IsValid", "model.preference.is_valid.category.app_error", nil, "category="+o.Category, http.StatusBadRequest)
- }
-
- if len(o.Name) > 32 {
- return NewAppError("Preference.IsValid", "model.preference.is_valid.name.app_error", nil, "name="+o.Name, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.Value) > 2000 {
- return NewAppError("Preference.IsValid", "model.preference.is_valid.value.app_error", nil, "value="+o.Value, http.StatusBadRequest)
- }
-
- if o.Category == PREFERENCE_CATEGORY_THEME {
- var unused map[string]string
- if err := json.NewDecoder(strings.NewReader(o.Value)).Decode(&unused); err != nil {
- return NewAppError("Preference.IsValid", "model.preference.is_valid.theme.app_error", nil, "value="+o.Value, http.StatusBadRequest)
- }
- }
-
- return nil
-}
-
-func (o *Preference) PreUpdate() {
- if o.Category == PREFERENCE_CATEGORY_THEME {
- // decode the value of theme (a map of strings to string) and eliminate any invalid values
- var props map[string]string
- if err := json.NewDecoder(strings.NewReader(o.Value)).Decode(&props); err != nil {
- // just continue, the invalid preference value should get caught by IsValid before saving
- return
- }
-
- colorPattern := regexp.MustCompile(`^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$`)
-
- // blank out any invalid theme values
- for name, value := range props {
- if name == "image" || name == "type" || name == "codeTheme" {
- continue
- }
-
- if !colorPattern.MatchString(value) {
- props[name] = "#ffffff"
- }
- }
-
- if b, err := json.Marshal(props); err == nil {
- o.Value = string(b)
- }
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/preferences.go b/vendor/github.com/mattermost/platform/model/preferences.go
deleted file mode 100644
index b982e309..00000000
--- a/vendor/github.com/mattermost/platform/model/preferences.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type Preferences []Preference
-
-func (o *Preferences) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func PreferencesFromJson(data io.Reader) (Preferences, error) {
- decoder := json.NewDecoder(data)
- var o Preferences
- err := decoder.Decode(&o)
- if err == nil {
- return o, nil
- } else {
- return nil, err
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/push_notification.go b/vendor/github.com/mattermost/platform/model/push_notification.go
deleted file mode 100644
index 69719e74..00000000
--- a/vendor/github.com/mattermost/platform/model/push_notification.go
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "strings"
-)
-
-const (
- PUSH_NOTIFY_APPLE = "apple"
- PUSH_NOTIFY_ANDROID = "android"
- PUSH_NOTIFY_APPLE_REACT_NATIVE = "apple_rn"
- PUSH_NOTIFY_ANDROID_REACT_NATIVE = "android_rn"
-
- PUSH_TYPE_MESSAGE = "message"
- PUSH_TYPE_CLEAR = "clear"
-
- // The category is set to handle a set of interactive Actions
- // with the push notifications
- CATEGORY_CAN_REPLY = "CAN_REPLY"
-
- MHPNS = "https://push.mattermost.com"
-)
-
-type PushNotification struct {
- Platform string `json:"platform"`
- ServerId string `json:"server_id"`
- DeviceId string `json:"device_id"`
- Category string `json:"category"`
- Sound string `json:"sound"`
- Message string `json:"message"`
- Badge int `json:"badge"`
- ContentAvailable int `json:"cont_ava"`
- TeamId string `json:"team_id"`
- ChannelId string `json:"channel_id"`
- PostId string `json:"post_id"`
- RootId string `json:"root_id"`
- ChannelName string `json:"channel_name"`
- Type string `json:"type"`
- SenderId string `json:"sender_id"`
- OverrideUsername string `json:"override_username"`
- OverrideIconUrl string `json:"override_icon_url"`
- FromWebhook string `json:"from_webhook"`
-}
-
-func (me *PushNotification) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (me *PushNotification) SetDeviceIdAndPlatform(deviceId string) {
-
- index := strings.Index(deviceId, ":")
-
- if index > -1 {
- me.Platform = deviceId[:index]
- me.DeviceId = deviceId[index+1:]
- }
-}
-
-func PushNotificationFromJson(data io.Reader) *PushNotification {
- decoder := json.NewDecoder(data)
- var me PushNotification
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/push_response.go b/vendor/github.com/mattermost/platform/model/push_response.go
deleted file mode 100644
index 095986f3..00000000
--- a/vendor/github.com/mattermost/platform/model/push_response.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- PUSH_STATUS = "status"
- PUSH_STATUS_OK = "OK"
- PUSH_STATUS_FAIL = "FAIL"
- PUSH_STATUS_REMOVE = "REMOVE"
- PUSH_STATUS_ERROR_MSG = "error"
-)
-
-type PushResponse map[string]string
-
-func NewOkPushResponse() PushResponse {
- m := make(map[string]string)
- m[PUSH_STATUS] = PUSH_STATUS_OK
- return m
-}
-
-func NewRemovePushResponse() PushResponse {
- m := make(map[string]string)
- m[PUSH_STATUS] = PUSH_STATUS_REMOVE
- return m
-}
-
-func NewErrorPushResponse(message string) PushResponse {
- m := make(map[string]string)
- m[PUSH_STATUS] = PUSH_STATUS_FAIL
- m[PUSH_STATUS_ERROR_MSG] = message
- return m
-}
-
-func (me *PushResponse) ToJson() string {
- if b, err := json.Marshal(me); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func PushResponseFromJson(data io.Reader) PushResponse {
- decoder := json.NewDecoder(data)
-
- var objmap PushResponse
- if err := decoder.Decode(&objmap); err != nil {
- return make(map[string]string)
- } else {
- return objmap
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/reaction.go b/vendor/github.com/mattermost/platform/model/reaction.go
deleted file mode 100644
index 4b72dd44..00000000
--- a/vendor/github.com/mattermost/platform/model/reaction.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "regexp"
-)
-
-type Reaction struct {
- UserId string `json:"user_id"`
- PostId string `json:"post_id"`
- EmojiName string `json:"emoji_name"`
- CreateAt int64 `json:"create_at"`
-}
-
-func (o *Reaction) ToJson() string {
- if b, err := json.Marshal(o); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ReactionFromJson(data io.Reader) *Reaction {
- var o Reaction
-
- if err := json.NewDecoder(data).Decode(&o); err != nil {
- return nil
- } else {
- return &o
- }
-}
-
-func ReactionsToJson(o []*Reaction) string {
- if b, err := json.Marshal(o); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ReactionsFromJson(data io.Reader) []*Reaction {
- var o []*Reaction
-
- if err := json.NewDecoder(data).Decode(&o); err != nil {
- return nil
- } else {
- return o
- }
-}
-
-func (o *Reaction) IsValid() *AppError {
- if len(o.UserId) != 26 {
- return NewAppError("Reaction.IsValid", "model.reaction.is_valid.user_id.app_error", nil, "user_id="+o.UserId, http.StatusBadRequest)
- }
-
- if len(o.PostId) != 26 {
- return NewAppError("Reaction.IsValid", "model.reaction.is_valid.post_id.app_error", nil, "post_id="+o.PostId, http.StatusBadRequest)
- }
-
- validName := regexp.MustCompile(`^[a-zA-Z0-9\-\+_]+$`)
-
- if len(o.EmojiName) == 0 || len(o.EmojiName) > 64 || !validName.MatchString(o.EmojiName) {
- return NewAppError("Reaction.IsValid", "model.reaction.is_valid.emoji_name.app_error", nil, "emoji_name="+o.EmojiName, http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("Reaction.IsValid", "model.reaction.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *Reaction) PreSave() {
- if o.CreateAt == 0 {
- o.CreateAt = GetMillis()
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/saml.go b/vendor/github.com/mattermost/platform/model/saml.go
deleted file mode 100644
index f5826a95..00000000
--- a/vendor/github.com/mattermost/platform/model/saml.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- USER_AUTH_SERVICE_SAML = "saml"
- USER_AUTH_SERVICE_SAML_TEXT = "With SAML"
- SAML_IDP_CERTIFICATE = 1
- SAML_PRIVATE_KEY = 2
- SAML_PUBLIC_CERT = 3
-)
-
-type SamlAuthRequest struct {
- Base64AuthRequest string
- URL string
- RelayState string
-}
-
-type SamlCertificateStatus struct {
- IdpCertificateFile bool `json:"idp_certificate_file"`
- PrivateKeyFile bool `json:"private_key_file"`
- PublicCertificateFile bool `json:"public_certificate_file"`
-}
-
-func (s *SamlCertificateStatus) ToJson() string {
- b, err := json.Marshal(s)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SamlCertificateStatusFromJson(data io.Reader) *SamlCertificateStatus {
- decoder := json.NewDecoder(data)
- var status SamlCertificateStatus
- err := decoder.Decode(&status)
- if err == nil {
- return &status
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/scheduled_task.go b/vendor/github.com/mattermost/platform/model/scheduled_task.go
deleted file mode 100644
index 453828bd..00000000
--- a/vendor/github.com/mattermost/platform/model/scheduled_task.go
+++ /dev/null
@@ -1,110 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "fmt"
- "sync"
- "time"
-)
-
-type TaskFunc func()
-
-type ScheduledTask struct {
- Name string `json:"name"`
- Interval time.Duration `json:"interval"`
- Recurring bool `json:"recurring"`
- function TaskFunc
- timer *time.Timer
-}
-
-var taskMutex = sync.Mutex{}
-var tasks = make(map[string]*ScheduledTask)
-
-func addTask(task *ScheduledTask) {
- taskMutex.Lock()
- defer taskMutex.Unlock()
- tasks[task.Name] = task
-}
-
-func removeTaskByName(name string) {
- taskMutex.Lock()
- defer taskMutex.Unlock()
- delete(tasks, name)
-}
-
-func GetTaskByName(name string) *ScheduledTask {
- taskMutex.Lock()
- defer taskMutex.Unlock()
- if task, ok := tasks[name]; ok {
- return task
- }
- return nil
-}
-
-func GetAllTasks() *map[string]*ScheduledTask {
- taskMutex.Lock()
- defer taskMutex.Unlock()
- return &tasks
-}
-
-func CreateTask(name string, function TaskFunc, timeToExecution time.Duration) *ScheduledTask {
- task := &ScheduledTask{
- Name: name,
- Interval: timeToExecution,
- Recurring: false,
- function: function,
- }
-
- taskRunner := func() {
- go task.function()
- removeTaskByName(task.Name)
- }
-
- task.timer = time.AfterFunc(timeToExecution, taskRunner)
-
- addTask(task)
-
- return task
-}
-
-func CreateRecurringTask(name string, function TaskFunc, interval time.Duration) *ScheduledTask {
- task := &ScheduledTask{
- Name: name,
- Interval: interval,
- Recurring: true,
- function: function,
- }
-
- taskRecurer := func() {
- go task.function()
- task.timer.Reset(task.Interval)
- }
-
- task.timer = time.AfterFunc(interval, taskRecurer)
-
- addTask(task)
-
- return task
-}
-
-func (task *ScheduledTask) Cancel() {
- task.timer.Stop()
- removeTaskByName(task.Name)
-}
-
-// Executes the task immediatly. A recurring task will be run regularally after interval.
-func (task *ScheduledTask) Execute() {
- task.function()
- task.timer.Reset(task.Interval)
-}
-
-func (task *ScheduledTask) String() string {
- return fmt.Sprintf(
- "%s\nInterval: %s\nRecurring: %t\n",
- task.Name,
- task.Interval.String(),
- task.Recurring,
- )
-}
diff --git a/vendor/github.com/mattermost/platform/model/search_params.go b/vendor/github.com/mattermost/platform/model/search_params.go
deleted file mode 100644
index 2feea8da..00000000
--- a/vendor/github.com/mattermost/platform/model/search_params.go
+++ /dev/null
@@ -1,175 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "regexp"
- "strings"
-)
-
-var searchTermPuncStart = regexp.MustCompile(`^[^\pL\d\s#"]+`)
-var searchTermPuncEnd = regexp.MustCompile(`[^\pL\d\s*"]+$`)
-
-type SearchParams struct {
- Terms string
- IsHashtag bool
- InChannels []string
- FromUsers []string
- OrTerms bool
-}
-
-func (o *SearchParams) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-var searchFlags = [...]string{"from", "channel", "in"}
-
-func splitWords(text string) []string {
- words := []string{}
-
- foundQuote := false
- location := 0
- for i, char := range text {
- if char == '"' {
- if foundQuote {
- // Grab the quoted section
- word := text[location : i+1]
- words = append(words, word)
- foundQuote = false
- location = i + 1
- } else {
- words = append(words, strings.Fields(text[location:i])...)
- foundQuote = true
- location = i
- }
- }
- }
-
- words = append(words, strings.Fields(text[location:])...)
-
- return words
-}
-
-func parseSearchFlags(input []string) ([]string, [][2]string) {
- words := []string{}
- flags := [][2]string{}
-
- skipNextWord := false
- for i, word := range input {
- if skipNextWord {
- skipNextWord = false
- continue
- }
-
- isFlag := false
-
- if colon := strings.Index(word, ":"); colon != -1 {
- flag := word[:colon]
- value := word[colon+1:]
-
- for _, searchFlag := range searchFlags {
- // check for case insensitive equality
- if strings.EqualFold(flag, searchFlag) {
- if value != "" {
- flags = append(flags, [2]string{searchFlag, value})
- isFlag = true
- } else if i < len(input)-1 {
- flags = append(flags, [2]string{searchFlag, input[i+1]})
- skipNextWord = true
- isFlag = true
- }
-
- if isFlag {
- break
- }
- }
- }
- }
-
- if !isFlag {
- // trim off surrounding punctuation (note that we leave trailing asterisks to allow wildcards)
- word = searchTermPuncStart.ReplaceAllString(word, "")
- word = searchTermPuncEnd.ReplaceAllString(word, "")
-
- // and remove extra pound #s
- word = hashtagStart.ReplaceAllString(word, "#")
-
- if len(word) != 0 {
- words = append(words, word)
- }
- }
- }
-
- return words, flags
-}
-
-func ParseSearchParams(text string) []*SearchParams {
- words, flags := parseSearchFlags(splitWords(text))
-
- hashtagTermList := []string{}
- plainTermList := []string{}
-
- for _, word := range words {
- if validHashtag.MatchString(word) {
- hashtagTermList = append(hashtagTermList, word)
- } else {
- plainTermList = append(plainTermList, word)
- }
- }
-
- hashtagTerms := strings.Join(hashtagTermList, " ")
- plainTerms := strings.Join(plainTermList, " ")
-
- inChannels := []string{}
- fromUsers := []string{}
-
- for _, flagPair := range flags {
- flag := flagPair[0]
- value := flagPair[1]
-
- if flag == "in" || flag == "channel" {
- inChannels = append(inChannels, value)
- } else if flag == "from" {
- fromUsers = append(fromUsers, value)
- }
- }
-
- paramsList := []*SearchParams{}
-
- if len(plainTerms) > 0 {
- paramsList = append(paramsList, &SearchParams{
- Terms: plainTerms,
- IsHashtag: false,
- InChannels: inChannels,
- FromUsers: fromUsers,
- })
- }
-
- if len(hashtagTerms) > 0 {
- paramsList = append(paramsList, &SearchParams{
- Terms: hashtagTerms,
- IsHashtag: true,
- InChannels: inChannels,
- FromUsers: fromUsers,
- })
- }
-
- // special case for when no terms are specified but we still have a filter
- if len(plainTerms) == 0 && len(hashtagTerms) == 0 && (len(inChannels) != 0 || len(fromUsers) != 0) {
- paramsList = append(paramsList, &SearchParams{
- Terms: "",
- IsHashtag: false,
- InChannels: inChannels,
- FromUsers: fromUsers,
- })
- }
-
- return paramsList
-}
diff --git a/vendor/github.com/mattermost/platform/model/security_bulletin.go b/vendor/github.com/mattermost/platform/model/security_bulletin.go
deleted file mode 100644
index b8c1dc48..00000000
--- a/vendor/github.com/mattermost/platform/model/security_bulletin.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type SecurityBulletin struct {
- Id string `json:"id"`
- AppliesToVersion string `json:"applies_to_version"`
-}
-
-type SecurityBulletins []SecurityBulletin
-
-func (me *SecurityBulletin) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SecurityBulletinFromJson(data io.Reader) *SecurityBulletin {
- decoder := json.NewDecoder(data)
- var o SecurityBulletin
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (me SecurityBulletins) ToJson() string {
- if b, err := json.Marshal(me); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func SecurityBulletinsFromJson(data io.Reader) SecurityBulletins {
- decoder := json.NewDecoder(data)
- var o SecurityBulletins
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/session.go b/vendor/github.com/mattermost/platform/model/session.go
deleted file mode 100644
index 704af067..00000000
--- a/vendor/github.com/mattermost/platform/model/session.go
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "strings"
-)
-
-const (
- SESSION_COOKIE_TOKEN = "MMAUTHTOKEN"
- SESSION_COOKIE_USER = "MMUSERID"
- SESSION_CACHE_SIZE = 35000
- SESSION_PROP_PLATFORM = "platform"
- SESSION_PROP_OS = "os"
- SESSION_PROP_BROWSER = "browser"
- SESSION_PROP_TYPE = "type"
- SESSION_PROP_USER_ACCESS_TOKEN_ID = "user_access_token_id"
- SESSION_TYPE_USER_ACCESS_TOKEN = "UserAccessToken"
- SESSION_ACTIVITY_TIMEOUT = 1000 * 60 * 5 // 5 minutes
- SESSION_USER_ACCESS_TOKEN_EXPIRY = 100 * 365 // 100 years
-)
-
-type Session struct {
- Id string `json:"id"`
- Token string `json:"token"`
- CreateAt int64 `json:"create_at"`
- ExpiresAt int64 `json:"expires_at"`
- LastActivityAt int64 `json:"last_activity_at"`
- UserId string `json:"user_id"`
- DeviceId string `json:"device_id"`
- Roles string `json:"roles"`
- IsOAuth bool `json:"is_oauth"`
- Props StringMap `json:"props"`
- TeamMembers []*TeamMember `json:"team_members" db:"-"`
-}
-
-func (me *Session) DeepCopy() *Session {
- copy := *me
- return &copy
-}
-
-func (me *Session) ToJson() string {
- b, err := json.Marshal(me)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SessionFromJson(data io.Reader) *Session {
- decoder := json.NewDecoder(data)
- var me Session
- err := decoder.Decode(&me)
- if err == nil {
- return &me
- } else {
- return nil
- }
-}
-
-func (me *Session) PreSave() {
- if me.Id == "" {
- me.Id = NewId()
- }
-
- if me.Token == "" {
- me.Token = NewId()
- }
-
- me.CreateAt = GetMillis()
- me.LastActivityAt = me.CreateAt
-
- if me.Props == nil {
- me.Props = make(map[string]string)
- }
-}
-
-func (me *Session) Sanitize() {
- me.Token = ""
-}
-
-func (me *Session) IsExpired() bool {
-
- if me.ExpiresAt <= 0 {
- return false
- }
-
- if GetMillis() > me.ExpiresAt {
- return true
- }
-
- return false
-}
-
-func (me *Session) SetExpireInDays(days int) {
- if me.CreateAt == 0 {
- me.ExpiresAt = GetMillis() + (1000 * 60 * 60 * 24 * int64(days))
- } else {
- me.ExpiresAt = me.CreateAt + (1000 * 60 * 60 * 24 * int64(days))
- }
-}
-
-func (me *Session) AddProp(key string, value string) {
-
- if me.Props == nil {
- me.Props = make(map[string]string)
- }
-
- me.Props[key] = value
-}
-
-func (me *Session) GetTeamByTeamId(teamId string) *TeamMember {
- for _, team := range me.TeamMembers {
- if team.TeamId == teamId {
- return team
- }
- }
-
- return nil
-}
-
-func (me *Session) IsMobileApp() bool {
- return len(me.DeviceId) > 0
-}
-
-func (me *Session) GetUserRoles() []string {
- return strings.Fields(me.Roles)
-}
-
-func SessionsToJson(o []*Session) string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func SessionsFromJson(data io.Reader) []*Session {
- decoder := json.NewDecoder(data)
- var o []*Session
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/slack_attachment.go b/vendor/github.com/mattermost/platform/model/slack_attachment.go
deleted file mode 100644
index 197d3f0f..00000000
--- a/vendor/github.com/mattermost/platform/model/slack_attachment.go
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "fmt"
-)
-
-type SlackAttachment struct {
- Id int64 `json:"id"`
- Fallback string `json:"fallback"`
- Color string `json:"color"`
- Pretext string `json:"pretext"`
- AuthorName string `json:"author_name"`
- AuthorLink string `json:"author_link"`
- AuthorIcon string `json:"author_icon"`
- Title string `json:"title"`
- TitleLink string `json:"title_link"`
- Text string `json:"text"`
- Fields []*SlackAttachmentField `json:"fields"`
- ImageURL string `json:"image_url"`
- ThumbURL string `json:"thumb_url"`
- Footer string `json:"footer"`
- FooterIcon string `json:"footer_icon"`
- Timestamp interface{} `json:"ts"` // This is either a string or an int64
- Actions []*PostAction `json:"actions,omitempty"`
-}
-
-type SlackAttachmentField struct {
- Title string `json:"title"`
- Value interface{} `json:"value"`
- Short bool `json:"short"`
-}
-
-func StringifySlackFieldValue(a []*SlackAttachment) []*SlackAttachment {
- var nonNilAttachments []*SlackAttachment
- for _, attachment := range a {
- if attachment == nil {
- continue
- }
- nonNilAttachments = append(nonNilAttachments, attachment)
-
- var nonNilFields []*SlackAttachmentField
- for _, field := range attachment.Fields {
- if field == nil {
- continue
- }
- nonNilFields = append(nonNilFields, field)
-
- if field.Value != nil {
- // Ensure the value is set to a string if it is set
- field.Value = fmt.Sprintf("%v", field.Value)
- }
- }
- attachment.Fields = nonNilFields
- }
- return nonNilAttachments
-}
diff --git a/vendor/github.com/mattermost/platform/model/status.go b/vendor/github.com/mattermost/platform/model/status.go
deleted file mode 100644
index 6da6161e..00000000
--- a/vendor/github.com/mattermost/platform/model/status.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- STATUS_OFFLINE = "offline"
- STATUS_AWAY = "away"
- STATUS_DND = "dnd"
- STATUS_ONLINE = "online"
- STATUS_CACHE_SIZE = SESSION_CACHE_SIZE
- STATUS_CHANNEL_TIMEOUT = 20000 // 20 seconds
- STATUS_MIN_UPDATE_TIME = 120000 // 2 minutes
-)
-
-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:"-" db:"-"`
-}
-
-func (o *Status) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func StatusFromJson(data io.Reader) *Status {
- decoder := json.NewDecoder(data)
- var o Status
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func StatusListToJson(u []*Status) string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func StatusListFromJson(data io.Reader) []*Status {
- decoder := json.NewDecoder(data)
- var statuses []*Status
- err := decoder.Decode(&statuses)
- if err == nil {
- return statuses
- } else {
- return nil
- }
-}
-
-func StatusMapToInterfaceMap(statusMap map[string]*Status) map[string]interface{} {
- interfaceMap := map[string]interface{}{}
- for _, s := range statusMap {
- // Omitted statues mean offline
- if s.Status != STATUS_OFFLINE {
- interfaceMap[s.UserId] = s.Status
- }
- }
- return interfaceMap
-}
diff --git a/vendor/github.com/mattermost/platform/model/suggest_command.go b/vendor/github.com/mattermost/platform/model/suggest_command.go
deleted file mode 100644
index 3d066499..00000000
--- a/vendor/github.com/mattermost/platform/model/suggest_command.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type SuggestCommand struct {
- Suggestion string `json:"suggestion"`
- Description string `json:"description"`
-}
-
-func (o *SuggestCommand) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SuggestCommandFromJson(data io.Reader) *SuggestCommand {
- decoder := json.NewDecoder(data)
- var o SuggestCommand
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/switch_request.go b/vendor/github.com/mattermost/platform/model/switch_request.go
deleted file mode 100644
index 10039294..00000000
--- a/vendor/github.com/mattermost/platform/model/switch_request.go
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type SwitchRequest struct {
- CurrentService string `json:"current_service"`
- NewService string `json:"new_service"`
- Email string `json:"email"`
- Password string `json:"password"`
- NewPassword string `json:"new_password"`
- MfaCode string `json:"mfa_code"`
- LdapId string `json:"ldap_id"`
-}
-
-func (o *SwitchRequest) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SwitchRequestFromJson(data io.Reader) *SwitchRequest {
- decoder := json.NewDecoder(data)
- var o SwitchRequest
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *SwitchRequest) EmailToOAuth() bool {
- return o.CurrentService == USER_AUTH_SERVICE_EMAIL &&
- (o.NewService == USER_AUTH_SERVICE_SAML ||
- o.NewService == USER_AUTH_SERVICE_GITLAB ||
- o.NewService == SERVICE_GOOGLE ||
- o.NewService == SERVICE_OFFICE365)
-}
-
-func (o *SwitchRequest) OAuthToEmail() bool {
- return (o.CurrentService == USER_AUTH_SERVICE_SAML ||
- o.CurrentService == USER_AUTH_SERVICE_GITLAB ||
- o.CurrentService == SERVICE_GOOGLE ||
- o.CurrentService == SERVICE_OFFICE365) && o.NewService == USER_AUTH_SERVICE_EMAIL
-}
-
-func (o *SwitchRequest) EmailToLdap() bool {
- return o.CurrentService == USER_AUTH_SERVICE_EMAIL && o.NewService == USER_AUTH_SERVICE_LDAP
-}
-
-func (o *SwitchRequest) LdapToEmail() bool {
- return o.CurrentService == USER_AUTH_SERVICE_LDAP && o.NewService == USER_AUTH_SERVICE_EMAIL
-}
diff --git a/vendor/github.com/mattermost/platform/model/system.go b/vendor/github.com/mattermost/platform/model/system.go
deleted file mode 100644
index e2f4283a..00000000
--- a/vendor/github.com/mattermost/platform/model/system.go
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- SYSTEM_DIAGNOSTIC_ID = "DiagnosticId"
- SYSTEM_RAN_UNIT_TESTS = "RanUnitTests"
- SYSTEM_LAST_SECURITY_TIME = "LastSecurityTime"
- SYSTEM_ACTIVE_LICENSE_ID = "ActiveLicenseId"
- SYSTEM_LAST_COMPLIANCE_TIME = "LastComplianceTime"
-)
-
-type System struct {
- Name string `json:"name"`
- Value string `json:"value"`
-}
-
-func (o *System) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func SystemFromJson(data io.Reader) *System {
- decoder := json.NewDecoder(data)
- var o System
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/team.go b/vendor/github.com/mattermost/platform/model/team.go
deleted file mode 100644
index 4fe03f2f..00000000
--- a/vendor/github.com/mattermost/platform/model/team.go
+++ /dev/null
@@ -1,330 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "regexp"
- "strings"
- "unicode/utf8"
-)
-
-const (
- TEAM_OPEN = "O"
- TEAM_INVITE = "I"
- TEAM_ALLOWED_DOMAINS_MAX_LENGTH = 500
- TEAM_COMPANY_NAME_MAX_LENGTH = 64
- TEAM_DESCRIPTION_MAX_LENGTH = 255
- TEAM_DISPLAY_NAME_MAX_RUNES = 64
- TEAM_EMAIL_MAX_LENGTH = 128
- TEAM_NAME_MAX_LENGTH = 64
- TEAM_NAME_MIN_LENGTH = 2
-)
-
-type Team struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at"`
- UpdateAt int64 `json:"update_at"`
- DeleteAt int64 `json:"delete_at"`
- DisplayName string `json:"display_name"`
- Name string `json:"name"`
- Description string `json:"description"`
- Email string `json:"email"`
- Type string `json:"type"`
- CompanyName string `json:"company_name"`
- AllowedDomains string `json:"allowed_domains"`
- InviteId string `json:"invite_id"`
- AllowOpenInvite bool `json:"allow_open_invite"`
-}
-
-type TeamPatch struct {
- DisplayName *string `json:"display_name"`
- Description *string `json:"description"`
- CompanyName *string `json:"company_name"`
- InviteId *string `json:"invite_id"`
- AllowOpenInvite *bool `json:"allow_open_invite"`
-}
-
-type Invites struct {
- Invites []map[string]string `json:"invites"`
-}
-
-func InvitesFromJson(data io.Reader) *Invites {
- decoder := json.NewDecoder(data)
- var o Invites
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *Invites) ToEmailList() []string {
- emailList := make([]string, len(o.Invites))
- for _, invite := range o.Invites {
- emailList = append(emailList, invite["email"])
- }
- return emailList
-}
-
-func (o *Invites) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *Team) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func TeamFromJson(data io.Reader) *Team {
- decoder := json.NewDecoder(data)
- var o Team
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func TeamMapToJson(u map[string]*Team) string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func TeamMapFromJson(data io.Reader) map[string]*Team {
- decoder := json.NewDecoder(data)
- var teams map[string]*Team
- err := decoder.Decode(&teams)
- if err == nil {
- return teams
- } else {
- return nil
- }
-}
-
-func TeamListToJson(t []*Team) string {
- b, err := json.Marshal(t)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func TeamListFromJson(data io.Reader) []*Team {
- decoder := json.NewDecoder(data)
- var teams []*Team
- err := decoder.Decode(&teams)
- if err == nil {
- return teams
- } else {
- return nil
- }
-}
-
-func (o *Team) Etag() string {
- return Etag(o.Id, o.UpdateAt)
-}
-
-func (o *Team) IsValid() *AppError {
-
- if len(o.Id) != 26 {
- return NewAppError("Team.IsValid", "model.team.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if o.CreateAt == 0 {
- return NewAppError("Team.IsValid", "model.team.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if o.UpdateAt == 0 {
- return NewAppError("Team.IsValid", "model.team.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.Email) > TEAM_EMAIL_MAX_LENGTH {
- return NewAppError("Team.IsValid", "model.team.is_valid.email.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.Email) > 0 && !IsValidEmail(o.Email) {
- return NewAppError("Team.IsValid", "model.team.is_valid.email.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if utf8.RuneCountInString(o.DisplayName) == 0 || utf8.RuneCountInString(o.DisplayName) > TEAM_DISPLAY_NAME_MAX_RUNES {
- return NewAppError("Team.IsValid", "model.team.is_valid.name.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.Name) > TEAM_NAME_MAX_LENGTH {
- return NewAppError("Team.IsValid", "model.team.is_valid.url.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.Description) > TEAM_DESCRIPTION_MAX_LENGTH {
- return NewAppError("Team.IsValid", "model.team.is_valid.description.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if IsReservedTeamName(o.Name) {
- return NewAppError("Team.IsValid", "model.team.is_valid.reserved.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if !IsValidTeamName(o.Name) {
- return NewAppError("Team.IsValid", "model.team.is_valid.characters.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if !(o.Type == TEAM_OPEN || o.Type == TEAM_INVITE) {
- return NewAppError("Team.IsValid", "model.team.is_valid.type.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.CompanyName) > TEAM_COMPANY_NAME_MAX_LENGTH {
- return NewAppError("Team.IsValid", "model.team.is_valid.company.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- if len(o.AllowedDomains) > TEAM_ALLOWED_DOMAINS_MAX_LENGTH {
- return NewAppError("Team.IsValid", "model.team.is_valid.domains.app_error", nil, "id="+o.Id, http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *Team) PreSave() {
- if o.Id == "" {
- o.Id = NewId()
- }
-
- o.CreateAt = GetMillis()
- o.UpdateAt = o.CreateAt
-
- if len(o.InviteId) == 0 {
- o.InviteId = NewId()
- }
-}
-
-func (o *Team) PreUpdate() {
- o.UpdateAt = GetMillis()
-}
-
-func IsReservedTeamName(s string) bool {
- s = strings.ToLower(s)
-
- for _, value := range reservedName {
- if strings.Index(s, value) == 0 {
- return true
- }
- }
-
- return false
-}
-
-func IsValidTeamName(s string) bool {
-
- if !IsValidAlphaNum(s) {
- return false
- }
-
- if len(s) < TEAM_NAME_MIN_LENGTH {
- return false
- }
-
- return true
-}
-
-var validTeamNameCharacter = regexp.MustCompile(`^[a-z0-9-]$`)
-
-func CleanTeamName(s string) string {
- s = strings.ToLower(strings.Replace(s, " ", "-", -1))
-
- for _, value := range reservedName {
- if strings.Index(s, value) == 0 {
- s = strings.Replace(s, value, "", -1)
- }
- }
-
- s = strings.TrimSpace(s)
-
- for _, c := range s {
- char := fmt.Sprintf("%c", c)
- if !validTeamNameCharacter.MatchString(char) {
- s = strings.Replace(s, char, "", -1)
- }
- }
-
- s = strings.Trim(s, "-")
-
- if !IsValidTeamName(s) {
- s = NewId()
- }
-
- return s
-}
-
-func (o *Team) Sanitize() {
- o.Email = ""
- o.AllowedDomains = ""
-}
-
-func (o *Team) SanitizeForNotLoggedIn() {
- o.Email = ""
- o.AllowedDomains = ""
- o.CompanyName = ""
- if !o.AllowOpenInvite {
- o.InviteId = ""
- }
-}
-
-func (t *Team) Patch(patch *TeamPatch) {
- if patch.DisplayName != nil {
- t.DisplayName = *patch.DisplayName
- }
-
- if patch.Description != nil {
- t.Description = *patch.Description
- }
-
- if patch.CompanyName != nil {
- t.CompanyName = *patch.CompanyName
- }
-
- if patch.InviteId != nil {
- t.InviteId = *patch.InviteId
- }
-
- if patch.AllowOpenInvite != nil {
- t.AllowOpenInvite = *patch.AllowOpenInvite
- }
-}
-
-func (t *TeamPatch) ToJson() string {
- b, err := json.Marshal(t)
- if err != nil {
- return ""
- }
-
- return string(b)
-}
-
-func TeamPatchFromJson(data io.Reader) *TeamPatch {
- decoder := json.NewDecoder(data)
- var team TeamPatch
- err := decoder.Decode(&team)
- if err != nil {
- return nil
- }
-
- return &team
-}
diff --git a/vendor/github.com/mattermost/platform/model/team_member.go b/vendor/github.com/mattermost/platform/model/team_member.go
deleted file mode 100644
index 6c70b75e..00000000
--- a/vendor/github.com/mattermost/platform/model/team_member.go
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
- "strings"
-)
-
-type TeamMember struct {
- TeamId string `json:"team_id"`
- UserId string `json:"user_id"`
- Roles string `json:"roles"`
- DeleteAt int64 `json:"delete_at"`
-}
-
-type TeamUnread struct {
- TeamId string `json:"team_id"`
- MsgCount int64 `json:"msg_count"`
- MentionCount int64 `json:"mention_count"`
-}
-
-func (o *TeamMember) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (o *TeamUnread) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func TeamMemberFromJson(data io.Reader) *TeamMember {
- decoder := json.NewDecoder(data)
- var o TeamMember
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func TeamUnreadFromJson(data io.Reader) *TeamUnread {
- decoder := json.NewDecoder(data)
- var o TeamUnread
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func TeamMembersToJson(o []*TeamMember) string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func TeamMembersFromJson(data io.Reader) []*TeamMember {
- decoder := json.NewDecoder(data)
- var o []*TeamMember
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
-
-func TeamsUnreadToJson(o []*TeamUnread) string {
- if b, err := json.Marshal(o); err != nil {
- return "[]"
- } else {
- return string(b)
- }
-}
-
-func TeamsUnreadFromJson(data io.Reader) []*TeamUnread {
- decoder := json.NewDecoder(data)
- var o []*TeamUnread
- err := decoder.Decode(&o)
- if err == nil {
- return o
- } else {
- return nil
- }
-}
-
-func (o *TeamMember) IsValid() *AppError {
-
- if len(o.TeamId) != 26 {
- return NewAppError("TeamMember.IsValid", "model.team_member.is_valid.team_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(o.UserId) != 26 {
- return NewAppError("TeamMember.IsValid", "model.team_member.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (o *TeamMember) PreUpdate() {
-}
-
-func (o *TeamMember) GetRoles() []string {
- return strings.Fields(o.Roles)
-}
diff --git a/vendor/github.com/mattermost/platform/model/team_search.go b/vendor/github.com/mattermost/platform/model/team_search.go
deleted file mode 100644
index e0676022..00000000
--- a/vendor/github.com/mattermost/platform/model/team_search.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type TeamSearch struct {
- Term string `json:"term"`
-}
-
-// ToJson convert a TeamSearch to json string
-func (c *TeamSearch) ToJson() string {
- b, err := json.Marshal(c)
- if err != nil {
- return ""
- }
-
- return string(b)
-}
-
-// TeamSearchFromJson decodes the input and returns a TeamSearch
-func TeamSearchFromJson(data io.Reader) *TeamSearch {
- decoder := json.NewDecoder(data)
- var cs TeamSearch
- err := decoder.Decode(&cs)
- if err == nil {
- return &cs
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/team_stats.go b/vendor/github.com/mattermost/platform/model/team_stats.go
deleted file mode 100644
index e94ed37b..00000000
--- a/vendor/github.com/mattermost/platform/model/team_stats.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type TeamStats struct {
- TeamId string `json:"team_id"`
- TotalMemberCount int64 `json:"total_member_count"`
- ActiveMemberCount int64 `json:"active_member_count"`
-}
-
-func (o *TeamStats) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func TeamStatsFromJson(data io.Reader) *TeamStats {
- decoder := json.NewDecoder(data)
- var o TeamStats
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/token.go b/vendor/github.com/mattermost/platform/model/token.go
deleted file mode 100644
index a4d10c7f..00000000
--- a/vendor/github.com/mattermost/platform/model/token.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import "net/http"
-
-const (
- TOKEN_SIZE = 64
- MAX_TOKEN_EXIPRY_TIME = 1000 * 60 * 60 * 24 // 24 hour
- TOKEN_TYPE_OAUTH = "oauth"
-)
-
-type Token struct {
- Token string
- CreateAt int64
- Type string
- Extra string
-}
-
-func NewToken(tokentype, extra string) *Token {
- return &Token{
- Token: NewRandomString(TOKEN_SIZE),
- CreateAt: GetMillis(),
- Type: tokentype,
- Extra: extra,
- }
-}
-
-func (t *Token) IsValid() *AppError {
- if len(t.Token) != TOKEN_SIZE {
- return NewAppError("Token.IsValid", "model.token.is_valid.size", nil, "", http.StatusInternalServerError)
- }
-
- if t.CreateAt == 0 {
- return NewAppError("Token.IsValid", "model.token.is_valid.expiry", nil, "", http.StatusInternalServerError)
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/user.go b/vendor/github.com/mattermost/platform/model/user.go
deleted file mode 100644
index 7e767fd5..00000000
--- a/vendor/github.com/mattermost/platform/model/user.go
+++ /dev/null
@@ -1,653 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "fmt"
- "io"
- "net/http"
- "regexp"
- "strings"
- "unicode/utf8"
-
- "golang.org/x/crypto/bcrypt"
-)
-
-const (
- ME = "me"
- USER_NOTIFY_ALL = "all"
- USER_NOTIFY_MENTION = "mention"
- USER_NOTIFY_NONE = "none"
- DESKTOP_NOTIFY_PROP = "desktop"
- DESKTOP_SOUND_NOTIFY_PROP = "desktop_sound"
- DESKTOP_DURATION_NOTIFY_PROP = "desktop_duration"
- MARK_UNREAD_NOTIFY_PROP = "mark_unread"
- PUSH_NOTIFY_PROP = "push"
- PUSH_STATUS_NOTIFY_PROP = "push_status"
- EMAIL_NOTIFY_PROP = "email"
- CHANNEL_MENTIONS_NOTIFY_PROP = "channel"
- COMMENTS_NOTIFY_PROP = "comments"
- MENTION_KEYS_NOTIFY_PROP = "mention_keys"
- COMMENTS_NOTIFY_NEVER = "never"
- COMMENTS_NOTIFY_ROOT = "root"
- COMMENTS_NOTIFY_ANY = "any"
-
- DEFAULT_LOCALE = "en"
- USER_AUTH_SERVICE_EMAIL = "email"
-
- USER_EMAIL_MAX_LENGTH = 128
- USER_NICKNAME_MAX_RUNES = 64
- USER_POSITION_MAX_RUNES = 64
- USER_FIRST_NAME_MAX_RUNES = 64
- USER_LAST_NAME_MAX_RUNES = 64
- USER_AUTH_DATA_MAX_LENGTH = 128
- USER_NAME_MAX_LENGTH = 64
- USER_NAME_MIN_LENGTH = 1
- USER_PASSWORD_MAX_LENGTH = 72
-)
-
-type User struct {
- Id string `json:"id"`
- CreateAt int64 `json:"create_at,omitempty"`
- UpdateAt int64 `json:"update_at,omitempty"`
- DeleteAt int64 `json:"delete_at"`
- Username string `json:"username"`
- Password string `json:"password,omitempty"`
- AuthData *string `json:"auth_data,omitempty"`
- AuthService string `json:"auth_service"`
- Email string `json:"email"`
- EmailVerified bool `json:"email_verified,omitempty"`
- Nickname string `json:"nickname"`
- FirstName string `json:"first_name"`
- LastName string `json:"last_name"`
- Position string `json:"position"`
- Roles string `json:"roles"`
- AllowMarketing bool `json:"allow_marketing,omitempty"`
- Props StringMap `json:"props,omitempty"`
- NotifyProps StringMap `json:"notify_props,omitempty"`
- LastPasswordUpdate int64 `json:"last_password_update,omitempty"`
- LastPictureUpdate int64 `json:"last_picture_update,omitempty"`
- FailedAttempts int `json:"failed_attempts,omitempty"`
- Locale string `json:"locale"`
- MfaActive bool `json:"mfa_active,omitempty"`
- MfaSecret string `json:"mfa_secret,omitempty"`
- LastActivityAt int64 `db:"-" json:"last_activity_at,omitempty"`
-}
-
-type UserPatch struct {
- Username *string `json:"username"`
- Nickname *string `json:"nickname"`
- FirstName *string `json:"first_name"`
- LastName *string `json:"last_name"`
- Position *string `json:"position"`
- Email *string `json:"email"`
- Props StringMap `json:"props,omitempty"`
- NotifyProps StringMap `json:"notify_props,omitempty"`
- Locale *string `json:"locale"`
-}
-
-type UserAuth struct {
- Password string `json:"password,omitempty"`
- AuthData *string `json:"auth_data,omitempty"`
- AuthService string `json:"auth_service,omitempty"`
-}
-
-// IsValid validates the user and returns an error if it isn't configured
-// correctly.
-func (u *User) IsValid() *AppError {
-
- if len(u.Id) != 26 {
- return InvalidUserError("id", "")
- }
-
- if u.CreateAt == 0 {
- return InvalidUserError("create_at", u.Id)
- }
-
- if u.UpdateAt == 0 {
- return InvalidUserError("update_at", u.Id)
- }
-
- if !IsValidUsername(u.Username) {
- return InvalidUserError("username", u.Id)
- }
-
- if len(u.Email) > USER_EMAIL_MAX_LENGTH || len(u.Email) == 0 {
- return InvalidUserError("email", u.Id)
- }
-
- if utf8.RuneCountInString(u.Nickname) > USER_NICKNAME_MAX_RUNES {
- return InvalidUserError("nickname", u.Id)
- }
-
- if utf8.RuneCountInString(u.Position) > USER_POSITION_MAX_RUNES {
- return InvalidUserError("position", u.Id)
- }
-
- if utf8.RuneCountInString(u.FirstName) > USER_FIRST_NAME_MAX_RUNES {
- return InvalidUserError("first_name", u.Id)
- }
-
- if utf8.RuneCountInString(u.LastName) > USER_LAST_NAME_MAX_RUNES {
- return InvalidUserError("last_name", u.Id)
- }
-
- if u.AuthData != nil && len(*u.AuthData) > USER_AUTH_DATA_MAX_LENGTH {
- return InvalidUserError("auth_data", u.Id)
- }
-
- if u.AuthData != nil && len(*u.AuthData) > 0 && len(u.AuthService) == 0 {
- return InvalidUserError("auth_data_type", u.Id)
- }
-
- if len(u.Password) > 0 && u.AuthData != nil && len(*u.AuthData) > 0 {
- return InvalidUserError("auth_data_pwd", u.Id)
- }
-
- if len(u.Password) > USER_PASSWORD_MAX_LENGTH {
- return InvalidUserError("password_limit", u.Id)
- }
-
- return nil
-}
-
-func InvalidUserError(fieldName string, userId string) *AppError {
- id := fmt.Sprintf("model.user.is_valid.%s.app_error", fieldName)
- details := ""
- if userId != "" {
- details = "user_id=" + userId
- }
- return NewAppError("User.IsValid", id, nil, details, http.StatusBadRequest)
-}
-
-// PreSave will set the Id and Username if missing. It will also fill
-// in the CreateAt, UpdateAt times. It will also hash the password. It should
-// be run before saving the user to the db.
-func (u *User) PreSave() {
- if u.Id == "" {
- u.Id = NewId()
- }
-
- if u.Username == "" {
- u.Username = NewId()
- }
-
- if u.AuthData != nil && *u.AuthData == "" {
- u.AuthData = nil
- }
-
- u.Username = strings.ToLower(u.Username)
- u.Email = strings.ToLower(u.Email)
-
- u.CreateAt = GetMillis()
- u.UpdateAt = u.CreateAt
-
- u.LastPasswordUpdate = u.CreateAt
-
- u.MfaActive = false
-
- if u.Locale == "" {
- u.Locale = DEFAULT_LOCALE
- }
-
- if u.Props == nil {
- u.Props = make(map[string]string)
- }
-
- if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
- u.SetDefaultNotifications()
- }
-
- if len(u.Password) > 0 {
- u.Password = HashPassword(u.Password)
- }
-}
-
-// PreUpdate should be run before updating the user in the db.
-func (u *User) PreUpdate() {
- u.Username = strings.ToLower(u.Username)
- u.Email = strings.ToLower(u.Email)
- u.UpdateAt = GetMillis()
-
- if u.AuthData != nil && *u.AuthData == "" {
- u.AuthData = nil
- }
-
- if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
- u.SetDefaultNotifications()
- } else if _, ok := u.NotifyProps["mention_keys"]; ok {
- // Remove any blank mention keys
- splitKeys := strings.Split(u.NotifyProps["mention_keys"], ",")
- goodKeys := []string{}
- for _, key := range splitKeys {
- if len(key) > 0 {
- goodKeys = append(goodKeys, strings.ToLower(key))
- }
- }
- u.NotifyProps["mention_keys"] = strings.Join(goodKeys, ",")
- }
-}
-
-func (u *User) SetDefaultNotifications() {
- u.NotifyProps = make(map[string]string)
- u.NotifyProps["email"] = "true"
- u.NotifyProps["push"] = USER_NOTIFY_MENTION
- u.NotifyProps["desktop"] = USER_NOTIFY_MENTION
- u.NotifyProps["desktop_sound"] = "true"
- u.NotifyProps["mention_keys"] = u.Username + ",@" + u.Username
- u.NotifyProps["channel"] = "true"
- u.NotifyProps["push_status"] = STATUS_AWAY
- u.NotifyProps["comments"] = "never"
- u.NotifyProps["first_name"] = "false"
-}
-
-func (user *User) UpdateMentionKeysFromUsername(oldUsername string) {
- nonUsernameKeys := []string{}
- splitKeys := strings.Split(user.NotifyProps["mention_keys"], ",")
- for _, key := range splitKeys {
- if key != oldUsername && key != "@"+oldUsername {
- nonUsernameKeys = append(nonUsernameKeys, key)
- }
- }
-
- user.NotifyProps["mention_keys"] = user.Username + ",@" + user.Username
- if len(nonUsernameKeys) > 0 {
- user.NotifyProps["mention_keys"] += "," + strings.Join(nonUsernameKeys, ",")
- }
-}
-
-func (u *User) Patch(patch *UserPatch) {
- if patch.Username != nil {
- u.Username = *patch.Username
- }
-
- if patch.Nickname != nil {
- u.Nickname = *patch.Nickname
- }
-
- if patch.FirstName != nil {
- u.FirstName = *patch.FirstName
- }
-
- if patch.LastName != nil {
- u.LastName = *patch.LastName
- }
-
- if patch.Position != nil {
- u.Position = *patch.Position
- }
-
- if patch.Email != nil {
- u.Email = *patch.Email
- }
-
- if patch.Props != nil {
- u.Props = patch.Props
- }
-
- if patch.NotifyProps != nil {
- u.NotifyProps = patch.NotifyProps
- }
-
- if patch.Locale != nil {
- u.Locale = *patch.Locale
- }
-}
-
-// ToJson convert a User to a json string
-func (u *User) ToJson() string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (u *UserPatch) ToJson() string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func (u *UserAuth) ToJson() string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// Generate a valid strong etag so the browser can cache the results
-func (u *User) Etag(showFullName, showEmail bool) string {
- return Etag(u.Id, u.UpdateAt, showFullName, showEmail)
-}
-
-// Remove any private data from the user object
-func (u *User) Sanitize(options map[string]bool) {
- u.Password = ""
- u.AuthData = NewString("")
- u.MfaSecret = ""
-
- if len(options) != 0 && !options["email"] {
- u.Email = ""
- }
- if len(options) != 0 && !options["fullname"] {
- u.FirstName = ""
- u.LastName = ""
- }
- if len(options) != 0 && !options["passwordupdate"] {
- u.LastPasswordUpdate = 0
- }
- if len(options) != 0 && !options["authservice"] {
- u.AuthService = ""
- }
-}
-
-func (u *User) ClearNonProfileFields() {
- u.Password = ""
- u.AuthData = NewString("")
- u.MfaSecret = ""
- u.EmailVerified = false
- u.AllowMarketing = false
- u.NotifyProps = StringMap{}
- u.LastPasswordUpdate = 0
- 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)
- }
-
- if u.NotifyProps == nil {
- u.NotifyProps = make(map[string]string)
- }
-}
-
-func (u *User) AddProp(key string, value string) {
- u.MakeNonNil()
-
- u.Props[key] = value
-}
-
-func (u *User) AddNotifyProp(key string, value string) {
- u.MakeNonNil()
-
- u.NotifyProps[key] = value
-}
-
-func (u *User) GetFullName() string {
- if u.FirstName != "" && u.LastName != "" {
- return u.FirstName + " " + u.LastName
- } else if u.FirstName != "" {
- return u.FirstName
- } else if u.LastName != "" {
- return u.LastName
- } else {
- return ""
- }
-}
-
-func (u *User) GetDisplayName(nameFormat string) string {
- displayName := u.Username
-
- if nameFormat == SHOW_NICKNAME_FULLNAME {
- if u.Nickname != "" {
- displayName = u.Nickname
- } else if fullName := u.GetFullName(); fullName != "" {
- displayName = fullName
- }
- } else if nameFormat == SHOW_FULLNAME {
- if fullName := u.GetFullName(); fullName != "" {
- displayName = fullName
- }
- }
-
- return displayName
-}
-
-func (u *User) GetRoles() []string {
- return strings.Fields(u.Roles)
-}
-
-func (u *User) GetRawRoles() string {
- return u.Roles
-}
-
-func IsValidUserRoles(userRoles string) bool {
-
- roles := strings.Fields(userRoles)
-
- for _, r := range roles {
- if !isValidRole(r) {
- return false
- }
- }
-
- // Exclude just the system_admin role explicitly to prevent mistakes
- if len(roles) == 1 && roles[0] == "system_admin" {
- return false
- }
-
- return true
-}
-
-func isValidRole(roleId string) bool {
- _, ok := DefaultRoles[roleId]
- return ok
-}
-
-// Make sure you acually want to use this function. In context.go there are functions to check permissions
-// This function should not be used to check permissions.
-func (u *User) IsInRole(inRole string) bool {
- return IsInRole(u.Roles, inRole)
-}
-
-// Make sure you acually want to use this function. In context.go there are functions to check permissions
-// This function should not be used to check permissions.
-func IsInRole(userRoles string, inRole string) bool {
- roles := strings.Split(userRoles, " ")
-
- for _, r := range roles {
- if r == inRole {
- return true
- }
- }
-
- return false
-}
-
-func (u *User) IsSSOUser() bool {
- return u.AuthService != "" && u.AuthService != USER_AUTH_SERVICE_EMAIL
-}
-
-func (u *User) IsOAuthUser() bool {
- return u.AuthService == USER_AUTH_SERVICE_GITLAB
-}
-
-func (u *User) IsLDAPUser() bool {
- return u.AuthService == USER_AUTH_SERVICE_LDAP
-}
-
-func (u *User) IsSAMLUser() bool {
- return u.AuthService == USER_AUTH_SERVICE_SAML
-}
-
-// UserFromJson will decode the input and return a User
-func UserFromJson(data io.Reader) *User {
- decoder := json.NewDecoder(data)
- var user User
- err := decoder.Decode(&user)
- if err == nil {
- return &user
- } else {
- return nil
- }
-}
-
-func UserPatchFromJson(data io.Reader) *UserPatch {
- decoder := json.NewDecoder(data)
- var user UserPatch
- err := decoder.Decode(&user)
- if err == nil {
- return &user
- } else {
- return nil
- }
-}
-
-func UserAuthFromJson(data io.Reader) *UserAuth {
- decoder := json.NewDecoder(data)
- var user UserAuth
- err := decoder.Decode(&user)
- if err == nil {
- return &user
- } else {
- return nil
- }
-}
-
-func UserMapToJson(u map[string]*User) string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserMapFromJson(data io.Reader) map[string]*User {
- decoder := json.NewDecoder(data)
- var users map[string]*User
- err := decoder.Decode(&users)
- if err == nil {
- return users
- } else {
- return nil
- }
-}
-
-func UserListToJson(u []*User) string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserListFromJson(data io.Reader) []*User {
- decoder := json.NewDecoder(data)
- var users []*User
- err := decoder.Decode(&users)
- if err == nil {
- return users
- } else {
- return nil
- }
-}
-
-// HashPassword generates a hash using the bcrypt.GenerateFromPassword
-func HashPassword(password string) string {
- hash, err := bcrypt.GenerateFromPassword([]byte(password), 10)
- if err != nil {
- panic(err)
- }
-
- return string(hash)
-}
-
-// ComparePassword compares the hash
-func ComparePassword(hash string, password string) bool {
-
- if len(password) == 0 || len(hash) == 0 {
- return false
- }
-
- err := bcrypt.CompareHashAndPassword([]byte(hash), []byte(password))
- return err == nil
-}
-
-var validUsernameChars = regexp.MustCompile(`^[a-z0-9\.\-_]+$`)
-
-var restrictedUsernames = []string{
- "all",
- "channel",
- "matterbot",
-}
-
-func IsValidUsername(s string) bool {
- if len(s) < USER_NAME_MIN_LENGTH || len(s) > USER_NAME_MAX_LENGTH {
- return false
- }
-
- if !validUsernameChars.MatchString(s) {
- return false
- }
-
- for _, restrictedUsername := range restrictedUsernames {
- if s == restrictedUsername {
- return false
- }
- }
-
- return true
-}
-
-func CleanUsername(s string) string {
- s = strings.ToLower(strings.Replace(s, " ", "-", -1))
-
- for _, value := range reservedName {
- if s == value {
- s = strings.Replace(s, value, "", -1)
- }
- }
-
- s = strings.TrimSpace(s)
-
- for _, c := range s {
- char := fmt.Sprintf("%c", c)
- if !validUsernameChars.MatchString(char) {
- s = strings.Replace(s, char, "-", -1)
- }
- }
-
- s = strings.Trim(s, "-")
-
- if !IsValidUsername(s) {
- s = "a" + NewId()
- }
-
- return s
-}
-
-func IsValidUserNotifyLevel(notifyLevel string) bool {
- return notifyLevel == CHANNEL_NOTIFY_ALL ||
- notifyLevel == CHANNEL_NOTIFY_MENTION ||
- notifyLevel == CHANNEL_NOTIFY_NONE
-}
-
-func IsValidPushStatusNotifyLevel(notifyLevel string) bool {
- return notifyLevel == STATUS_ONLINE ||
- notifyLevel == STATUS_AWAY ||
- notifyLevel == STATUS_OFFLINE
-}
-
-func IsValidCommentsNotifyLevel(notifyLevel string) bool {
- return notifyLevel == COMMENTS_NOTIFY_ANY ||
- notifyLevel == COMMENTS_NOTIFY_ROOT ||
- notifyLevel == COMMENTS_NOTIFY_NEVER
-}
diff --git a/vendor/github.com/mattermost/platform/model/user_access_token.go b/vendor/github.com/mattermost/platform/model/user_access_token.go
deleted file mode 100644
index e189ec23..00000000
--- a/vendor/github.com/mattermost/platform/model/user_access_token.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
- "net/http"
-)
-
-type UserAccessToken struct {
- Id string `json:"id"`
- Token string `json:"token,omitempty"`
- UserId string `json:"user_id"`
- Description string `json:"description"`
- IsActive bool `json:"is_active"`
-}
-
-func (t *UserAccessToken) IsValid() *AppError {
- if len(t.Id) != 26 {
- return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(t.Token) != 26 {
- return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.token.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(t.UserId) != 26 {
- return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
- }
-
- if len(t.Description) > 255 {
- return NewAppError("UserAccessToken.IsValid", "model.user_access_token.is_valid.description.app_error", nil, "", http.StatusBadRequest)
- }
-
- return nil
-}
-
-func (t *UserAccessToken) PreSave() {
- t.Id = NewId()
- t.IsActive = true
-}
-
-func (t *UserAccessToken) ToJson() string {
- b, err := json.Marshal(t)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserAccessTokenFromJson(data io.Reader) *UserAccessToken {
- decoder := json.NewDecoder(data)
- var t UserAccessToken
- err := decoder.Decode(&t)
- if err == nil {
- return &t
- } else {
- return nil
- }
-}
-
-func UserAccessTokenListToJson(t []*UserAccessToken) string {
- b, err := json.Marshal(t)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserAccessTokenListFromJson(data io.Reader) []*UserAccessToken {
- decoder := json.NewDecoder(data)
- var t []*UserAccessToken
- err := decoder.Decode(&t)
- if err == nil {
- return t
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/user_autocomplete.go b/vendor/github.com/mattermost/platform/model/user_autocomplete.go
deleted file mode 100644
index 43c030b8..00000000
--- a/vendor/github.com/mattermost/platform/model/user_autocomplete.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type UserAutocompleteInChannel struct {
- InChannel []*User `json:"in_channel"`
- OutOfChannel []*User `json:"out_of_channel"`
-}
-
-type UserAutocompleteInTeam struct {
- InTeam []*User `json:"in_team"`
-}
-
-type UserAutocomplete struct {
- Users []*User `json:"users"`
- OutOfChannel []*User `json:"out_of_channel,omitempty"`
-}
-
-func (o *UserAutocomplete) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserAutocompleteFromJson(data io.Reader) *UserAutocomplete {
- decoder := json.NewDecoder(data)
- autocomplete := new(UserAutocomplete)
- err := decoder.Decode(&autocomplete)
- if err == nil {
- return autocomplete
- } else {
- return nil
- }
-}
-
-func (o *UserAutocompleteInChannel) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserAutocompleteInChannelFromJson(data io.Reader) *UserAutocompleteInChannel {
- decoder := json.NewDecoder(data)
- var o UserAutocompleteInChannel
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *UserAutocompleteInTeam) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func UserAutocompleteInTeamFromJson(data io.Reader) *UserAutocompleteInTeam {
- decoder := json.NewDecoder(data)
- var o UserAutocompleteInTeam
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/user_search.go b/vendor/github.com/mattermost/platform/model/user_search.go
deleted file mode 100644
index 6213b16e..00000000
--- a/vendor/github.com/mattermost/platform/model/user_search.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type UserSearch struct {
- Term string `json:"term"`
- TeamId string `json:"team_id"`
- NotInTeamId string `json:"not_in_team_id"`
- InChannelId string `json:"in_channel_id"`
- NotInChannelId string `json:"not_in_channel_id"`
- AllowInactive bool `json:"allow_inactive"`
- WithoutTeam bool `json:"without_team"`
-}
-
-// ToJson convert a User to a json string
-func (u *UserSearch) ToJson() string {
- b, err := json.Marshal(u)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// UserSearchFromJson will decode the input and return a User
-func UserSearchFromJson(data io.Reader) *UserSearch {
- decoder := json.NewDecoder(data)
- var us UserSearch
- err := decoder.Decode(&us)
- if err == nil {
- return &us
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/utils.go b/vendor/github.com/mattermost/platform/model/utils.go
deleted file mode 100644
index e84d44f7..00000000
--- a/vendor/github.com/mattermost/platform/model/utils.go
+++ /dev/null
@@ -1,494 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/base32"
- "encoding/json"
- "fmt"
- "io"
- "io/ioutil"
- "net"
- "net/http"
- "net/mail"
- "net/url"
- "regexp"
- "strconv"
- "strings"
- "time"
- "unicode"
-
- goi18n "github.com/nicksnyder/go-i18n/i18n"
- "github.com/pborman/uuid"
-)
-
-const (
- LOWERCASE_LETTERS = "abcdefghijklmnopqrstuvwxyz"
- UPPERCASE_LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- NUMBERS = "0123456789"
- SYMBOLS = " !\"\\#$%&'()*+,-./:;<=>?@[]^_`|~"
-)
-
-type StringInterface map[string]interface{}
-type StringMap map[string]string
-type StringArray []string
-
-type AppError struct {
- Id string `json:"id"`
- Message string `json:"message"` // Message to be display to the end user without debugging information
- DetailedError string `json:"detailed_error"` // Internal error string to help the developer
- RequestId string `json:"request_id,omitempty"` // The RequestId that's also set in the header
- StatusCode int `json:"status_code,omitempty"` // The http status code
- Where string `json:"-"` // The function where it happened in the form of Struct.Func
- IsOAuth bool `json:"is_oauth,omitempty"` // Whether the error is OAuth specific
- params map[string]interface{}
-}
-
-func (er *AppError) Error() string {
- return er.Where + ": " + er.Message + ", " + er.DetailedError
-}
-
-func (er *AppError) Translate(T goi18n.TranslateFunc) {
- if er.params == nil {
- er.Message = T(er.Id)
- } else {
- er.Message = T(er.Id, er.params)
- }
-}
-
-func (er *AppError) SystemMessage(T goi18n.TranslateFunc) string {
- if er.params == nil {
- return T(er.Id)
- } else {
- return T(er.Id, er.params)
- }
-}
-
-func (er *AppError) ToJson() string {
- b, err := json.Marshal(er)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// AppErrorFromJson will decode the input and return an AppError
-func AppErrorFromJson(data io.Reader) *AppError {
- str := ""
- bytes, rerr := ioutil.ReadAll(data)
- if rerr != nil {
- str = rerr.Error()
- } else {
- str = string(bytes)
- }
-
- decoder := json.NewDecoder(strings.NewReader(str))
- var er AppError
- err := decoder.Decode(&er)
- if err == nil {
- return &er
- } else {
- return NewAppError("AppErrorFromJson", "model.utils.decode_json.app_error", nil, "body: "+str, http.StatusInternalServerError)
- }
-}
-
-func NewAppError(where string, id string, params map[string]interface{}, details string, status int) *AppError {
- ap := &AppError{}
- ap.Id = id
- ap.params = params
- ap.Message = id
- ap.Where = where
- ap.DetailedError = details
- ap.StatusCode = status
- ap.IsOAuth = false
- return ap
-}
-
-var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769")
-
-// NewId is a globally unique identifier. It is a [A-Z0-9] string 26
-// characters long. It is a UUID version 4 Guid that is zbased32 encoded
-// with the padding stripped off.
-func NewId() string {
- var b bytes.Buffer
- encoder := base32.NewEncoder(encoding, &b)
- encoder.Write(uuid.NewRandom())
- encoder.Close()
- b.Truncate(26) // removes the '==' padding
- return b.String()
-}
-
-func NewRandomString(length int) string {
- var b bytes.Buffer
- str := make([]byte, length+8)
- rand.Read(str)
- encoder := base32.NewEncoder(encoding, &b)
- encoder.Write(str)
- encoder.Close()
- b.Truncate(length) // removes the '==' padding
- return b.String()
-}
-
-// GetMillis is a convience method to get milliseconds since epoch.
-func GetMillis() int64 {
- return time.Now().UnixNano() / int64(time.Millisecond)
-}
-
-// MapToJson converts a map to a json string
-func MapToJson(objmap map[string]string) string {
- if b, err := json.Marshal(objmap); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// MapToJson converts a map to a json string
-func MapBoolToJson(objmap map[string]bool) string {
- if b, err := json.Marshal(objmap); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-// MapFromJson will decode the key/value pair map
-func MapFromJson(data io.Reader) map[string]string {
- decoder := json.NewDecoder(data)
-
- var objmap map[string]string
- if err := decoder.Decode(&objmap); err != nil {
- return make(map[string]string)
- } else {
- return objmap
- }
-}
-
-// MapFromJson will decode the key/value pair map
-func MapBoolFromJson(data io.Reader) map[string]bool {
- decoder := json.NewDecoder(data)
-
- var objmap map[string]bool
- if err := decoder.Decode(&objmap); err != nil {
- return make(map[string]bool)
- } else {
- return objmap
- }
-}
-
-func ArrayToJson(objmap []string) string {
- if b, err := json.Marshal(objmap); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func ArrayFromJson(data io.Reader) []string {
- decoder := json.NewDecoder(data)
-
- var objmap []string
- if err := decoder.Decode(&objmap); err != nil {
- return make([]string, 0)
- } else {
- return objmap
- }
-}
-
-func ArrayFromInterface(data interface{}) []string {
- stringArray := []string{}
-
- dataArray, ok := data.([]interface{})
- if !ok {
- return stringArray
- }
-
- for _, v := range dataArray {
- if str, ok := v.(string); ok {
- stringArray = append(stringArray, str)
- }
- }
-
- return stringArray
-}
-
-func StringInterfaceToJson(objmap map[string]interface{}) string {
- if b, err := json.Marshal(objmap); err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func StringInterfaceFromJson(data io.Reader) map[string]interface{} {
- decoder := json.NewDecoder(data)
-
- var objmap map[string]interface{}
- if err := decoder.Decode(&objmap); err != nil {
- return make(map[string]interface{})
- } else {
- return objmap
- }
-}
-
-func StringToJson(s string) string {
- b, err := json.Marshal(s)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func StringFromJson(data io.Reader) string {
- decoder := json.NewDecoder(data)
-
- var s string
- if err := decoder.Decode(&s); err != nil {
- return ""
- } else {
- return s
- }
-}
-
-func GetServerIpAddress() string {
- if addrs, err := net.InterfaceAddrs(); err != nil {
- return ""
- } else {
- for _, addr := range addrs {
-
- if ip, ok := addr.(*net.IPNet); ok && !ip.IP.IsLoopback() {
- if ip.IP.To4() != nil {
- return ip.IP.String()
- }
- }
- }
- }
-
- return ""
-}
-
-func IsLower(s string) bool {
- return strings.ToLower(s) == s
-}
-
-func IsValidEmail(email string) bool {
-
- if !IsLower(email) {
- return false
- }
-
- if _, err := mail.ParseAddress(email); err == nil {
- return true
- }
-
- return false
-}
-
-var reservedName = []string{
- "signup",
- "login",
- "admin",
- "channel",
- "post",
- "api",
- "oauth",
-}
-
-func IsValidChannelIdentifier(s string) bool {
-
- if !IsValidAlphaNumHyphenUnderscore(s, true) {
- return false
- }
-
- if len(s) < CHANNEL_NAME_MIN_LENGTH {
- return false
- }
-
- return true
-}
-
-func IsValidAlphaNum(s string) bool {
- validAlphaNum := regexp.MustCompile(`^[a-z0-9]+([a-z\-0-9]+|(__)?)[a-z0-9]+$`)
-
- return validAlphaNum.MatchString(s)
-}
-
-func IsValidAlphaNumHyphenUnderscore(s string, withFormat bool) bool {
- if withFormat {
- validAlphaNumHyphenUnderscore := regexp.MustCompile(`^[a-z0-9]+([a-z\-\_0-9]+|(__)?)[a-z0-9]+$`)
- return validAlphaNumHyphenUnderscore.MatchString(s)
- }
-
- validSimpleAlphaNumHyphenUnderscore := regexp.MustCompile(`^[a-zA-Z0-9\-_]+$`)
- return validSimpleAlphaNumHyphenUnderscore.MatchString(s)
-}
-
-func Etag(parts ...interface{}) string {
-
- etag := CurrentVersion
-
- for _, part := range parts {
- etag += fmt.Sprintf(".%v", part)
- }
-
- return etag
-}
-
-var validHashtag = regexp.MustCompile(`^(#\pL[\pL\d\-_.]*[\pL\d])$`)
-var puncStart = regexp.MustCompile(`^[^\pL\d\s#]+`)
-var hashtagStart = regexp.MustCompile(`^#{2,}`)
-var puncEnd = regexp.MustCompile(`[^\pL\d\s]+$`)
-
-func ParseHashtags(text string) (string, string) {
- words := strings.Fields(text)
-
- hashtagString := ""
- plainString := ""
- for _, word := range words {
- // trim off surrounding punctuation
- word = puncStart.ReplaceAllString(word, "")
- word = puncEnd.ReplaceAllString(word, "")
-
- // and remove extra pound #s
- word = hashtagStart.ReplaceAllString(word, "#")
-
- if validHashtag.MatchString(word) {
- hashtagString += " " + word
- } else {
- plainString += " " + word
- }
- }
-
- if len(hashtagString) > 1000 {
- hashtagString = hashtagString[:999]
- lastSpace := strings.LastIndex(hashtagString, " ")
- if lastSpace > -1 {
- hashtagString = hashtagString[:lastSpace]
- } else {
- hashtagString = ""
- }
- }
-
- return strings.TrimSpace(hashtagString), strings.TrimSpace(plainString)
-}
-
-func IsFileExtImage(ext string) bool {
- ext = strings.ToLower(ext)
- for _, imgExt := range IMAGE_EXTENSIONS {
- if ext == imgExt {
- return true
- }
- }
- return false
-}
-
-func GetImageMimeType(ext string) string {
- ext = strings.ToLower(ext)
- if len(IMAGE_MIME_TYPES[ext]) == 0 {
- return "image"
- } else {
- return IMAGE_MIME_TYPES[ext]
- }
-}
-
-func ClearMentionTags(post string) string {
- post = strings.Replace(post, "<mention>", "", -1)
- post = strings.Replace(post, "</mention>", "", -1)
- return post
-}
-
-var UrlRegex = regexp.MustCompile(`^((?:[a-z]+:\/\/)?(?:(?:[a-z0-9\-]+\.)+(?:[a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|local|internal))(:[0-9]{1,5})?(?:\/[a-z0-9_\-\.~]+)*(\/([a-z0-9_\-\.]*)(?:\?[a-z0-9+_~\-\.%=&amp;]*)?)?(?:#[a-zA-Z0-9!$&'()*+.=-_~:@/?]*)?)(?:\s+|$)$`)
-var PartialUrlRegex = regexp.MustCompile(`/([A-Za-z0-9]{26})/([A-Za-z0-9]{26})/((?:[A-Za-z0-9]{26})?.+(?:\.[A-Za-z0-9]{3,})?)`)
-
-func IsValidHttpUrl(rawUrl string) bool {
- if strings.Index(rawUrl, "http://") != 0 && strings.Index(rawUrl, "https://") != 0 {
- return false
- }
-
- if _, err := url.ParseRequestURI(rawUrl); err != nil {
- return false
- }
-
- return true
-}
-
-func IsValidHttpsUrl(rawUrl string) bool {
- if strings.Index(rawUrl, "https://") != 0 {
- return false
- }
-
- if _, err := url.ParseRequestURI(rawUrl); err != nil {
- return false
- }
-
- return true
-}
-
-func IsValidTurnOrStunServer(rawUri string) bool {
- if strings.Index(rawUri, "turn:") != 0 && strings.Index(rawUri, "stun:") != 0 {
- return false
- }
-
- if _, err := url.ParseRequestURI(rawUri); err != nil {
- return false
- }
-
- return true
-}
-
-func IsSafeLink(link *string) bool {
- if link != nil {
- if IsValidHttpUrl(*link) {
- return true
- } else if strings.HasPrefix(*link, "/") {
- return true
- } else {
- return false
- }
- }
-
- return true
-}
-
-func IsValidWebsocketUrl(rawUrl string) bool {
- if strings.Index(rawUrl, "ws://") != 0 && strings.Index(rawUrl, "wss://") != 0 {
- return false
- }
-
- if _, err := url.ParseRequestURI(rawUrl); err != nil {
- return false
- }
-
- return true
-}
-
-func IsValidTrueOrFalseString(value string) bool {
- return value == "true" || value == "false"
-}
-
-func IsValidNumberString(value string) bool {
- if _, err := strconv.Atoi(value); err != nil {
- return false
- }
-
- return true
-}
-
-func IsValidId(value string) bool {
- if len(value) != 26 {
- return false
- }
-
- for _, r := range value {
- if !unicode.IsLetter(r) && !unicode.IsNumber(r) {
- return false
- }
- }
-
- return true
-}
diff --git a/vendor/github.com/mattermost/platform/model/version.go b/vendor/github.com/mattermost/platform/model/version.go
deleted file mode 100644
index 430924ee..00000000
--- a/vendor/github.com/mattermost/platform/model/version.go
+++ /dev/null
@@ -1,147 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "fmt"
- "strconv"
- "strings"
-)
-
-// This is a list of all the current viersions including any patches.
-// It should be maitained in chronological order with most current
-// release at the front of the list.
-var versions = []string{
- "4.6.0",
- "4.5.0",
- "4.4.0",
- "4.3.0",
- "4.2.0",
- "4.1.0",
- "4.0.0",
- "3.10.0",
- "3.9.0",
- "3.8.0",
- "3.7.0",
- "3.6.0",
- "3.5.0",
- "3.4.0",
- "3.3.0",
- "3.2.0",
- "3.1.0",
- "3.0.0",
- "2.2.0",
- "2.1.0",
- "2.0.0",
- "1.4.0",
- "1.3.0",
- "1.2.1",
- "1.2.0",
- "1.1.0",
- "1.0.0",
- "0.7.1",
- "0.7.0",
- "0.6.0",
- "0.5.0",
-}
-
-var CurrentVersion string = versions[0]
-var BuildNumber string
-var BuildDate string
-var BuildHash string
-var BuildHashEnterprise string
-var BuildEnterpriseReady string
-var versionsWithoutHotFixes []string
-
-func init() {
- versionsWithoutHotFixes = make([]string, 0, len(versions))
- seen := make(map[string]string)
-
- for _, version := range versions {
- maj, min, _ := SplitVersion(version)
- verStr := fmt.Sprintf("%v.%v.0", maj, min)
-
- if seen[verStr] == "" {
- versionsWithoutHotFixes = append(versionsWithoutHotFixes, verStr)
- seen[verStr] = verStr
- }
- }
-}
-
-func SplitVersion(version string) (int64, int64, int64) {
- parts := strings.Split(version, ".")
-
- major := int64(0)
- minor := int64(0)
- patch := int64(0)
-
- if len(parts) > 0 {
- major, _ = strconv.ParseInt(parts[0], 10, 64)
- }
-
- if len(parts) > 1 {
- minor, _ = strconv.ParseInt(parts[1], 10, 64)
- }
-
- if len(parts) > 2 {
- patch, _ = strconv.ParseInt(parts[2], 10, 64)
- }
-
- return major, minor, patch
-}
-
-func GetPreviousVersion(version string) string {
- verMajor, verMinor, _ := SplitVersion(version)
- verStr := fmt.Sprintf("%v.%v.0", verMajor, verMinor)
-
- for index, v := range versionsWithoutHotFixes {
- if v == verStr && len(versionsWithoutHotFixes) > index+1 {
- return versionsWithoutHotFixes[index+1]
- }
- }
-
- return ""
-}
-
-func IsOfficalBuild() bool {
- return BuildNumber != "_BUILD_NUMBER_"
-}
-
-func IsCurrentVersion(versionToCheck string) bool {
- currentMajor, currentMinor, _ := SplitVersion(CurrentVersion)
- toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
-
- if toCheckMajor == currentMajor && toCheckMinor == currentMinor {
- return true
- } else {
- return false
- }
-}
-
-func IsPreviousVersionsSupported(versionToCheck string) bool {
- toCheckMajor, toCheckMinor, _ := SplitVersion(versionToCheck)
- versionToCheckStr := fmt.Sprintf("%v.%v.0", toCheckMajor, toCheckMinor)
-
- // Current Supported
- if versionsWithoutHotFixes[0] == versionToCheckStr {
- return true
- }
-
- // Current - 1 Supported
- if versionsWithoutHotFixes[1] == versionToCheckStr {
- return true
- }
-
- // Current - 2 Supported
- if versionsWithoutHotFixes[2] == versionToCheckStr {
- return true
- }
-
- // Current - 3 Supported
- if versionsWithoutHotFixes[3] == versionToCheckStr {
- return true
- }
-
- return false
-}
diff --git a/vendor/github.com/mattermost/platform/model/webrtc.go b/vendor/github.com/mattermost/platform/model/webrtc.go
deleted file mode 100644
index fa15a4b7..00000000
--- a/vendor/github.com/mattermost/platform/model/webrtc.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-type WebrtcInfoResponse struct {
- Token string `json:"token"`
- GatewayUrl string `json:"gateway_url"`
- StunUri string `json:"stun_uri,omitempty"`
- TurnUri string `json:"turn_uri,omitempty"`
- TurnPassword string `json:"turn_password,omitempty"`
- TurnUsername string `json:"turn_username,omitempty"`
-}
-
-type GatewayResponse struct {
- Status string `json:"janus"`
-}
-
-func GatewayResponseFromJson(data io.Reader) *GatewayResponse {
- decoder := json.NewDecoder(data)
- var o GatewayResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-func (o *WebrtcInfoResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func WebrtcInfoResponseFromJson(data io.Reader) *WebrtcInfoResponse {
- decoder := json.NewDecoder(data)
- var o WebrtcInfoResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/websocket_client.go b/vendor/github.com/mattermost/platform/model/websocket_client.go
deleted file mode 100644
index e5c44dde..00000000
--- a/vendor/github.com/mattermost/platform/model/websocket_client.go
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "net/http"
-
- "github.com/gorilla/websocket"
-)
-
-const (
- SOCKET_MAX_MESSAGE_SIZE_KB = 8 * 1024 // 8KB
-)
-
-type WebSocketClient struct {
- Url string // The location of the server like "ws://localhost:8065"
- ApiUrl string // The api location of the server like "ws://localhost:8065/api/v3"
- ConnectUrl string // The websocket URL to connect to like "ws://localhost:8065/api/v3/path/to/websocket"
- Conn *websocket.Conn // The WebSocket connection
- AuthToken string // The token used to open the WebSocket
- Sequence int64 // The ever-incrementing sequence attached to each WebSocket action
- EventChannel chan *WebSocketEvent
- ResponseChannel chan *WebSocketResponse
- ListenError *AppError
-}
-
-// NewWebSocketClient constructs a new WebSocket client with convienence
-// methods for talking to the server.
-func NewWebSocketClient(url, authToken string) (*WebSocketClient, *AppError) {
- conn, _, err := websocket.DefaultDialer.Dial(url+API_URL_SUFFIX_V3+"/users/websocket", nil)
- if err != nil {
- return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
- }
-
- client := &WebSocketClient{
- url,
- url + API_URL_SUFFIX_V3,
- url + API_URL_SUFFIX_V3 + "/users/websocket",
- conn,
- authToken,
- 1,
- make(chan *WebSocketEvent, 100),
- make(chan *WebSocketResponse, 100),
- nil,
- }
-
- client.SendMessage(WEBSOCKET_AUTHENTICATION_CHALLENGE, map[string]interface{}{"token": authToken})
-
- return client, nil
-}
-
-// NewWebSocketClient4 constructs a new WebSocket client with convienence
-// methods for talking to the server. Uses the v4 endpoint.
-func NewWebSocketClient4(url, authToken string) (*WebSocketClient, *AppError) {
- conn, _, err := websocket.DefaultDialer.Dial(url+API_URL_SUFFIX+"/websocket", nil)
- if err != nil {
- return nil, NewAppError("NewWebSocketClient4", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
- }
-
- client := &WebSocketClient{
- url,
- url + API_URL_SUFFIX,
- url + API_URL_SUFFIX + "/websocket",
- conn,
- authToken,
- 1,
- make(chan *WebSocketEvent, 100),
- make(chan *WebSocketResponse, 100),
- nil,
- }
-
- client.SendMessage(WEBSOCKET_AUTHENTICATION_CHALLENGE, map[string]interface{}{"token": authToken})
-
- return client, nil
-}
-
-func (wsc *WebSocketClient) Connect() *AppError {
- var err error
- wsc.Conn, _, err = websocket.DefaultDialer.Dial(wsc.ConnectUrl, nil)
- if err != nil {
- return NewAppError("Connect", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
- }
-
- wsc.EventChannel = make(chan *WebSocketEvent, 100)
- wsc.ResponseChannel = make(chan *WebSocketResponse, 100)
-
- wsc.SendMessage(WEBSOCKET_AUTHENTICATION_CHALLENGE, map[string]interface{}{"token": wsc.AuthToken})
-
- return nil
-}
-
-func (wsc *WebSocketClient) Close() {
- wsc.Conn.Close()
-}
-
-func (wsc *WebSocketClient) Listen() {
- go func() {
- defer func() {
- wsc.Conn.Close()
- close(wsc.EventChannel)
- close(wsc.ResponseChannel)
- }()
-
- for {
- var rawMsg json.RawMessage
- var err error
- if _, rawMsg, err = wsc.Conn.ReadMessage(); err != nil {
- if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
- wsc.ListenError = NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
- }
-
- return
- }
-
- var event WebSocketEvent
- if err := json.Unmarshal(rawMsg, &event); err == nil && event.IsValid() {
- wsc.EventChannel <- &event
- continue
- }
-
- var response WebSocketResponse
- if err := json.Unmarshal(rawMsg, &response); err == nil && response.IsValid() {
- wsc.ResponseChannel <- &response
- continue
- }
-
- }
- }()
-}
-
-func (wsc *WebSocketClient) SendMessage(action string, data map[string]interface{}) {
- req := &WebSocketRequest{}
- req.Seq = wsc.Sequence
- req.Action = action
- req.Data = data
-
- wsc.Sequence++
-
- wsc.Conn.WriteJSON(req)
-}
-
-// UserTyping will push a user_typing event out to all connected users
-// who are in the specified channel
-func (wsc *WebSocketClient) UserTyping(channelId, parentId string) {
- data := map[string]interface{}{
- "channel_id": channelId,
- "parent_id": parentId,
- }
-
- wsc.SendMessage("user_typing", data)
-}
-
-// GetStatuses will return a map of string statuses using user id as the key
-func (wsc *WebSocketClient) GetStatuses() {
- wsc.SendMessage("get_statuses", nil)
-}
-
-// GetStatusesByIds will fetch certain user statuses based on ids and return
-// a map of string statuses using user id as the key
-func (wsc *WebSocketClient) GetStatusesByIds(userIds []string) {
- data := map[string]interface{}{
- "user_ids": userIds,
- }
- wsc.SendMessage("get_statuses_by_ids", data)
-}
diff --git a/vendor/github.com/mattermost/platform/model/websocket_message.go b/vendor/github.com/mattermost/platform/model/websocket_message.go
deleted file mode 100644
index bf2535dc..00000000
--- a/vendor/github.com/mattermost/platform/model/websocket_message.go
+++ /dev/null
@@ -1,149 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-)
-
-const (
- WEBSOCKET_EVENT_TYPING = "typing"
- WEBSOCKET_EVENT_POSTED = "posted"
- WEBSOCKET_EVENT_POST_EDITED = "post_edited"
- WEBSOCKET_EVENT_POST_DELETED = "post_deleted"
- WEBSOCKET_EVENT_CHANNEL_DELETED = "channel_deleted"
- WEBSOCKET_EVENT_CHANNEL_CREATED = "channel_created"
- WEBSOCKET_EVENT_CHANNEL_UPDATED = "channel_updated"
- WEBSOCKET_EVENT_DIRECT_ADDED = "direct_added"
- WEBSOCKET_EVENT_GROUP_ADDED = "group_added"
- WEBSOCKET_EVENT_NEW_USER = "new_user"
- WEBSOCKET_EVENT_ADDED_TO_TEAM = "added_to_team"
- WEBSOCKET_EVENT_LEAVE_TEAM = "leave_team"
- WEBSOCKET_EVENT_UPDATE_TEAM = "update_team"
- WEBSOCKET_EVENT_USER_ADDED = "user_added"
- WEBSOCKET_EVENT_USER_UPDATED = "user_updated"
- WEBSOCKET_EVENT_USER_ROLE_UPDATED = "user_role_updated"
- WEBSOCKET_EVENT_MEMBERROLE_UPDATED = "memberrole_updated"
- WEBSOCKET_EVENT_USER_REMOVED = "user_removed"
- WEBSOCKET_EVENT_PREFERENCE_CHANGED = "preference_changed"
- WEBSOCKET_EVENT_PREFERENCES_CHANGED = "preferences_changed"
- WEBSOCKET_EVENT_PREFERENCES_DELETED = "preferences_deleted"
- WEBSOCKET_EVENT_EPHEMERAL_MESSAGE = "ephemeral_message"
- WEBSOCKET_EVENT_STATUS_CHANGE = "status_change"
- WEBSOCKET_EVENT_HELLO = "hello"
- WEBSOCKET_EVENT_WEBRTC = "webrtc"
- WEBSOCKET_AUTHENTICATION_CHALLENGE = "authentication_challenge"
- WEBSOCKET_EVENT_REACTION_ADDED = "reaction_added"
- WEBSOCKET_EVENT_REACTION_REMOVED = "reaction_removed"
- WEBSOCKET_EVENT_RESPONSE = "response"
- WEBSOCKET_EVENT_EMOJI_ADDED = "emoji_added"
- WEBSOCKET_EVENT_CHANNEL_VIEWED = "channel_viewed"
- WEBSOCKET_EVENT_PLUGIN_ACTIVATED = "plugin_activated" // EXPERIMENTAL - SUBJECT TO CHANGE
- WEBSOCKET_EVENT_PLUGIN_DEACTIVATED = "plugin_deactivated" // EXPERIMENTAL - SUBJECT TO CHANGE
-)
-
-type WebSocketMessage interface {
- ToJson() string
- IsValid() bool
- EventType() string
-}
-
-type WebsocketBroadcast struct {
- OmitUsers map[string]bool `json:"omit_users"` // broadcast is omitted for users listed here
- UserId string `json:"user_id"` // broadcast only occurs for this user
- ChannelId string `json:"channel_id"` // broadcast only occurs for users in this channel
- TeamId string `json:"team_id"` // broadcast only occurs for users in this team
-}
-
-type WebSocketEvent struct {
- Event string `json:"event"`
- Data map[string]interface{} `json:"data"`
- Broadcast *WebsocketBroadcast `json:"broadcast"`
- Sequence int64 `json:"seq"`
-}
-
-func (m *WebSocketEvent) Add(key string, value interface{}) {
- m.Data[key] = value
-}
-
-func NewWebSocketEvent(event, teamId, channelId, userId string, omitUsers map[string]bool) *WebSocketEvent {
- return &WebSocketEvent{Event: event, Data: make(map[string]interface{}),
- Broadcast: &WebsocketBroadcast{TeamId: teamId, ChannelId: channelId, UserId: userId, OmitUsers: omitUsers}}
-}
-
-func (o *WebSocketEvent) IsValid() bool {
- return o.Event != ""
-}
-
-func (o *WebSocketEvent) EventType() string {
- return o.Event
-}
-
-func (o *WebSocketEvent) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func WebSocketEventFromJson(data io.Reader) *WebSocketEvent {
- decoder := json.NewDecoder(data)
- var o WebSocketEvent
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
-
-type WebSocketResponse struct {
- Status string `json:"status"`
- SeqReply int64 `json:"seq_reply,omitempty"`
- Data map[string]interface{} `json:"data,omitempty"`
- Error *AppError `json:"error,omitempty"`
-}
-
-func (m *WebSocketResponse) Add(key string, value interface{}) {
- m.Data[key] = value
-}
-
-func NewWebSocketResponse(status string, seqReply int64, data map[string]interface{}) *WebSocketResponse {
- return &WebSocketResponse{Status: status, SeqReply: seqReply, Data: data}
-}
-
-func NewWebSocketError(seqReply int64, err *AppError) *WebSocketResponse {
- return &WebSocketResponse{Status: STATUS_FAIL, SeqReply: seqReply, Error: err}
-}
-
-func (o *WebSocketResponse) IsValid() bool {
- return o.Status != ""
-}
-
-func (o *WebSocketResponse) EventType() string {
- return WEBSOCKET_EVENT_RESPONSE
-}
-
-func (o *WebSocketResponse) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func WebSocketResponseFromJson(data io.Reader) *WebSocketResponse {
- decoder := json.NewDecoder(data)
- var o WebSocketResponse
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}
diff --git a/vendor/github.com/mattermost/platform/model/websocket_request.go b/vendor/github.com/mattermost/platform/model/websocket_request.go
deleted file mode 100644
index 7dc0b433..00000000
--- a/vendor/github.com/mattermost/platform/model/websocket_request.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package model
-
-import (
- "encoding/json"
- "io"
-
- goi18n "github.com/nicksnyder/go-i18n/i18n"
-)
-
-type WebSocketRequest struct {
- // Client-provided fields
- Seq int64 `json:"seq"`
- Action string `json:"action"`
- Data map[string]interface{} `json:"data"`
-
- // Server-provided fields
- Session Session `json:"-"`
- T goi18n.TranslateFunc `json:"-"`
- Locale string `json:"-"`
-}
-
-func (o *WebSocketRequest) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
- }
-}
-
-func WebSocketRequestFromJson(data io.Reader) *WebSocketRequest {
- decoder := json.NewDecoder(data)
- var o WebSocketRequest
- err := decoder.Decode(&o)
- if err == nil {
- return &o
- } else {
- return nil
- }
-}