summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mattermost/platform
diff options
context:
space:
mode:
authorWim <wim@42.be>2018-02-09 00:11:04 +0100
committerWim <wim@42.be>2018-02-09 00:11:04 +0100
commit5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811 (patch)
tree09bcb3f02f968867c2ca84db1f28594dd0afb967 /vendor/github.com/mattermost/platform
parent1d33e60e36fa7b0e361990ac347ee8d620d67dcc (diff)
downloadmatterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.tar.gz
matterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.tar.bz2
matterbridge-msglm-5aab158c0b0db64b6136fe2fdaca8b8e9e3bd811.zip
Update vendor (github.com/mattermost)
Diffstat (limited to 'vendor/github.com/mattermost/platform')
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/account_migration.go20
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/brand.go24
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/cluster.go33
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/compliance.go23
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/elasticsearch.go25
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/emoji.go22
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/jobs/data_retention.go23
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/jobs/elasticsearch.go22
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/ldap.go31
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/metrics.go50
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/mfa.go25
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/oauthproviders.go29
-rw-r--r--vendor/github.com/mattermost/platform/einterfaces/saml.go25
-rw-r--r--vendor/github.com/mattermost/platform/model/access.go11
-rw-r--r--vendor/github.com/mattermost/platform/model/authorization.go87
-rw-r--r--vendor/github.com/mattermost/platform/model/authorize.go23
-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.go25
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_member.go17
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_member_history.go12
-rw-r--r--vendor/github.com/mattermost/platform/model/channel_view.go25
-rw-r--r--vendor/github.com/mattermost/platform/model/client.go40
-rw-r--r--vendor/github.com/mattermost/platform/model/client4.go240
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_discovery.go13
-rw-r--r--vendor/github.com/mattermost/platform/model/cluster_info.go1
-rw-r--r--vendor/github.com/mattermost/platform/model/command.go25
-rw-r--r--vendor/github.com/mattermost/platform/model/command_response.go23
-rw-r--r--vendor/github.com/mattermost/platform/model/command_webhook.go65
-rw-r--r--vendor/github.com/mattermost/platform/model/compliance.go13
-rw-r--r--vendor/github.com/mattermost/platform/model/config.go2364
-rw-r--r--vendor/github.com/mattermost/platform/model/data_retention_policy.go36
-rw-r--r--vendor/github.com/mattermost/platform/model/emoji.go11
-rw-r--r--vendor/github.com/mattermost/platform/model/file_info.go18
-rw-r--r--vendor/github.com/mattermost/platform/model/gitlab/gitlab.go6
-rw-r--r--vendor/github.com/mattermost/platform/model/incoming_webhook.go19
-rw-r--r--vendor/github.com/mattermost/platform/model/job.go36
-rw-r--r--vendor/github.com/mattermost/platform/model/license.go84
-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/outgoing_webhook.go31
-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.go190
-rw-r--r--vendor/github.com/mattermost/platform/model/post_list.go21
-rw-r--r--vendor/github.com/mattermost/platform/model/preference.go11
-rw-r--r--vendor/github.com/mattermost/platform/model/push_notification.go6
-rw-r--r--vendor/github.com/mattermost/platform/model/reaction.go9
-rw-r--r--vendor/github.com/mattermost/platform/model/search_params.go14
-rw-r--r--vendor/github.com/mattermost/platform/model/session.go5
-rw-r--r--vendor/github.com/mattermost/platform/model/slack_attachment.go26
-rw-r--r--vendor/github.com/mattermost/platform/model/status.go1
-rw-r--r--vendor/github.com/mattermost/platform/model/team_member.go5
-rw-r--r--vendor/github.com/mattermost/platform/model/user.go46
-rw-r--r--vendor/github.com/mattermost/platform/model/user_access_token.go2
-rw-r--r--vendor/github.com/mattermost/platform/model/utils.go36
-rw-r--r--vendor/github.com/mattermost/platform/model/version.go5
-rw-r--r--vendor/github.com/mattermost/platform/model/websocket_client.go10
-rw-r--r--vendor/github.com/mattermost/platform/model/websocket_message.go3
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/config.go288
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/filelog.go264
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/log4go.go484
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/pattlog.go126
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/socklog.go57
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/termlog.go49
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/wrapper.go278
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client.go392
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone.go16
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone_legacy.go38
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/compression.go148
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn.go1149
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read.go18
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read_legacy.go21
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/doc.go180
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/autobahn/server.go265
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/client.go137
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/hub.go53
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/main.go40
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/command/main.go193
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/client.go81
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/server.go132
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/filewatch/main.go193
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/json.go55
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask.go55
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask_safe.go15
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/prepared.go103
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/server.go291
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/util.go214
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go4
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/language.go6
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/operands.go20
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go9
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go166
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go2
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go2
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/dce.go84
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/doc.go8
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/hash.go53
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/marshal.go83
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/node.go117
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/sql.go66
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/time.go132
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/util.go43
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/uuid.go201
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version1.go41
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version4.go25
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/doc.go2
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/fuzz.go31
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/keysparsing.go107
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/marshal.go230
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/parser.go6
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/doc.go2
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/parser.go2
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/toml.go26
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_create.go6
-rw-r--r--vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_write.go43
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/base64.go35
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/bcrypt.go295
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/LICENSE.txt897
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/block.go159
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/cipher.go91
-rw-r--r--vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/const.go199
-rw-r--r--vendor/github.com/mattermost/platform/vendor/gopkg.in/yaml.v2/scannerc.go9
128 files changed, 3123 insertions, 14233 deletions
diff --git a/vendor/github.com/mattermost/platform/einterfaces/LICENSE.txt b/vendor/github.com/mattermost/platform/einterfaces/LICENSE.txt
deleted file mode 100644
index ead98cf0..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/einterfaces/account_migration.go b/vendor/github.com/mattermost/platform/einterfaces/account_migration.go
deleted file mode 100644
index c9534ab6..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/account_migration.go
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import "github.com/mattermost/platform/model"
-
-type AccountMigrationInterface interface {
- MigrateToLdap(fromAuthService string, forignUserFieldNameToMatch string, force bool) *model.AppError
-}
-
-var theAccountMigrationInterface AccountMigrationInterface
-
-func RegisterAccountMigrationInterface(newInterface AccountMigrationInterface) {
- theAccountMigrationInterface = newInterface
-}
-
-func GetAccountMigrationInterface() AccountMigrationInterface {
- return theAccountMigrationInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/brand.go b/vendor/github.com/mattermost/platform/einterfaces/brand.go
deleted file mode 100644
index f4e16eb0..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/brand.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
- "mime/multipart"
-)
-
-type BrandInterface interface {
- SaveBrandImage(*multipart.FileHeader) *model.AppError
- GetBrandImage() ([]byte, *model.AppError)
-}
-
-var theBrandInterface BrandInterface
-
-func RegisterBrandInterface(newInterface BrandInterface) {
- theBrandInterface = newInterface
-}
-
-func GetBrandInterface() BrandInterface {
- return theBrandInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/cluster.go b/vendor/github.com/mattermost/platform/einterfaces/cluster.go
deleted file mode 100644
index 096a775f..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/cluster.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type ClusterMessageHandler func(msg *model.ClusterMessage)
-
-type ClusterInterface interface {
- StartInterNodeCommunication()
- StopInterNodeCommunication()
- RegisterClusterMessageHandler(event string, crm ClusterMessageHandler)
- GetClusterId() string
- GetClusterInfos() []*model.ClusterInfo
- SendClusterMessage(cluster *model.ClusterMessage)
- NotifyMsg(buf []byte)
- GetClusterStats() ([]*model.ClusterStats, *model.AppError)
- GetLogs(page, perPage int) ([]string, *model.AppError)
- ConfigChanged(previousConfig *model.Config, newConfig *model.Config, sendToOtherServer bool) *model.AppError
-}
-
-var theClusterInterface ClusterInterface
-
-func RegisterClusterInterface(newInterface ClusterInterface) {
- theClusterInterface = newInterface
-}
-
-func GetClusterInterface() ClusterInterface {
- return theClusterInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/compliance.go b/vendor/github.com/mattermost/platform/einterfaces/compliance.go
deleted file mode 100644
index b7c087e8..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/compliance.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type ComplianceInterface interface {
- StartComplianceDailyJob()
- RunComplianceJob(job *model.Compliance) *model.AppError
-}
-
-var theComplianceInterface ComplianceInterface
-
-func RegisterComplianceInterface(newInterface ComplianceInterface) {
- theComplianceInterface = newInterface
-}
-
-func GetComplianceInterface() ComplianceInterface {
- return theComplianceInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/elasticsearch.go b/vendor/github.com/mattermost/platform/einterfaces/elasticsearch.go
deleted file mode 100644
index 011b259b..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/elasticsearch.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import "github.com/mattermost/platform/model"
-
-type ElasticsearchInterface interface {
- Start() *model.AppError
- IndexPost(post *model.Post, teamId string) *model.AppError
- SearchPosts(channels *model.ChannelList, searchParams []*model.SearchParams) ([]string, *model.AppError)
- DeletePost(post *model.Post) *model.AppError
- TestConfig(cfg *model.Config) *model.AppError
- PurgeIndexes() *model.AppError
-}
-
-var theElasticsearchInterface ElasticsearchInterface
-
-func RegisterElasticsearchInterface(newInterface ElasticsearchInterface) {
- theElasticsearchInterface = newInterface
-}
-
-func GetElasticsearchInterface() ElasticsearchInterface {
- return theElasticsearchInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/emoji.go b/vendor/github.com/mattermost/platform/einterfaces/emoji.go
deleted file mode 100644
index 45d1432d..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/emoji.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type EmojiInterface interface {
- CanUserCreateEmoji(string, []*model.TeamMember) bool
-}
-
-var theEmojiInterface EmojiInterface
-
-func RegisterEmojiInterface(newInterface EmojiInterface) {
- theEmojiInterface = newInterface
-}
-
-func GetEmojiInterface() EmojiInterface {
- return theEmojiInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/jobs/data_retention.go b/vendor/github.com/mattermost/platform/einterfaces/jobs/data_retention.go
deleted file mode 100644
index 442f667f..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/jobs/data_retention.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package jobs
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type DataRetentionInterface interface {
- MakeWorker() model.Worker
- MakeScheduler() model.Scheduler
-}
-
-var theDataRetentionInterface DataRetentionInterface
-
-func RegisterDataRetentionInterface(newInterface DataRetentionInterface) {
- theDataRetentionInterface = newInterface
-}
-
-func GetDataRetentionInterface() DataRetentionInterface {
- return theDataRetentionInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/jobs/elasticsearch.go b/vendor/github.com/mattermost/platform/einterfaces/jobs/elasticsearch.go
deleted file mode 100644
index 6d6dbe89..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/jobs/elasticsearch.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package jobs
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type ElasticsearchIndexerInterface interface {
- MakeWorker() model.Worker
-}
-
-var theElasticsearchIndexerInterface ElasticsearchIndexerInterface
-
-func RegisterElasticsearchIndexerInterface(newInterface ElasticsearchIndexerInterface) {
- theElasticsearchIndexerInterface = newInterface
-}
-
-func GetElasticsearchIndexerInterface() ElasticsearchIndexerInterface {
- return theElasticsearchIndexerInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/ldap.go b/vendor/github.com/mattermost/platform/einterfaces/ldap.go
deleted file mode 100644
index 721c8d30..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/ldap.go
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type LdapInterface interface {
- DoLogin(id string, password string) (*model.User, *model.AppError)
- GetUser(id string) (*model.User, *model.AppError)
- CheckPassword(id string, password string) *model.AppError
- SwitchToLdap(userId, ldapId, ldapPassword string) *model.AppError
- ValidateFilter(filter string) *model.AppError
- Syncronize() *model.AppError
- StartLdapSyncJob()
- SyncNow()
- RunTest() *model.AppError
- GetAllLdapUsers() ([]*model.User, *model.AppError)
-}
-
-var theLdapInterface LdapInterface
-
-func RegisterLdapInterface(newInterface LdapInterface) {
- theLdapInterface = newInterface
-}
-
-func GetLdapInterface() LdapInterface {
- return theLdapInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/metrics.go b/vendor/github.com/mattermost/platform/einterfaces/metrics.go
deleted file mode 100644
index e1ef9c15..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/metrics.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-type MetricsInterface interface {
- StartServer()
- StopServer()
-
- IncrementPostCreate()
- IncrementWebhookPost()
- IncrementPostSentEmail()
- IncrementPostSentPush()
- IncrementPostBroadcast()
- IncrementPostFileAttachment(count int)
-
- IncrementHttpRequest()
- IncrementHttpError()
- ObserveHttpRequestDuration(elapsed float64)
-
- IncrementClusterRequest()
- ObserveClusterRequestDuration(elapsed float64)
-
- IncrementLogin()
- IncrementLoginFail()
-
- IncrementEtagHitCounter(route string)
- IncrementEtagMissCounter(route string)
-
- IncrementMemCacheHitCounter(cacheName string)
- IncrementMemCacheMissCounter(cacheName string)
- IncrementMemCacheMissCounterSession()
- IncrementMemCacheHitCounterSession()
-
- IncrementWebsocketEvent(eventType string)
- IncrementWebSocketBroadcast(eventType string)
-
- AddMemCacheHitCounter(cacheName string, amount float64)
- AddMemCacheMissCounter(cacheName string, amount float64)
-}
-
-var theMetricsInterface MetricsInterface
-
-func RegisterMetricsInterface(newInterface MetricsInterface) {
- theMetricsInterface = newInterface
-}
-
-func GetMetricsInterface() MetricsInterface {
- return theMetricsInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/mfa.go b/vendor/github.com/mattermost/platform/einterfaces/mfa.go
deleted file mode 100644
index e1b6ecbc..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/mfa.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type MfaInterface interface {
- GenerateSecret(user *model.User) (string, []byte, *model.AppError)
- Activate(user *model.User, token string) *model.AppError
- Deactivate(userId string) *model.AppError
- ValidateToken(secret, token string) (bool, *model.AppError)
-}
-
-var theMfaInterface MfaInterface
-
-func RegisterMfaInterface(newInterface MfaInterface) {
- theMfaInterface = newInterface
-}
-
-func GetMfaInterface() MfaInterface {
- return theMfaInterface
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/oauthproviders.go b/vendor/github.com/mattermost/platform/einterfaces/oauthproviders.go
deleted file mode 100644
index b58e8307..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/oauthproviders.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
- "io"
-)
-
-type OauthProvider interface {
- GetIdentifier() string
- GetUserFromJson(data io.Reader) *model.User
- GetAuthDataFromJson(data io.Reader) string
-}
-
-var oauthProviders = make(map[string]OauthProvider)
-
-func RegisterOauthProvider(name string, newProvider OauthProvider) {
- oauthProviders[name] = newProvider
-}
-
-func GetOauthProvider(name string) OauthProvider {
- provider, ok := oauthProviders[name]
- if ok {
- return provider
- }
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/einterfaces/saml.go b/vendor/github.com/mattermost/platform/einterfaces/saml.go
deleted file mode 100644
index 3e020891..00000000
--- a/vendor/github.com/mattermost/platform/einterfaces/saml.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
-// See License.txt for license information.
-
-package einterfaces
-
-import (
- "github.com/mattermost/platform/model"
-)
-
-type SamlInterface interface {
- ConfigureSP() *model.AppError
- BuildRequest(relayState string) (*model.SamlAuthRequest, *model.AppError)
- DoLogin(encodedXML string, relayState map[string]string) (*model.User, *model.AppError)
- GetMetadata() (string, *model.AppError)
-}
-
-var theSamlInterface SamlInterface
-
-func RegisterSamlInterface(newInterface SamlInterface) {
- theSamlInterface = newInterface
-}
-
-func GetSamlInterface() SamlInterface {
- return theSamlInterface
-}
diff --git a/vendor/github.com/mattermost/platform/model/access.go b/vendor/github.com/mattermost/platform/model/access.go
index 9e16ed58..551ef930 100644
--- a/vendor/github.com/mattermost/platform/model/access.go
+++ b/vendor/github.com/mattermost/platform/model/access.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
)
const (
@@ -37,23 +38,23 @@ type AccessResponse struct {
func (ad *AccessData) IsValid() *AppError {
if len(ad.ClientId) == 0 || len(ad.ClientId) > 26 {
- return NewLocAppError("AccessData.IsValid", "model.access.is_valid.client_id.app_error", nil, "")
+ 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 NewLocAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "")
+ return NewAppError("AccessData.IsValid", "model.access.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
}
if len(ad.Token) != 26 {
- return NewLocAppError("AccessData.IsValid", "model.access.is_valid.access_token.app_error", nil, "")
+ return NewAppError("AccessData.IsValid", "model.access.is_valid.access_token.app_error", nil, "", http.StatusBadRequest)
}
if len(ad.RefreshToken) > 26 {
- return NewLocAppError("AccessData.IsValid", "model.access.is_valid.refresh_token.app_error", nil, "")
+ 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 NewLocAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "")
+ return NewAppError("AccessData.IsValid", "model.access.is_valid.redirect_uri.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/authorization.go b/vendor/github.com/mattermost/platform/model/authorization.go
index d413e294..9f4e36ea 100644
--- a/vendor/github.com/mattermost/platform/model/authorization.go
+++ b/vendor/github.com/mattermost/platform/model/authorization.go
@@ -69,24 +69,24 @@ var PERMISSION_REVOKE_USER_ACCESS_TOKEN *Permission
// admin functions but not others
var PERMISSION_MANAGE_SYSTEM *Permission
-var ROLE_SYSTEM_USER *Role
-var ROLE_SYSTEM_ADMIN *Role
-var ROLE_SYSTEM_POST_ALL *Role
-var ROLE_SYSTEM_POST_ALL_PUBLIC *Role
-var ROLE_SYSTEM_USER_ACCESS_TOKEN *Role
+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"
-var ROLE_TEAM_USER *Role
-var ROLE_TEAM_ADMIN *Role
-var ROLE_TEAM_POST_ALL *Role
-var ROLE_TEAM_POST_ALL_PUBLIC *Role
+ 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"
-var ROLE_CHANNEL_USER *Role
-var ROLE_CHANNEL_ADMIN *Role
-var ROLE_CHANNEL_GUEST *Role
+ CHANNEL_USER_ROLE_ID = "channel_user"
+ CHANNEL_ADMIN_ROLE_ID = "channel_admin"
+ CHANNEL_GUEST_ROLE_ID = "guest"
+)
-var BuiltInRoles map[string]*Role
-
-func InitalizePermissions() {
+func initializePermissions() {
PERMISSION_INVITE_USER = &Permission{
"invite_user",
"authentication.permissions.team_invite_user.name",
@@ -329,11 +329,12 @@ func InitalizePermissions() {
}
}
-func InitalizeRoles() {
- InitalizePermissions()
- BuiltInRoles = make(map[string]*Role)
+var DefaultRoles map[string]*Role
+
+func initializeDefaultRoles() {
+ DefaultRoles = make(map[string]*Role)
- ROLE_CHANNEL_USER = &Role{
+ DefaultRoles[CHANNEL_USER_ROLE_ID] = &Role{
"channel_user",
"authentication.roles.channel_user.name",
"authentication.roles.channel_user.description",
@@ -347,8 +348,8 @@ func InitalizeRoles() {
PERMISSION_USE_SLASH_COMMANDS.Id,
},
}
- BuiltInRoles[ROLE_CHANNEL_USER.Id] = ROLE_CHANNEL_USER
- ROLE_CHANNEL_ADMIN = &Role{
+
+ DefaultRoles[CHANNEL_ADMIN_ROLE_ID] = &Role{
"channel_admin",
"authentication.roles.channel_admin.name",
"authentication.roles.channel_admin.description",
@@ -356,16 +357,15 @@ func InitalizeRoles() {
PERMISSION_MANAGE_CHANNEL_ROLES.Id,
},
}
- BuiltInRoles[ROLE_CHANNEL_ADMIN.Id] = ROLE_CHANNEL_ADMIN
- ROLE_CHANNEL_GUEST = &Role{
+
+ DefaultRoles[CHANNEL_GUEST_ROLE_ID] = &Role{
"guest",
"authentication.roles.global_guest.name",
"authentication.roles.global_guest.description",
[]string{},
}
- BuiltInRoles[ROLE_CHANNEL_GUEST.Id] = ROLE_CHANNEL_GUEST
- ROLE_TEAM_USER = &Role{
+ DefaultRoles[TEAM_USER_ROLE_ID] = &Role{
"team_user",
"authentication.roles.team_user.name",
"authentication.roles.team_user.description",
@@ -376,9 +376,8 @@ func InitalizeRoles() {
PERMISSION_VIEW_TEAM.Id,
},
}
- BuiltInRoles[ROLE_TEAM_USER.Id] = ROLE_TEAM_USER
- ROLE_TEAM_POST_ALL = &Role{
+ DefaultRoles[TEAM_POST_ALL_ROLE_ID] = &Role{
"team_post_all",
"authentication.roles.team_post_all.name",
"authentication.roles.team_post_all.description",
@@ -386,9 +385,8 @@ func InitalizeRoles() {
PERMISSION_CREATE_POST.Id,
},
}
- BuiltInRoles[ROLE_TEAM_POST_ALL.Id] = ROLE_TEAM_POST_ALL
- ROLE_TEAM_POST_ALL_PUBLIC = &Role{
+ 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",
@@ -396,9 +394,8 @@ func InitalizeRoles() {
PERMISSION_CREATE_POST_PUBLIC.Id,
},
}
- BuiltInRoles[ROLE_TEAM_POST_ALL_PUBLIC.Id] = ROLE_TEAM_POST_ALL_PUBLIC
- ROLE_TEAM_ADMIN = &Role{
+ DefaultRoles[TEAM_ADMIN_ROLE_ID] = &Role{
"team_admin",
"authentication.roles.team_admin.name",
"authentication.roles.team_admin.description",
@@ -415,9 +412,8 @@ func InitalizeRoles() {
PERMISSION_MANAGE_WEBHOOKS.Id,
},
}
- BuiltInRoles[ROLE_TEAM_ADMIN.Id] = ROLE_TEAM_ADMIN
- ROLE_SYSTEM_USER = &Role{
+ DefaultRoles[SYSTEM_USER_ROLE_ID] = &Role{
"system_user",
"authentication.roles.global_user.name",
"authentication.roles.global_user.description",
@@ -427,9 +423,8 @@ func InitalizeRoles() {
PERMISSION_PERMANENT_DELETE_USER.Id,
},
}
- BuiltInRoles[ROLE_SYSTEM_USER.Id] = ROLE_SYSTEM_USER
- ROLE_SYSTEM_POST_ALL = &Role{
+ DefaultRoles[SYSTEM_POST_ALL_ROLE_ID] = &Role{
"system_post_all",
"authentication.roles.system_post_all.name",
"authentication.roles.system_post_all.description",
@@ -437,9 +432,8 @@ func InitalizeRoles() {
PERMISSION_CREATE_POST.Id,
},
}
- BuiltInRoles[ROLE_SYSTEM_POST_ALL.Id] = ROLE_SYSTEM_POST_ALL
- ROLE_SYSTEM_POST_ALL_PUBLIC = &Role{
+ 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",
@@ -447,9 +441,8 @@ func InitalizeRoles() {
PERMISSION_CREATE_POST_PUBLIC.Id,
},
}
- BuiltInRoles[ROLE_SYSTEM_POST_ALL_PUBLIC.Id] = ROLE_SYSTEM_POST_ALL_PUBLIC
- ROLE_SYSTEM_USER_ACCESS_TOKEN = &Role{
+ 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",
@@ -459,9 +452,8 @@ func InitalizeRoles() {
PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
},
}
- BuiltInRoles[ROLE_SYSTEM_USER_ACCESS_TOKEN.Id] = ROLE_SYSTEM_USER_ACCESS_TOKEN
- ROLE_SYSTEM_ADMIN = &Role{
+ DefaultRoles[SYSTEM_ADMIN_ROLE_ID] = &Role{
"system_admin",
"authentication.roles.global_admin.name",
"authentication.roles.global_admin.description",
@@ -500,17 +492,15 @@ func InitalizeRoles() {
PERMISSION_READ_USER_ACCESS_TOKEN.Id,
PERMISSION_REVOKE_USER_ACCESS_TOKEN.Id,
},
- ROLE_TEAM_USER.Permissions...,
+ DefaultRoles[TEAM_USER_ROLE_ID].Permissions...,
),
- ROLE_CHANNEL_USER.Permissions...,
+ DefaultRoles[CHANNEL_USER_ROLE_ID].Permissions...,
),
- ROLE_TEAM_ADMIN.Permissions...,
+ DefaultRoles[TEAM_ADMIN_ROLE_ID].Permissions...,
),
- ROLE_CHANNEL_ADMIN.Permissions...,
+ DefaultRoles[CHANNEL_ADMIN_ROLE_ID].Permissions...,
),
}
- BuiltInRoles[ROLE_SYSTEM_ADMIN.Id] = ROLE_SYSTEM_ADMIN
-
}
func RoleIdsToString(roles []string) string {
@@ -527,5 +517,6 @@ func RoleIdsToString(roles []string) string {
}
func init() {
- InitalizeRoles()
+ initializePermissions()
+ initializeDefaultRoles()
}
diff --git a/vendor/github.com/mattermost/platform/model/authorize.go b/vendor/github.com/mattermost/platform/model/authorize.go
index 460b7082..df07ff14 100644
--- a/vendor/github.com/mattermost/platform/model/authorize.go
+++ b/vendor/github.com/mattermost/platform/model/authorize.go
@@ -39,35 +39,35 @@ type AuthorizeRequest struct {
func (ad *AuthData) IsValid() *AppError {
if len(ad.ClientId) != 26 {
- return NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "")
+ return NewAppError("AuthData.IsValid", "model.authorize.is_valid.client_id.app_error", nil, "", http.StatusBadRequest)
}
if len(ad.UserId) != 26 {
- return NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.user_id.app_error", nil, "")
+ 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 NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.auth_code.app_error", nil, "client_id="+ad.ClientId)
+ return NewAppError("AuthData.IsValid", "model.authorize.is_valid.auth_code.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
}
if ad.ExpiresIn == 0 {
- return NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.expires.app_error", nil, "")
+ return NewAppError("AuthData.IsValid", "model.authorize.is_valid.expires.app_error", nil, "", http.StatusBadRequest)
}
if ad.CreateAt <= 0 {
- return NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.create_at.app_error", nil, "client_id="+ad.ClientId)
+ 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 NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.redirect_uri.app_error", nil, "client_id="+ad.ClientId)
+ 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 NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.state.app_error", nil, "client_id="+ad.ClientId)
+ return NewAppError("AuthData.IsValid", "model.authorize.is_valid.state.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
}
if len(ad.Scope) > 128 {
- return NewLocAppError("AuthData.IsValid", "model.authorize.is_valid.scope.app_error", nil, "client_id="+ad.ClientId)
+ return NewAppError("AuthData.IsValid", "model.authorize.is_valid.scope.app_error", nil, "client_id="+ad.ClientId, http.StatusBadRequest)
}
return nil
@@ -155,10 +155,5 @@ func AuthorizeRequestFromJson(data io.Reader) *AuthorizeRequest {
}
func (ad *AuthData) IsExpired() bool {
-
- if GetMillis() > ad.CreateAt+int64(ad.ExpiresIn*1000) {
- return true
- }
-
- return false
+ 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
new file mode 100644
index 00000000..5dd00a96
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/builtin.go
@@ -0,0 +1,9 @@
+// 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
new file mode 100644
index 00000000..6965159c
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/bundle_info.go
@@ -0,0 +1,23 @@
+// 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
index 50d48755..a4c733c3 100644
--- a/vendor/github.com/mattermost/platform/model/channel.go
+++ b/vendor/github.com/mattermost/platform/model/channel.go
@@ -8,6 +8,7 @@ import (
"encoding/hex"
"encoding/json"
"io"
+ "net/http"
"sort"
"strings"
"unicode/utf8"
@@ -24,6 +25,7 @@ const (
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
@@ -53,6 +55,11 @@ type ChannelPatch struct {
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 {
@@ -104,39 +111,39 @@ func (o *Channel) StatsEtag() string {
func (o *Channel) IsValid() *AppError {
if len(o.Id) != 26 {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "")
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.create_at.app_error", nil, "id="+o.Id)
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.UpdateAt == 0 {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.update_at.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Channel.IsValid", "model.channel.is_valid.display_name.app_error", nil, "id="+o.Id)
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.display_name.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if !IsValidChannelIdentifier(o.Name) {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.2_or_more.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Channel.IsValid", "model.channel.is_valid.type.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Channel.IsValid", "model.channel.is_valid.header.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Channel.IsValid", "model.channel.is_valid.purpose.app_error", nil, "id="+o.Id)
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.purpose.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if len(o.CreatorId) > 26 {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.creator_id.app_error", nil, "")
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.creator_id.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/channel_member.go b/vendor/github.com/mattermost/platform/model/channel_member.go
index f6d58519..e7ad8232 100644
--- a/vendor/github.com/mattermost/platform/model/channel_member.go
+++ b/vendor/github.com/mattermost/platform/model/channel_member.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"strings"
)
@@ -101,36 +102,32 @@ func ChannelMemberFromJson(data io.Reader) *ChannelMember {
func (o *ChannelMember) IsValid() *AppError {
if len(o.ChannelId) != 26 {
- return NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.channel_id.app_error", nil, "")
+ return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.UserId) != 26 {
- return NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.user_id.app_error", nil, "")
+ 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 NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.notify_level.app_error",
- nil, "notify_level="+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 NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.unread_level.app_error",
- nil, "mark_unread_level="+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 NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.push_level.app_error",
- nil, "push_notification_level="+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 NewLocAppError("ChannelMember.IsValid", "model.channel_member.is_valid.email_value.app_error",
- nil, "push_notification_level="+sendEmail)
+ return NewAppError("ChannelMember.IsValid", "model.channel_member.is_valid.email_value.app_error", nil, "push_notification_level="+sendEmail, http.StatusBadRequest)
}
}
diff --git a/vendor/github.com/mattermost/platform/model/channel_member_history.go b/vendor/github.com/mattermost/platform/model/channel_member_history.go
new file mode 100644
index 00000000..bc71b580
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/channel_member_history.go
@@ -0,0 +1,12 @@
+// 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_view.go b/vendor/github.com/mattermost/platform/model/channel_view.go
index 8a7ead76..e7b1de30 100644
--- a/vendor/github.com/mattermost/platform/model/channel_view.go
+++ b/vendor/github.com/mattermost/platform/model/channel_view.go
@@ -32,3 +32,28 @@ func ChannelViewFromJson(data io.Reader) *ChannelView {
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
index 564aa2e4..ef890b59 100644
--- a/vendor/github.com/mattermost/platform/model/client.go
+++ b/vendor/github.com/mattermost/platform/model/client.go
@@ -18,6 +18,8 @@ import (
l4g "github.com/alecthomas/log4go"
)
+var UsedApiV3 *int32 = new(int32)
+
const (
HEADER_REQUEST_ID = "X-Request-ID"
HEADER_VERSION_ID = "X-Version-ID"
@@ -37,7 +39,7 @@ const (
STATUS_FAIL = "FAIL"
STATUS_REMOVE = "REMOVE"
- CLIENT_DIR = "webapp/dist"
+ CLIENT_DIR = "client"
API_URL_SUFFIX_V1 = "/api/v1"
API_URL_SUFFIX_V3 = "/api/v3"
@@ -144,7 +146,7 @@ func (c *Client) DoPost(url, data, contentType string) (*http.Response, *AppErro
rq.Close = true
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ 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)
@@ -162,7 +164,7 @@ func (c *Client) DoApiPost(url string, data string) (*http.Response, *AppError)
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ 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)
@@ -184,7 +186,7 @@ func (c *Client) DoApiGet(url string, data string, etag string) (*http.Response,
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ 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 {
@@ -429,7 +431,7 @@ func (c *Client) UpdateTeam(team *Team) (*Result, *AppError) {
} else {
defer closeBody(r)
return &Result{r.Header.Get(HEADER_REQUEST_ID),
- r.Header.Get(HEADER_ETAG_SERVER), MapFromJson(r.Body)}, nil
+ r.Header.Get(HEADER_ETAG_SERVER), TeamFromJson(r.Body)}, nil
}
}
@@ -677,7 +679,7 @@ func (c *Client) login(m map[string]string) (*Result, *AppError) {
sessionToken := getCookie(SESSION_COOKIE_TOKEN, r)
if c.AuthToken != sessionToken.Value {
- NewLocAppError("/users/login", "model.client.login.app_error", nil, "")
+ NewAppError("/users/login", "model.client.login.app_error", nil, "", 0)
}
defer closeBody(r)
@@ -1054,7 +1056,7 @@ func (c *Client) DownloadComplianceReport(id string) (*Result, *AppError) {
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError("/admin/download_compliance_report", "model.client.connecting.app_error", nil, err.Error())
+ 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)
@@ -1527,19 +1529,19 @@ func (c *Client) UploadPostAttachment(data []byte, channelId string, filename st
writer := multipart.NewWriter(body)
if part, err := writer.CreateFormFile("files", filename); err != nil {
- return nil, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error())
+ 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, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.file.app_error", nil, err.Error())
+ 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, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error())
+ 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, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.channel_id.app_error", nil, err.Error())
+ 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, NewLocAppError("UploadPostAttachment", "model.client.upload_post_attachment.writer.app_error", nil, err.Error())
+ 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 {
@@ -1559,7 +1561,7 @@ func (c *Client) uploadFile(url string, data []byte, contentType string) (*Resul
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
return nil, AppErrorFromJson(rp.Body)
} else {
@@ -2175,17 +2177,17 @@ func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoj
writer := multipart.NewWriter(body)
if part, err := writer.CreateFormFile("image", filename); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
+ 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, NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())
+ 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, NewLocAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error(), 0)
}
if err := writer.Close(); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error())
+ 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)
@@ -2197,7 +2199,7 @@ func (c *Client) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emoj
}
if r, err := c.HttpClient.Do(rq); err != nil {
- return nil, NewLocAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error())
+ return nil, NewAppError("CreateEmoji", "model.client.connecting.app_error", nil, err.Error(), 0)
} else if r.StatusCode >= 300 {
return nil, AppErrorFromJson(r.Body)
} else {
@@ -2241,7 +2243,7 @@ func (c *Client) UploadCertificateFile(data []byte, contentType string) *AppErro
}
if rp, err := c.HttpClient.Do(rq); err != nil {
- return NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ return NewAppError(url, "model.client.connecting.app_error", nil, err.Error(), 0)
} else if rp.StatusCode >= 300 {
return AppErrorFromJson(rp.Body)
} else {
diff --git a/vendor/github.com/mattermost/platform/model/client4.go b/vendor/github.com/mattermost/platform/model/client4.go
index 0f757853..e84a23e5 100644
--- a/vendor/github.com/mattermost/platform/model/client4.go
+++ b/vendor/github.com/mattermost/platform/model/client4.go
@@ -44,7 +44,7 @@ func BuildErrorResponse(r *http.Response, err *AppError) *Response {
header = r.Header
} else {
statusCode = 0
- header = make(http.Header, 0)
+ header = make(http.Header)
}
return &Response{
@@ -178,6 +178,14 @@ 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")
}
@@ -246,6 +254,10 @@ 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")
}
@@ -319,7 +331,7 @@ func (c *Client4) DoApiRequest(method, url, data, etag string) (*http.Response,
}
if rp, err := c.HttpClient.Do(rq); err != nil || rp == nil {
- return nil, NewLocAppError(url, "model.client.connecting.app_error", nil, err.Error())
+ 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 {
@@ -754,6 +766,16 @@ func (c *Client4) PatchUser(userId string, patch *UserPatch) (*User, *Response)
}
}
+// 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.
@@ -889,6 +911,16 @@ func (c *Client4) RevokeSession(userId, sessionId string) (bool, *Response) {
}
}
+// 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}
@@ -1043,6 +1075,32 @@ func (c *Client4) RevokeUserAccessToken(tokenId string) (bool, *Response) {
}
}
+// 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.
@@ -1562,13 +1620,13 @@ func (c *Client4) GetChannelMembersForUser(userId, teamId, etag string) (*Channe
}
// 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) (bool, *Response) {
+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 false, BuildErrorResponse(r, err)
+ return nil, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
- return CheckStatusOK(r), BuildResponse(r)
+ return ChannelViewResponseFromJson(r.Body), BuildResponse(r)
}
}
@@ -1615,6 +1673,17 @@ func (c *Client4) AddChannelMember(channelId, userId string) (*ChannelMember, *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 {
@@ -1803,6 +1872,16 @@ func (c *Client4) SearchPosts(teamId string, terms string, isOrSearch bool) (*Po
}
}
+// 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.
@@ -2580,7 +2659,7 @@ func (c *Client4) UploadBrandImage(data []byte) (bool, *Response) {
// GetLogs page of logs as a string array.
func (c *Client4) GetLogs(page, perPage int) ([]string, *Response) {
- query := fmt.Sprintf("?page=%v&per_page=%v", page, perPage)
+ 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 {
@@ -2613,6 +2692,16 @@ func (c *Client4) CreateOAuthApp(app *OAuthApp) (*OAuthApp, *Response) {
}
}
+// 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)
@@ -2711,7 +2800,7 @@ func (c *Client4) TestElasticsearch() (bool, *Response) {
// PurgeElasticsearchIndexes immediately deletes all Elasticsearch indexes.
func (c *Client4) PurgeElasticsearchIndexes() (bool, *Response) {
- if r, err := c.DoApiPost(c.GetElasticsearchRoute()+"/test", ""); err != nil {
+ if r, err := c.DoApiPost(c.GetElasticsearchRoute()+"/purge_indexes", ""); err != nil {
return false, BuildErrorResponse(r, err)
} else {
defer closeBody(r)
@@ -2719,6 +2808,18 @@ func (c *Client4) PurgeElasticsearchIndexes() (bool, *Response) {
}
}
+// 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.
@@ -2762,9 +2863,28 @@ func (c *Client4) ListCommands(teamId string, customOnly bool) ([]*Command, *Res
}
}
-// ExecuteCommand executes a given command.
+// ExecuteCommand executes a given slash command.
func (c *Client4) ExecuteCommand(channelId, command string) (*CommandResponse, *Response) {
- commandArgs := &CommandArgs{ChannelId: channelId, Command: command}
+ 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 {
@@ -2849,17 +2969,17 @@ func (c *Client4) CreateEmoji(emoji *Emoji, image []byte, filename string) (*Emo
writer := multipart.NewWriter(body)
if part, err := writer.CreateFormFile("image", filename); err != nil {
- return nil, &Response{StatusCode: http.StatusForbidden, Error: NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())}
+ 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: NewLocAppError("CreateEmoji", "model.client.create_emoji.image.app_error", nil, err.Error())}
+ 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: NewLocAppError("CreateEmoji", "model.client.create_emoji.emoji.app_error", nil, err.Error())}
+ 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: NewLocAppError("CreateEmoji", "model.client.create_emoji.writer.app_error", nil, err.Error())}
+ 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())
@@ -3009,3 +3129,97 @@ func (c *Client4) CancelJob(jobId string) (bool, *Response) {
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
index 4b926965..89e5fc95 100644
--- a/vendor/github.com/mattermost/platform/model/cluster_discovery.go
+++ b/vendor/github.com/mattermost/platform/model/cluster_discovery.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"os"
)
@@ -85,27 +86,27 @@ func FilterClusterDiscovery(vs []*ClusterDiscovery, f func(*ClusterDiscovery) bo
func (o *ClusterDiscovery) IsValid() *AppError {
if len(o.Id) != 26 {
- return NewLocAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "")
+ return NewAppError("Channel.IsValid", "model.channel.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.ClusterName) == 0 {
- return NewLocAppError("ClusterDiscovery.IsValid", "ClusterName must be set", nil, "")
+ return NewAppError("ClusterDiscovery.IsValid", "ClusterName must be set", nil, "", http.StatusBadRequest)
}
if len(o.Type) == 0 {
- return NewLocAppError("ClusterDiscovery.IsValid", "Type must be set", nil, "")
+ return NewAppError("ClusterDiscovery.IsValid", "Type must be set", nil, "", http.StatusBadRequest)
}
if len(o.Hostname) == 0 {
- return NewLocAppError("ClusterDiscovery.IsValid", "Hostname must be set", nil, "")
+ return NewAppError("ClusterDiscovery.IsValid", "Hostname must be set", nil, "", http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("ClusterDiscovery.IsValid", "CreateAt must be set", nil, "")
+ return NewAppError("ClusterDiscovery.IsValid", "CreateAt must be set", nil, "", http.StatusBadRequest)
}
if o.LastPingAt == 0 {
- return NewLocAppError("ClusterDiscovery.IsValid", "LastPingAt must be set", nil, "")
+ return NewAppError("ClusterDiscovery.IsValid", "LastPingAt must be set", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/cluster_info.go b/vendor/github.com/mattermost/platform/model/cluster_info.go
index 1e468044..c4f7e89a 100644
--- a/vendor/github.com/mattermost/platform/model/cluster_info.go
+++ b/vendor/github.com/mattermost/platform/model/cluster_info.go
@@ -10,6 +10,7 @@ import (
)
type ClusterInfo struct {
+ Id string `json:"id"`
Version string `json:"version"`
ConfigHash string `json:"config_hash"`
IpAddress string `json:"ipaddress"`
diff --git a/vendor/github.com/mattermost/platform/model/command.go b/vendor/github.com/mattermost/platform/model/command.go
index 47378bbe..69da41c1 100644
--- a/vendor/github.com/mattermost/platform/model/command.go
+++ b/vendor/github.com/mattermost/platform/model/command.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"strings"
)
@@ -79,51 +80,51 @@ func CommandListFromJson(data io.Reader) []*Command {
func (o *Command) IsValid() *AppError {
if len(o.Id) != 26 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.Token) != 26 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.token.app_error", nil, "", http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
}
if o.UpdateAt == 0 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.update_at.app_error", nil, "", http.StatusBadRequest)
}
if len(o.CreatorId) != 26 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.TeamId) != 26 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.team_id.app_error", nil, "")
+ 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 NewLocAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.trigger.app_error", nil, "", http.StatusBadRequest)
}
if len(o.URL) == 0 || len(o.URL) > 1024 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.url.app_error", nil, "", http.StatusBadRequest)
}
if !IsValidHttpUrl(o.URL) {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.url_http.app_error", nil, "")
+ 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 NewLocAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.method.app_error", nil, "", http.StatusBadRequest)
}
if len(o.DisplayName) > 64 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.display_name.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.display_name.app_error", nil, "", http.StatusBadRequest)
}
if len(o.Description) > 128 {
- return NewLocAppError("Command.IsValid", "model.command.is_valid.description.app_error", nil, "")
+ return NewAppError("Command.IsValid", "model.command.is_valid.description.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/command_response.go b/vendor/github.com/mattermost/platform/model/command_response.go
index 27d39e17..a3a171ce 100644
--- a/vendor/github.com/mattermost/platform/model/command_response.go
+++ b/vendor/github.com/mattermost/platform/model/command_response.go
@@ -6,6 +6,8 @@ package model
import (
"encoding/json"
"io"
+ "io/ioutil"
+ "strings"
)
const (
@@ -18,6 +20,8 @@ type CommandResponse struct {
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"`
}
@@ -31,6 +35,22 @@ func (o *CommandResponse) ToJson() string {
}
}
+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
@@ -39,8 +59,7 @@ func CommandResponseFromJson(data io.Reader) *CommandResponse {
return nil
}
- o.Text = ExpandAnnouncement(o.Text)
- o.Attachments = ProcessSlackAttachments(o.Attachments)
+ 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
new file mode 100644
index 00000000..0b00e00b
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/command_webhook.go
@@ -0,0 +1,65 @@
+// 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
index 14f8f4a5..3134ddba 100644
--- a/vendor/github.com/mattermost/platform/model/compliance.go
+++ b/vendor/github.com/mattermost/platform/model/compliance.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"strings"
)
@@ -75,27 +76,27 @@ func (me *Compliance) JobName() string {
func (me *Compliance) IsValid() *AppError {
if len(me.Id) != 26 {
- return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.id.app_error", nil, "")
+ return NewAppError("Compliance.IsValid", "model.compliance.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if me.CreateAt == 0 {
- return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.create_at.app_error", nil, "")
+ 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 NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.desc.app_error", nil, "")
+ return NewAppError("Compliance.IsValid", "model.compliance.is_valid.desc.app_error", nil, "", http.StatusBadRequest)
}
if me.StartAt == 0 {
- return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.start_at.app_error", nil, "")
+ return NewAppError("Compliance.IsValid", "model.compliance.is_valid.start_at.app_error", nil, "", http.StatusBadRequest)
}
if me.EndAt == 0 {
- return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.end_at.app_error", nil, "")
+ return NewAppError("Compliance.IsValid", "model.compliance.is_valid.end_at.app_error", nil, "", http.StatusBadRequest)
}
if me.EndAt <= me.StartAt {
- return NewLocAppError("Compliance.IsValid", "model.compliance.is_valid.start_end_at.app_error", nil, "")
+ return NewAppError("Compliance.IsValid", "model.compliance.is_valid.start_end_at.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/config.go b/vendor/github.com/mattermost/platform/model/config.go
index 1717d61a..fb34d1a0 100644
--- a/vendor/github.com/mattermost/platform/model/config.go
+++ b/vendor/github.com/mattermost/platform/model/config.go
@@ -8,6 +8,8 @@ import (
"io"
"net/http"
"net/url"
+ "strings"
+ "time"
)
const (
@@ -22,6 +24,10 @@ const (
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
@@ -71,17 +77,22 @@ const (
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_ALLOW_CORS_FROM = ""
+ 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/"
@@ -123,17 +134,32 @@ const (
ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR = "#f2a93b"
ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR = "#333333"
- 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
+ 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
+ ListenAddress *string
ConnectionSecurity *string
TLSCertFile *string
TLSKeyFile *string
@@ -142,7 +168,7 @@ type ServiceSettings struct {
Forward80To443 *bool
ReadTimeout *int
WriteTimeout *int
- MaximumLoginAttempts int
+ MaximumLoginAttempts *int
GoroutineHealthThreshold *int
GoogleDeveloperKey string
EnableOAuthServiceProvider bool
@@ -158,6 +184,7 @@ type ServiceSettings struct {
EnableDeveloper *bool
EnableSecurityFixAlert *bool
EnableInsecureOutgoingConnections *bool
+ AllowedUntrustedInternalConnections *string
EnableMultifactorAuthentication *bool
EnforceMultifactorAuthentication *bool
EnableUserAccessTokens *bool
@@ -166,6 +193,7 @@ type ServiceSettings struct {
SessionLengthMobileInDays *int
SessionLengthSSOInDays *int
SessionCacheInMinutes *int
+ SessionIdleTimeoutInMinutes *int
WebsocketSecurePort *int
WebsocketPort *int
WebserverMode *string
@@ -180,7 +208,211 @@ type ServiceSettings struct {
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 {
@@ -194,16 +426,70 @@ type ClusterSettings struct {
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
@@ -215,17 +501,43 @@ type SSOSettings struct {
}
type SqlSettings struct {
- DriverName string
- DataSource string
+ DriverName *string
+ DataSource *string
DataSourceReplicas []string
DataSourceSearchReplicas []string
- MaxIdleConns int
- MaxOpenConns int
+ 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
@@ -237,6 +549,12 @@ type LogSettings struct {
EnableDiagnostics *bool
}
+func (s *LogSettings) SetDefaults() {
+ if s.EnableDiagnostics == nil {
+ s.EnableDiagnostics = NewBool(true)
+ }
+}
+
type PasswordSettings struct {
MinimumLength *int
Lowercase *bool
@@ -245,12 +563,34 @@ type PasswordSettings struct {
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
+ DriverName *string
Directory string
EnablePublicLink bool
PublicLinkSalt *string
@@ -263,6 +603,64 @@ type FileSettings struct {
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 {
@@ -270,6 +668,7 @@ type EmailSettings struct {
EnableSignInWithEmail *bool
EnableSignInWithUsername *bool
SendEmailNotifications bool
+ UseChannelInEmailNotifications *bool
RequireEmailVerification bool
FeedbackName string
FeedbackEmail string
@@ -289,1412 +688,1441 @@ type EmailSettings struct {
EmailBatchingInterval *int
SkipServerCertificateVerification *bool
EmailNotificationContentsType *string
+ LoginButtonColor *string
+ LoginButtonBorderColor *string
+ LoginButtonTextColor *string
}
-type RateLimitSettings struct {
- Enable *bool
- PerSec int
- MaxBurst *int
- MemoryStoreSize int
- VaryByRemoteAddr bool
- VaryByHeader string
-}
-
-type PrivacySettings struct {
- ShowEmailAddress bool
- ShowFullName bool
-}
-
-type SupportSettings struct {
- TermsOfServiceLink *string
- PrivacyPolicyLink *string
- AboutLink *string
- HelpLink *string
- ReportAProblemLink *string
- AdministratorsGuideLink *string
- TroubleshootingForumLink *string
- CommercialSupportLink *string
- SupportEmail *string
-}
-
-type AnnouncementSettings struct {
- EnableBanner *bool
- BannerText *string
- BannerColor *string
- BannerTextColor *string
- AllowBannerDismissal *bool
-}
-
-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
- UserStatusAwayTimeout *int64
- MaxChannelsPerTeam *int64
- MaxNotificationsPerChannel *int64
- TeammateNameDisplay *string
-}
-
-type LdapSettings struct {
- // Basic
- Enable *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
-}
-
-type ComplianceSettings struct {
- Enable *bool
- Directory *string
- EnableDaily *bool
-}
+func (s *EmailSettings) SetDefaults() {
+ if len(s.InviteSalt) == 0 {
+ s.InviteSalt = NewRandomString(32)
+ }
-type LocalizationSettings struct {
- DefaultServerLocale *string
- DefaultClientLocale *string
- AvailableLocales *string
-}
+ if s.EnableSignInWithEmail == nil {
+ s.EnableSignInWithEmail = NewBool(s.EnableSignUpWithEmail)
+ }
-type SamlSettings struct {
- // Basic
- Enable *bool
- Verify *bool
- Encrypt *bool
+ if s.EnableSignInWithUsername == nil {
+ s.EnableSignInWithUsername = NewBool(false)
+ }
- IdpUrl *string
- IdpDescriptorUrl *string
- AssertionConsumerServiceURL *string
+ if s.UseChannelInEmailNotifications == nil {
+ s.UseChannelInEmailNotifications = NewBool(false)
+ }
- IdpCertificateFile *string
- PublicCertificateFile *string
- PrivateKeyFile *string
+ if s.SendPushNotifications == nil {
+ s.SendPushNotifications = NewBool(false)
+ }
- // User Mapping
- FirstNameAttribute *string
- LastNameAttribute *string
- EmailAttribute *string
- UsernameAttribute *string
- NicknameAttribute *string
- LocaleAttribute *string
- PositionAttribute *string
+ if s.PushNotificationServer == nil {
+ s.PushNotificationServer = NewString("")
+ }
- LoginButtonText *string
-}
+ if s.PushNotificationContents == nil {
+ s.PushNotificationContents = NewString(GENERIC_NOTIFICATION)
+ }
-type NativeAppSettings struct {
- AppDownloadLink *string
- AndroidAppDownloadLink *string
- IosAppDownloadLink *string
-}
+ if s.FeedbackOrganization == nil {
+ s.FeedbackOrganization = NewString(EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION)
+ }
-type WebrtcSettings struct {
- Enable *bool
- GatewayWebsocketUrl *string
- GatewayAdminUrl *string
- GatewayAdminSecret *string
- StunURI *string
- TurnURI *string
- TurnUsername *string
- TurnSharedKey *string
-}
+ if s.EnableEmailBatching == nil {
+ s.EnableEmailBatching = NewBool(false)
+ }
-type ElasticsearchSettings struct {
- ConnectionUrl *string
- Username *string
- Password *string
- EnableIndexing *bool
- EnableSearching *bool
- Sniff *bool
- PostIndexReplicas *int
- PostIndexShards *int
-}
+ if s.EmailBatchingBufferSize == nil {
+ s.EmailBatchingBufferSize = NewInt(EMAIL_BATCHING_BUFFER_SIZE)
+ }
-type DataRetentionSettings struct {
- Enable *bool
-}
+ if s.EmailBatchingInterval == nil {
+ s.EmailBatchingInterval = NewInt(EMAIL_BATCHING_INTERVAL)
+ }
-type JobSettings struct {
- RunJobs *bool
- RunScheduler *bool
-}
+ if s.EnableSMTPAuth == nil {
+ s.EnableSMTPAuth = new(bool)
+ if s.ConnectionSecurity == CONN_SECURITY_NONE {
+ *s.EnableSMTPAuth = false
+ } else {
+ *s.EnableSMTPAuth = true
+ }
+ }
-type PluginSettings struct {
- Plugins map[string]interface{}
-}
+ if s.ConnectionSecurity == CONN_SECURITY_PLAIN {
+ s.ConnectionSecurity = CONN_SECURITY_NONE
+ }
-type Config struct {
- ServiceSettings ServiceSettings
- TeamSettings TeamSettings
- SqlSettings SqlSettings
- LogSettings LogSettings
- PasswordSettings PasswordSettings
- FileSettings FileSettings
- EmailSettings EmailSettings
- RateLimitSettings RateLimitSettings
- PrivacySettings PrivacySettings
- SupportSettings SupportSettings
- AnnouncementSettings AnnouncementSettings
- 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
- JobSettings JobSettings
- PluginSettings PluginSettings
-}
+ if s.SkipServerCertificateVerification == nil {
+ s.SkipServerCertificateVerification = NewBool(false)
+ }
-func (o *Config) ToJson() string {
- b, err := json.Marshal(o)
- if err != nil {
- return ""
- } else {
- return string(b)
+ if s.EmailNotificationContentsType == nil {
+ s.EmailNotificationContentsType = NewString(EMAIL_NOTIFICATION_CONTENTS_FULL)
}
-}
-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
+ if s.LoginButtonColor == nil {
+ s.LoginButtonColor = NewString("#0000")
}
- return nil
-}
+ if s.LoginButtonBorderColor == nil {
+ s.LoginButtonBorderColor = NewString("#2389D7")
+ }
-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
+ if s.LoginButtonTextColor == nil {
+ s.LoginButtonTextColor = NewString("#2389D7")
}
}
-func (o *Config) SetDefaults() {
+type RateLimitSettings struct {
+ Enable *bool
+ PerSec *int
+ MaxBurst *int
+ MemoryStoreSize *int
+ VaryByRemoteAddr bool
+ VaryByHeader string
+}
- if len(o.SqlSettings.AtRestEncryptKey) == 0 {
- o.SqlSettings.AtRestEncryptKey = NewRandomString(32)
+func (s *RateLimitSettings) SetDefaults() {
+ if s.Enable == nil {
+ s.Enable = NewBool(false)
}
- if o.SqlSettings.QueryTimeout == nil {
- o.SqlSettings.QueryTimeout = new(int)
- *o.SqlSettings.QueryTimeout = 30
+ if s.PerSec == nil {
+ s.PerSec = NewInt(10)
}
- if o.FileSettings.AmazonS3Endpoint == "" {
- // Defaults to "s3.amazonaws.com"
- o.FileSettings.AmazonS3Endpoint = "s3.amazonaws.com"
+ if s.MaxBurst == nil {
+ s.MaxBurst = NewInt(100)
}
- if o.FileSettings.AmazonS3SSL == nil {
- o.FileSettings.AmazonS3SSL = new(bool)
- *o.FileSettings.AmazonS3SSL = true // Secure by default.
+ if s.MemoryStoreSize == nil {
+ s.MemoryStoreSize = NewInt(10000)
}
+}
- if o.FileSettings.AmazonS3SignV2 == nil {
- o.FileSettings.AmazonS3SignV2 = new(bool)
- // Signature v2 is not enabled by default.
- }
+type PrivacySettings struct {
+ ShowEmailAddress bool
+ ShowFullName bool
+}
- if o.FileSettings.AmazonS3SSE == nil {
- o.FileSettings.AmazonS3SSE = new(bool)
- *o.FileSettings.AmazonS3SSE = false // Not Encrypted by default.
- }
+type SupportSettings struct {
+ TermsOfServiceLink *string
+ PrivacyPolicyLink *string
+ AboutLink *string
+ HelpLink *string
+ ReportAProblemLink *string
+ SupportEmail *string
+}
- if o.FileSettings.EnableFileAttachments == nil {
- o.FileSettings.EnableFileAttachments = new(bool)
- *o.FileSettings.EnableFileAttachments = true
+func (s *SupportSettings) SetDefaults() {
+ if !IsSafeLink(s.TermsOfServiceLink) {
+ *s.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
}
- if o.FileSettings.EnableMobileUpload == nil {
- o.FileSettings.EnableMobileUpload = new(bool)
- *o.FileSettings.EnableMobileUpload = true
+ if s.TermsOfServiceLink == nil {
+ s.TermsOfServiceLink = NewString(SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK)
}
- if o.FileSettings.EnableMobileDownload == nil {
- o.FileSettings.EnableMobileDownload = new(bool)
- *o.FileSettings.EnableMobileDownload = true
+ if !IsSafeLink(s.PrivacyPolicyLink) {
+ *s.PrivacyPolicyLink = ""
}
- if o.FileSettings.MaxFileSize == nil {
- o.FileSettings.MaxFileSize = new(int64)
- *o.FileSettings.MaxFileSize = 52428800 // 50 MB
+ if s.PrivacyPolicyLink == nil {
+ s.PrivacyPolicyLink = NewString(SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK)
}
- if o.FileSettings.PublicLinkSalt == nil || len(*o.FileSettings.PublicLinkSalt) == 0 {
- o.FileSettings.PublicLinkSalt = new(string)
- *o.FileSettings.PublicLinkSalt = NewRandomString(32)
+ if !IsSafeLink(s.AboutLink) {
+ *s.AboutLink = ""
}
- if o.FileSettings.InitialFont == "" {
- // Defaults to "luximbi.ttf"
- o.FileSettings.InitialFont = "luximbi.ttf"
+ if s.AboutLink == nil {
+ s.AboutLink = NewString(SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK)
}
- if o.FileSettings.Directory == "" {
- o.FileSettings.Directory = "./data/"
+ if !IsSafeLink(s.HelpLink) {
+ *s.HelpLink = ""
}
- if len(o.EmailSettings.InviteSalt) == 0 {
- o.EmailSettings.InviteSalt = NewRandomString(32)
+ if s.HelpLink == nil {
+ s.HelpLink = NewString(SUPPORT_SETTINGS_DEFAULT_HELP_LINK)
}
- if o.ServiceSettings.SiteURL == nil {
- o.ServiceSettings.SiteURL = new(string)
- *o.ServiceSettings.SiteURL = SERVICE_SETTINGS_DEFAULT_SITE_URL
+ if !IsSafeLink(s.ReportAProblemLink) {
+ *s.ReportAProblemLink = ""
}
- if o.ServiceSettings.LicenseFileLocation == nil {
- o.ServiceSettings.LicenseFileLocation = new(string)
+ if s.ReportAProblemLink == nil {
+ s.ReportAProblemLink = NewString(SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK)
}
- if o.ServiceSettings.EnableAPIv3 == nil {
- o.ServiceSettings.EnableAPIv3 = new(bool)
- *o.ServiceSettings.EnableAPIv3 = true
+ if s.SupportEmail == nil {
+ s.SupportEmail = NewString(SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL)
}
+}
- if o.ServiceSettings.EnableLinkPreviews == nil {
- o.ServiceSettings.EnableLinkPreviews = new(bool)
- *o.ServiceSettings.EnableLinkPreviews = false
- }
+type AnnouncementSettings struct {
+ EnableBanner *bool
+ BannerText *string
+ BannerColor *string
+ BannerTextColor *string
+ AllowBannerDismissal *bool
+}
- if o.ServiceSettings.EnableDeveloper == nil {
- o.ServiceSettings.EnableDeveloper = new(bool)
- *o.ServiceSettings.EnableDeveloper = false
+func (s *AnnouncementSettings) SetDefaults() {
+ if s.EnableBanner == nil {
+ s.EnableBanner = NewBool(false)
}
- if o.ServiceSettings.EnableSecurityFixAlert == nil {
- o.ServiceSettings.EnableSecurityFixAlert = new(bool)
- *o.ServiceSettings.EnableSecurityFixAlert = true
+ if s.BannerText == nil {
+ s.BannerText = NewString("")
}
- if o.ServiceSettings.EnableInsecureOutgoingConnections == nil {
- o.ServiceSettings.EnableInsecureOutgoingConnections = new(bool)
- *o.ServiceSettings.EnableInsecureOutgoingConnections = false
+ if s.BannerColor == nil {
+ s.BannerColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR)
}
- if o.ServiceSettings.EnableMultifactorAuthentication == nil {
- o.ServiceSettings.EnableMultifactorAuthentication = new(bool)
- *o.ServiceSettings.EnableMultifactorAuthentication = false
+ if s.BannerTextColor == nil {
+ s.BannerTextColor = NewString(ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR)
}
- if o.ServiceSettings.EnforceMultifactorAuthentication == nil {
- o.ServiceSettings.EnforceMultifactorAuthentication = new(bool)
- *o.ServiceSettings.EnforceMultifactorAuthentication = false
+ if s.AllowBannerDismissal == nil {
+ s.AllowBannerDismissal = NewBool(true)
}
+}
- if o.ServiceSettings.EnableUserAccessTokens == nil {
- o.ServiceSettings.EnableUserAccessTokens = new(bool)
- *o.ServiceSettings.EnableUserAccessTokens = false
- }
+type ThemeSettings struct {
+ EnableThemeSelection *bool
+ DefaultTheme *string
+ AllowCustomThemes *bool
+ AllowedThemes []string
+}
- if o.PasswordSettings.MinimumLength == nil {
- o.PasswordSettings.MinimumLength = new(int)
- *o.PasswordSettings.MinimumLength = PASSWORD_MINIMUM_LENGTH
+func (s *ThemeSettings) SetDefaults() {
+ if s.EnableThemeSelection == nil {
+ s.EnableThemeSelection = NewBool(true)
}
- if o.PasswordSettings.Lowercase == nil {
- o.PasswordSettings.Lowercase = new(bool)
- *o.PasswordSettings.Lowercase = false
+ if s.DefaultTheme == nil {
+ s.DefaultTheme = NewString(TEAM_SETTINGS_DEFAULT_TEAM_TEXT)
}
- if o.PasswordSettings.Number == nil {
- o.PasswordSettings.Number = new(bool)
- *o.PasswordSettings.Number = false
+ if s.AllowCustomThemes == nil {
+ s.AllowCustomThemes = NewBool(true)
}
- if o.PasswordSettings.Uppercase == nil {
- o.PasswordSettings.Uppercase = new(bool)
- *o.PasswordSettings.Uppercase = false
+ 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
+}
- if o.PasswordSettings.Symbol == nil {
- o.PasswordSettings.Symbol = new(bool)
- *o.PasswordSettings.Symbol = false
+func (s *TeamSettings) SetDefaults() {
+ if s.MaxUsersPerTeam == nil {
+ s.MaxUsersPerTeam = NewInt(TEAM_SETTINGS_DEFAULT_MAX_USERS_PER_TEAM)
}
- if o.TeamSettings.EnableCustomBrand == nil {
- o.TeamSettings.EnableCustomBrand = new(bool)
- *o.TeamSettings.EnableCustomBrand = false
+ if s.EnableCustomBrand == nil {
+ s.EnableCustomBrand = NewBool(false)
}
- if o.TeamSettings.CustomBrandText == nil {
- o.TeamSettings.CustomBrandText = new(string)
- *o.TeamSettings.CustomBrandText = TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT
+ if s.CustomBrandText == nil {
+ s.CustomBrandText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_BRAND_TEXT)
}
- if o.TeamSettings.CustomDescriptionText == nil {
- o.TeamSettings.CustomDescriptionText = new(string)
- *o.TeamSettings.CustomDescriptionText = TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT
+ if s.CustomDescriptionText == nil {
+ s.CustomDescriptionText = NewString(TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT)
}
- if o.TeamSettings.EnableOpenServer == nil {
- o.TeamSettings.EnableOpenServer = new(bool)
- *o.TeamSettings.EnableOpenServer = false
+ if s.EnableOpenServer == nil {
+ s.EnableOpenServer = NewBool(false)
}
- if o.TeamSettings.RestrictDirectMessage == nil {
- o.TeamSettings.RestrictDirectMessage = new(string)
- *o.TeamSettings.RestrictDirectMessage = DIRECT_MESSAGE_ANY
+ if s.RestrictDirectMessage == nil {
+ s.RestrictDirectMessage = NewString(DIRECT_MESSAGE_ANY)
}
- if o.TeamSettings.RestrictTeamInvite == nil {
- o.TeamSettings.RestrictTeamInvite = new(string)
- *o.TeamSettings.RestrictTeamInvite = PERMISSIONS_ALL
+ if s.RestrictTeamInvite == nil {
+ s.RestrictTeamInvite = NewString(PERMISSIONS_ALL)
}
- if o.TeamSettings.RestrictPublicChannelManagement == nil {
- o.TeamSettings.RestrictPublicChannelManagement = new(string)
- *o.TeamSettings.RestrictPublicChannelManagement = PERMISSIONS_ALL
+ if s.RestrictPublicChannelManagement == nil {
+ s.RestrictPublicChannelManagement = NewString(PERMISSIONS_ALL)
}
- if o.TeamSettings.RestrictPrivateChannelManagement == nil {
- o.TeamSettings.RestrictPrivateChannelManagement = new(string)
- *o.TeamSettings.RestrictPrivateChannelManagement = PERMISSIONS_ALL
+ if s.RestrictPrivateChannelManagement == nil {
+ s.RestrictPrivateChannelManagement = NewString(PERMISSIONS_ALL)
}
- if o.TeamSettings.RestrictPublicChannelCreation == nil {
- o.TeamSettings.RestrictPublicChannelCreation = new(string)
+ 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 *o.TeamSettings.RestrictPublicChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
- *o.TeamSettings.RestrictPublicChannelCreation = PERMISSIONS_TEAM_ADMIN
+ if *s.RestrictPublicChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
+ *s.RestrictPublicChannelCreation = PERMISSIONS_TEAM_ADMIN
} else {
- *o.TeamSettings.RestrictPublicChannelCreation = *o.TeamSettings.RestrictPublicChannelManagement
+ *s.RestrictPublicChannelCreation = *s.RestrictPublicChannelManagement
}
}
- if o.TeamSettings.RestrictPrivateChannelCreation == nil {
- o.TeamSettings.RestrictPrivateChannelCreation = new(string)
+ if s.RestrictPrivateChannelCreation == nil {
// If this setting does not exist, assume migration from <3.6, so use management setting as default.
- if *o.TeamSettings.RestrictPrivateChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
- *o.TeamSettings.RestrictPrivateChannelCreation = PERMISSIONS_TEAM_ADMIN
+ if *s.RestrictPrivateChannelManagement == PERMISSIONS_CHANNEL_ADMIN {
+ s.RestrictPrivateChannelCreation = NewString(PERMISSIONS_TEAM_ADMIN)
} else {
- *o.TeamSettings.RestrictPrivateChannelCreation = *o.TeamSettings.RestrictPrivateChannelManagement
+ s.RestrictPrivateChannelCreation = NewString(*s.RestrictPrivateChannelManagement)
}
}
- if o.TeamSettings.RestrictPublicChannelDeletion == nil {
- o.TeamSettings.RestrictPublicChannelDeletion = new(string)
+ if s.RestrictPublicChannelDeletion == nil {
// If this setting does not exist, assume migration from <3.6, so use management setting as default.
- *o.TeamSettings.RestrictPublicChannelDeletion = *o.TeamSettings.RestrictPublicChannelManagement
+ s.RestrictPublicChannelDeletion = NewString(*s.RestrictPublicChannelManagement)
}
- if o.TeamSettings.RestrictPrivateChannelDeletion == nil {
- o.TeamSettings.RestrictPrivateChannelDeletion = new(string)
+ if s.RestrictPrivateChannelDeletion == nil {
// If this setting does not exist, assume migration from <3.6, so use management setting as default.
- *o.TeamSettings.RestrictPrivateChannelDeletion = *o.TeamSettings.RestrictPrivateChannelManagement
+ s.RestrictPrivateChannelDeletion = NewString(*s.RestrictPrivateChannelManagement)
}
- if o.TeamSettings.RestrictPrivateChannelManageMembers == nil {
- o.TeamSettings.RestrictPrivateChannelManageMembers = new(string)
- *o.TeamSettings.RestrictPrivateChannelManageMembers = PERMISSIONS_ALL
+ if s.RestrictPrivateChannelManageMembers == nil {
+ s.RestrictPrivateChannelManageMembers = NewString(PERMISSIONS_ALL)
}
- if o.TeamSettings.UserStatusAwayTimeout == nil {
- o.TeamSettings.UserStatusAwayTimeout = new(int64)
- *o.TeamSettings.UserStatusAwayTimeout = TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT
+ if s.EnableXToLeaveChannelsFromLHS == nil {
+ s.EnableXToLeaveChannelsFromLHS = NewBool(false)
}
- if o.TeamSettings.MaxChannelsPerTeam == nil {
- o.TeamSettings.MaxChannelsPerTeam = new(int64)
- *o.TeamSettings.MaxChannelsPerTeam = 2000
+ if s.UserStatusAwayTimeout == nil {
+ s.UserStatusAwayTimeout = NewInt64(TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT)
}
- if o.TeamSettings.MaxNotificationsPerChannel == nil {
- o.TeamSettings.MaxNotificationsPerChannel = new(int64)
- *o.TeamSettings.MaxNotificationsPerChannel = 1000
+ if s.MaxChannelsPerTeam == nil {
+ s.MaxChannelsPerTeam = NewInt64(2000)
}
- if o.EmailSettings.EnableSignInWithEmail == nil {
- o.EmailSettings.EnableSignInWithEmail = new(bool)
-
- if o.EmailSettings.EnableSignUpWithEmail == true {
- *o.EmailSettings.EnableSignInWithEmail = true
- } else {
- *o.EmailSettings.EnableSignInWithEmail = false
- }
+ if s.MaxNotificationsPerChannel == nil {
+ s.MaxNotificationsPerChannel = NewInt64(1000)
}
- if o.EmailSettings.EnableSignInWithUsername == nil {
- o.EmailSettings.EnableSignInWithUsername = new(bool)
- *o.EmailSettings.EnableSignInWithUsername = false
+ if s.EnableConfirmNotificationsToChannel == nil {
+ s.EnableConfirmNotificationsToChannel = NewBool(true)
}
- if o.EmailSettings.SendPushNotifications == nil {
- o.EmailSettings.SendPushNotifications = new(bool)
- *o.EmailSettings.SendPushNotifications = false
+ if s.ExperimentalTownSquareIsReadOnly == nil {
+ s.ExperimentalTownSquareIsReadOnly = NewBool(false)
}
- if o.EmailSettings.PushNotificationServer == nil {
- o.EmailSettings.PushNotificationServer = new(string)
- *o.EmailSettings.PushNotificationServer = ""
+ if s.ExperimentalPrimaryTeam == nil {
+ s.ExperimentalPrimaryTeam = NewString("")
}
+}
- if o.EmailSettings.PushNotificationContents == nil {
- o.EmailSettings.PushNotificationContents = new(string)
- *o.EmailSettings.PushNotificationContents = GENERIC_NOTIFICATION
- }
+type ClientRequirements struct {
+ AndroidLatestVersion string
+ AndroidMinVersion string
+ DesktopLatestVersion string
+ DesktopMinVersion string
+ IosLatestVersion string
+ IosMinVersion string
+}
- if o.EmailSettings.FeedbackOrganization == nil {
- o.EmailSettings.FeedbackOrganization = new(string)
- *o.EmailSettings.FeedbackOrganization = EMAIL_SETTINGS_DEFAULT_FEEDBACK_ORGANIZATION
- }
+type LdapSettings struct {
+ // Basic
+ Enable *bool
+ EnableSync *bool
+ LdapServer *string
+ LdapPort *int
+ ConnectionSecurity *string
+ BaseDN *string
+ BindUsername *string
+ BindPassword *string
- if o.EmailSettings.EnableEmailBatching == nil {
- o.EmailSettings.EnableEmailBatching = new(bool)
- *o.EmailSettings.EnableEmailBatching = false
- }
+ // Filtering
+ UserFilter *string
- if o.EmailSettings.EmailBatchingBufferSize == nil {
- o.EmailSettings.EmailBatchingBufferSize = new(int)
- *o.EmailSettings.EmailBatchingBufferSize = EMAIL_BATCHING_BUFFER_SIZE
- }
+ // User Mapping
+ FirstNameAttribute *string
+ LastNameAttribute *string
+ EmailAttribute *string
+ UsernameAttribute *string
+ NicknameAttribute *string
+ IdAttribute *string
+ PositionAttribute *string
- if o.EmailSettings.EmailBatchingInterval == nil {
- o.EmailSettings.EmailBatchingInterval = new(int)
- *o.EmailSettings.EmailBatchingInterval = EMAIL_BATCHING_INTERVAL
- }
+ // Syncronization
+ SyncIntervalMinutes *int
- if o.EmailSettings.EnableSMTPAuth == nil {
- o.EmailSettings.EnableSMTPAuth = new(bool)
- if o.EmailSettings.ConnectionSecurity == CONN_SECURITY_NONE {
- *o.EmailSettings.EnableSMTPAuth = false
- } else {
- *o.EmailSettings.EnableSMTPAuth = true
- }
- }
+ // Advanced
+ SkipCertificateVerification *bool
+ QueryTimeout *int
+ MaxPageSize *int
- if o.EmailSettings.ConnectionSecurity == CONN_SECURITY_PLAIN {
- o.EmailSettings.ConnectionSecurity = CONN_SECURITY_NONE
- }
+ // Customization
+ LoginFieldName *string
- if o.EmailSettings.SkipServerCertificateVerification == nil {
- o.EmailSettings.SkipServerCertificateVerification = new(bool)
- *o.EmailSettings.SkipServerCertificateVerification = false
- }
+ LoginButtonColor *string
+ LoginButtonBorderColor *string
+ LoginButtonTextColor *string
+}
- if o.EmailSettings.EmailNotificationContentsType == nil {
- o.EmailSettings.EmailNotificationContentsType = new(string)
- *o.EmailSettings.EmailNotificationContentsType = EMAIL_NOTIFICATION_CONTENTS_FULL
+func (s *LdapSettings) SetDefaults() {
+ if s.Enable == nil {
+ s.Enable = NewBool(false)
}
- if !IsSafeLink(o.SupportSettings.TermsOfServiceLink) {
- *o.SupportSettings.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
+ // When unset should default to LDAP Enabled
+ if s.EnableSync == nil {
+ s.EnableSync = NewBool(*s.Enable)
}
- if o.SupportSettings.TermsOfServiceLink == nil {
- o.SupportSettings.TermsOfServiceLink = new(string)
- *o.SupportSettings.TermsOfServiceLink = SUPPORT_SETTINGS_DEFAULT_TERMS_OF_SERVICE_LINK
+ if s.LdapServer == nil {
+ s.LdapServer = NewString("")
}
- if !IsSafeLink(o.SupportSettings.PrivacyPolicyLink) {
- *o.SupportSettings.PrivacyPolicyLink = ""
+ if s.LdapPort == nil {
+ s.LdapPort = NewInt(389)
}
- if o.SupportSettings.PrivacyPolicyLink == nil {
- o.SupportSettings.PrivacyPolicyLink = new(string)
- *o.SupportSettings.PrivacyPolicyLink = SUPPORT_SETTINGS_DEFAULT_PRIVACY_POLICY_LINK
+ if s.ConnectionSecurity == nil {
+ s.ConnectionSecurity = NewString("")
}
- if !IsSafeLink(o.SupportSettings.AboutLink) {
- *o.SupportSettings.AboutLink = ""
+ if s.BaseDN == nil {
+ s.BaseDN = NewString("")
}
- if o.SupportSettings.AboutLink == nil {
- o.SupportSettings.AboutLink = new(string)
- *o.SupportSettings.AboutLink = SUPPORT_SETTINGS_DEFAULT_ABOUT_LINK
+ if s.BindUsername == nil {
+ s.BindUsername = NewString("")
}
- if !IsSafeLink(o.SupportSettings.HelpLink) {
- *o.SupportSettings.HelpLink = ""
+ if s.BindPassword == nil {
+ s.BindPassword = NewString("")
}
- if o.SupportSettings.HelpLink == nil {
- o.SupportSettings.HelpLink = new(string)
- *o.SupportSettings.HelpLink = SUPPORT_SETTINGS_DEFAULT_HELP_LINK
+ if s.UserFilter == nil {
+ s.UserFilter = NewString("")
}
- if !IsSafeLink(o.SupportSettings.ReportAProblemLink) {
- *o.SupportSettings.ReportAProblemLink = ""
+ if s.FirstNameAttribute == nil {
+ s.FirstNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE)
}
- if o.SupportSettings.ReportAProblemLink == nil {
- o.SupportSettings.ReportAProblemLink = new(string)
- *o.SupportSettings.ReportAProblemLink = SUPPORT_SETTINGS_DEFAULT_REPORT_A_PROBLEM_LINK
+ if s.LastNameAttribute == nil {
+ s.LastNameAttribute = NewString(LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE)
}
- if !IsSafeLink(o.SupportSettings.AdministratorsGuideLink) {
- *o.SupportSettings.AdministratorsGuideLink = ""
+ if s.EmailAttribute == nil {
+ s.EmailAttribute = NewString(LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE)
}
- if o.SupportSettings.AdministratorsGuideLink == nil {
- o.SupportSettings.AdministratorsGuideLink = new(string)
- *o.SupportSettings.AdministratorsGuideLink = SUPPORT_SETTINGS_DEFAULT_ADMINISTRATORS_GUIDE_LINK
+ if s.UsernameAttribute == nil {
+ s.UsernameAttribute = NewString(LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE)
}
- if !IsSafeLink(o.SupportSettings.TroubleshootingForumLink) {
- *o.SupportSettings.TroubleshootingForumLink = ""
+ if s.NicknameAttribute == nil {
+ s.NicknameAttribute = NewString(LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE)
}
- if o.SupportSettings.TroubleshootingForumLink == nil {
- o.SupportSettings.TroubleshootingForumLink = new(string)
- *o.SupportSettings.TroubleshootingForumLink = SUPPORT_SETTINGS_DEFAULT_TROUBLESHOOTING_FORUM_LINK
+ if s.IdAttribute == nil {
+ s.IdAttribute = NewString(LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE)
}
- if !IsSafeLink(o.SupportSettings.CommercialSupportLink) {
- *o.SupportSettings.CommercialSupportLink = ""
+ if s.PositionAttribute == nil {
+ s.PositionAttribute = NewString(LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE)
}
- if o.SupportSettings.CommercialSupportLink == nil {
- o.SupportSettings.CommercialSupportLink = new(string)
- *o.SupportSettings.CommercialSupportLink = SUPPORT_SETTINGS_DEFAULT_COMMERCIAL_SUPPORT_LINK
+ if s.SyncIntervalMinutes == nil {
+ s.SyncIntervalMinutes = NewInt(60)
}
- if o.SupportSettings.SupportEmail == nil {
- o.SupportSettings.SupportEmail = new(string)
- *o.SupportSettings.SupportEmail = SUPPORT_SETTINGS_DEFAULT_SUPPORT_EMAIL
+ if s.SkipCertificateVerification == nil {
+ s.SkipCertificateVerification = NewBool(false)
}
- if o.AnnouncementSettings.EnableBanner == nil {
- o.AnnouncementSettings.EnableBanner = new(bool)
- *o.AnnouncementSettings.EnableBanner = false
+ if s.QueryTimeout == nil {
+ s.QueryTimeout = NewInt(60)
}
- if o.AnnouncementSettings.BannerText == nil {
- o.AnnouncementSettings.BannerText = new(string)
- *o.AnnouncementSettings.BannerText = ""
+ if s.MaxPageSize == nil {
+ s.MaxPageSize = NewInt(0)
}
- if o.AnnouncementSettings.BannerColor == nil {
- o.AnnouncementSettings.BannerColor = new(string)
- *o.AnnouncementSettings.BannerColor = ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_COLOR
+ if s.LoginFieldName == nil {
+ s.LoginFieldName = NewString(LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME)
}
- if o.AnnouncementSettings.BannerTextColor == nil {
- o.AnnouncementSettings.BannerTextColor = new(string)
- *o.AnnouncementSettings.BannerTextColor = ANNOUNCEMENT_SETTINGS_DEFAULT_BANNER_TEXT_COLOR
+ if s.LoginButtonColor == nil {
+ s.LoginButtonColor = NewString("#0000")
}
- if o.AnnouncementSettings.AllowBannerDismissal == nil {
- o.AnnouncementSettings.AllowBannerDismissal = new(bool)
- *o.AnnouncementSettings.AllowBannerDismissal = true
+ if s.LoginButtonBorderColor == nil {
+ s.LoginButtonBorderColor = NewString("#2389D7")
}
- if o.LdapSettings.Enable == nil {
- o.LdapSettings.Enable = new(bool)
- *o.LdapSettings.Enable = false
+ if s.LoginButtonTextColor == nil {
+ s.LoginButtonTextColor = NewString("#2389D7")
}
+}
- if o.LdapSettings.LdapServer == nil {
- o.LdapSettings.LdapServer = new(string)
- *o.LdapSettings.LdapServer = ""
- }
+type ComplianceSettings struct {
+ Enable *bool
+ Directory *string
+ EnableDaily *bool
+}
- if o.LdapSettings.LdapPort == nil {
- o.LdapSettings.LdapPort = new(int)
- *o.LdapSettings.LdapPort = 389
+func (s *ComplianceSettings) SetDefaults() {
+ if s.Enable == nil {
+ s.Enable = NewBool(false)
}
- if o.LdapSettings.ConnectionSecurity == nil {
- o.LdapSettings.ConnectionSecurity = new(string)
- *o.LdapSettings.ConnectionSecurity = ""
+ if s.Directory == nil {
+ s.Directory = NewString("./data/")
}
- if o.LdapSettings.BaseDN == nil {
- o.LdapSettings.BaseDN = new(string)
- *o.LdapSettings.BaseDN = ""
+ if s.EnableDaily == nil {
+ s.EnableDaily = NewBool(false)
}
+}
- if o.LdapSettings.BindUsername == nil {
- o.LdapSettings.BindUsername = new(string)
- *o.LdapSettings.BindUsername = ""
- }
+type LocalizationSettings struct {
+ DefaultServerLocale *string
+ DefaultClientLocale *string
+ AvailableLocales *string
+}
- if o.LdapSettings.BindPassword == nil {
- o.LdapSettings.BindPassword = new(string)
- *o.LdapSettings.BindPassword = ""
+func (s *LocalizationSettings) SetDefaults() {
+ if s.DefaultServerLocale == nil {
+ s.DefaultServerLocale = NewString(DEFAULT_LOCALE)
}
- if o.LdapSettings.UserFilter == nil {
- o.LdapSettings.UserFilter = new(string)
- *o.LdapSettings.UserFilter = ""
+ if s.DefaultClientLocale == nil {
+ s.DefaultClientLocale = NewString(DEFAULT_LOCALE)
}
- if o.LdapSettings.FirstNameAttribute == nil {
- o.LdapSettings.FirstNameAttribute = new(string)
- *o.LdapSettings.FirstNameAttribute = LDAP_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE
+ if s.AvailableLocales == nil {
+ s.AvailableLocales = NewString("")
}
+}
- if o.LdapSettings.LastNameAttribute == nil {
- o.LdapSettings.LastNameAttribute = new(string)
- *o.LdapSettings.LastNameAttribute = LDAP_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE
- }
+type SamlSettings struct {
+ // Basic
+ Enable *bool
+ EnableSyncWithLdap *bool
- if o.LdapSettings.EmailAttribute == nil {
- o.LdapSettings.EmailAttribute = new(string)
- *o.LdapSettings.EmailAttribute = LDAP_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE
- }
+ Verify *bool
+ Encrypt *bool
- if o.LdapSettings.UsernameAttribute == nil {
- o.LdapSettings.UsernameAttribute = new(string)
- *o.LdapSettings.UsernameAttribute = LDAP_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE
- }
+ IdpUrl *string
+ IdpDescriptorUrl *string
+ AssertionConsumerServiceURL *string
- if o.LdapSettings.NicknameAttribute == nil {
- o.LdapSettings.NicknameAttribute = new(string)
- *o.LdapSettings.NicknameAttribute = LDAP_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE
- }
+ IdpCertificateFile *string
+ PublicCertificateFile *string
+ PrivateKeyFile *string
- if o.LdapSettings.IdAttribute == nil {
- o.LdapSettings.IdAttribute = new(string)
- *o.LdapSettings.IdAttribute = LDAP_SETTINGS_DEFAULT_ID_ATTRIBUTE
- }
+ // User Mapping
+ FirstNameAttribute *string
+ LastNameAttribute *string
+ EmailAttribute *string
+ UsernameAttribute *string
+ NicknameAttribute *string
+ LocaleAttribute *string
+ PositionAttribute *string
- if o.LdapSettings.PositionAttribute == nil {
- o.LdapSettings.PositionAttribute = new(string)
- *o.LdapSettings.PositionAttribute = LDAP_SETTINGS_DEFAULT_POSITION_ATTRIBUTE
- }
+ LoginButtonText *string
- if o.LdapSettings.SyncIntervalMinutes == nil {
- o.LdapSettings.SyncIntervalMinutes = new(int)
- *o.LdapSettings.SyncIntervalMinutes = 60
- }
+ LoginButtonColor *string
+ LoginButtonBorderColor *string
+ LoginButtonTextColor *string
+}
- if o.LdapSettings.SkipCertificateVerification == nil {
- o.LdapSettings.SkipCertificateVerification = new(bool)
- *o.LdapSettings.SkipCertificateVerification = false
+func (s *SamlSettings) SetDefaults() {
+ if s.Enable == nil {
+ s.Enable = NewBool(false)
}
- if o.LdapSettings.QueryTimeout == nil {
- o.LdapSettings.QueryTimeout = new(int)
- *o.LdapSettings.QueryTimeout = 60
+ if s.EnableSyncWithLdap == nil {
+ s.EnableSyncWithLdap = NewBool(false)
}
- if o.LdapSettings.MaxPageSize == nil {
- o.LdapSettings.MaxPageSize = new(int)
- *o.LdapSettings.MaxPageSize = 0
+ if s.Verify == nil {
+ s.Verify = NewBool(true)
}
- if o.LdapSettings.LoginFieldName == nil {
- o.LdapSettings.LoginFieldName = new(string)
- *o.LdapSettings.LoginFieldName = LDAP_SETTINGS_DEFAULT_LOGIN_FIELD_NAME
+ if s.Encrypt == nil {
+ s.Encrypt = NewBool(true)
}
- if o.ServiceSettings.SessionLengthWebInDays == nil {
- o.ServiceSettings.SessionLengthWebInDays = new(int)
- *o.ServiceSettings.SessionLengthWebInDays = 30
+ if s.IdpUrl == nil {
+ s.IdpUrl = NewString("")
}
- if o.ServiceSettings.SessionLengthMobileInDays == nil {
- o.ServiceSettings.SessionLengthMobileInDays = new(int)
- *o.ServiceSettings.SessionLengthMobileInDays = 30
+ if s.IdpDescriptorUrl == nil {
+ s.IdpDescriptorUrl = NewString("")
}
- if o.ServiceSettings.SessionLengthSSOInDays == nil {
- o.ServiceSettings.SessionLengthSSOInDays = new(int)
- *o.ServiceSettings.SessionLengthSSOInDays = 30
+ if s.IdpCertificateFile == nil {
+ s.IdpCertificateFile = NewString("")
}
- if o.ServiceSettings.SessionCacheInMinutes == nil {
- o.ServiceSettings.SessionCacheInMinutes = new(int)
- *o.ServiceSettings.SessionCacheInMinutes = 10
+ if s.PublicCertificateFile == nil {
+ s.PublicCertificateFile = NewString("")
}
- if o.ServiceSettings.EnableCommands == nil {
- o.ServiceSettings.EnableCommands = new(bool)
- *o.ServiceSettings.EnableCommands = false
+ if s.PrivateKeyFile == nil {
+ s.PrivateKeyFile = NewString("")
}
- if o.ServiceSettings.EnableOnlyAdminIntegrations == nil {
- o.ServiceSettings.EnableOnlyAdminIntegrations = new(bool)
- *o.ServiceSettings.EnableOnlyAdminIntegrations = true
+ if s.AssertionConsumerServiceURL == nil {
+ s.AssertionConsumerServiceURL = NewString("")
}
- if o.ServiceSettings.WebsocketPort == nil {
- o.ServiceSettings.WebsocketPort = new(int)
- *o.ServiceSettings.WebsocketPort = 80
+ if s.LoginButtonText == nil || *s.LoginButtonText == "" {
+ s.LoginButtonText = NewString(USER_AUTH_SERVICE_SAML_TEXT)
}
- if o.ServiceSettings.WebsocketSecurePort == nil {
- o.ServiceSettings.WebsocketSecurePort = new(int)
- *o.ServiceSettings.WebsocketSecurePort = 443
+ if s.FirstNameAttribute == nil {
+ s.FirstNameAttribute = NewString(SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE)
}
- if o.ServiceSettings.AllowCorsFrom == nil {
- o.ServiceSettings.AllowCorsFrom = new(string)
- *o.ServiceSettings.AllowCorsFrom = SERVICE_SETTINGS_DEFAULT_ALLOW_CORS_FROM
+ if s.LastNameAttribute == nil {
+ s.LastNameAttribute = NewString(SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE)
}
- if o.ServiceSettings.WebserverMode == nil {
- o.ServiceSettings.WebserverMode = new(string)
- *o.ServiceSettings.WebserverMode = "gzip"
- } else if *o.ServiceSettings.WebserverMode == "regular" {
- *o.ServiceSettings.WebserverMode = "gzip"
+ if s.EmailAttribute == nil {
+ s.EmailAttribute = NewString(SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE)
}
- if o.ServiceSettings.EnableCustomEmoji == nil {
- o.ServiceSettings.EnableCustomEmoji = new(bool)
- *o.ServiceSettings.EnableCustomEmoji = false
+ if s.UsernameAttribute == nil {
+ s.UsernameAttribute = NewString(SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE)
}
- if o.ServiceSettings.EnableEmojiPicker == nil {
- o.ServiceSettings.EnableEmojiPicker = new(bool)
- *o.ServiceSettings.EnableEmojiPicker = true
+ if s.NicknameAttribute == nil {
+ s.NicknameAttribute = NewString(SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE)
}
- if o.ServiceSettings.RestrictCustomEmojiCreation == nil {
- o.ServiceSettings.RestrictCustomEmojiCreation = new(string)
- *o.ServiceSettings.RestrictCustomEmojiCreation = RESTRICT_EMOJI_CREATION_ALL
+ if s.PositionAttribute == nil {
+ s.PositionAttribute = NewString(SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE)
}
- if o.ServiceSettings.RestrictPostDelete == nil {
- o.ServiceSettings.RestrictPostDelete = new(string)
- *o.ServiceSettings.RestrictPostDelete = PERMISSIONS_DELETE_POST_ALL
+ if s.LocaleAttribute == nil {
+ s.LocaleAttribute = NewString(SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE)
}
- if o.ServiceSettings.AllowEditPost == nil {
- o.ServiceSettings.AllowEditPost = new(string)
- *o.ServiceSettings.AllowEditPost = ALLOW_EDIT_POST_ALWAYS
+ if s.LoginButtonColor == nil {
+ s.LoginButtonColor = NewString("#34a28b")
}
- if o.ServiceSettings.PostEditTimeLimit == nil {
- o.ServiceSettings.PostEditTimeLimit = new(int)
- *o.ServiceSettings.PostEditTimeLimit = 300
+ if s.LoginButtonBorderColor == nil {
+ s.LoginButtonBorderColor = NewString("#2389D7")
}
- if o.ClusterSettings.Enable == nil {
- o.ClusterSettings.Enable = new(bool)
- *o.ClusterSettings.Enable = false
+ if s.LoginButtonTextColor == nil {
+ s.LoginButtonTextColor = NewString("#ffffff")
}
+}
- if o.ClusterSettings.ClusterName == nil {
- o.ClusterSettings.ClusterName = new(string)
- *o.ClusterSettings.ClusterName = ""
- }
+type NativeAppSettings struct {
+ AppDownloadLink *string
+ AndroidAppDownloadLink *string
+ IosAppDownloadLink *string
+}
- if o.ClusterSettings.OverrideHostname == nil {
- o.ClusterSettings.OverrideHostname = new(string)
- *o.ClusterSettings.OverrideHostname = ""
+func (s *NativeAppSettings) SetDefaults() {
+ if s.AppDownloadLink == nil {
+ s.AppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK)
}
- if o.ClusterSettings.UseIpAddress == nil {
- o.ClusterSettings.UseIpAddress = new(bool)
- *o.ClusterSettings.UseIpAddress = true
+ if s.AndroidAppDownloadLink == nil {
+ s.AndroidAppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK)
}
- if o.ClusterSettings.UseExperimentalGossip == nil {
- o.ClusterSettings.UseExperimentalGossip = new(bool)
- *o.ClusterSettings.UseExperimentalGossip = false
+ if s.IosAppDownloadLink == nil {
+ s.IosAppDownloadLink = NewString(NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK)
}
+}
- if o.ClusterSettings.ReadOnlyConfig == nil {
- o.ClusterSettings.ReadOnlyConfig = new(bool)
- *o.ClusterSettings.ReadOnlyConfig = true
- }
+type WebrtcSettings struct {
+ Enable *bool
+ GatewayWebsocketUrl *string
+ GatewayAdminUrl *string
+ GatewayAdminSecret *string
+ StunURI *string
+ TurnURI *string
+ TurnUsername *string
+ TurnSharedKey *string
+}
- if o.ClusterSettings.GossipPort == nil {
- o.ClusterSettings.GossipPort = new(int)
- *o.ClusterSettings.GossipPort = 8074
+func (s *WebrtcSettings) SetDefaults() {
+ if s.Enable == nil {
+ s.Enable = NewBool(false)
}
- if o.ClusterSettings.StreamingPort == nil {
- o.ClusterSettings.StreamingPort = new(int)
- *o.ClusterSettings.StreamingPort = 8075
+ if s.GatewayWebsocketUrl == nil {
+ s.GatewayWebsocketUrl = NewString("")
}
- if o.MetricsSettings.ListenAddress == nil {
- o.MetricsSettings.ListenAddress = new(string)
- *o.MetricsSettings.ListenAddress = ":8067"
+ if s.GatewayAdminUrl == nil {
+ s.GatewayAdminUrl = NewString("")
}
- if o.MetricsSettings.Enable == nil {
- o.MetricsSettings.Enable = new(bool)
- *o.MetricsSettings.Enable = false
+ if s.GatewayAdminSecret == nil {
+ s.GatewayAdminSecret = NewString("")
}
- if o.AnalyticsSettings.MaxUsersForStatistics == nil {
- o.AnalyticsSettings.MaxUsersForStatistics = new(int)
- *o.AnalyticsSettings.MaxUsersForStatistics = ANALYTICS_SETTINGS_DEFAULT_MAX_USERS_FOR_STATISTICS
+ if s.StunURI == nil {
+ s.StunURI = NewString(WEBRTC_SETTINGS_DEFAULT_STUN_URI)
}
- if o.ComplianceSettings.Enable == nil {
- o.ComplianceSettings.Enable = new(bool)
- *o.ComplianceSettings.Enable = false
+ if s.TurnURI == nil {
+ s.TurnURI = NewString(WEBRTC_SETTINGS_DEFAULT_TURN_URI)
}
- if o.ComplianceSettings.Directory == nil {
- o.ComplianceSettings.Directory = new(string)
- *o.ComplianceSettings.Directory = "./data/"
+ if s.TurnUsername == nil {
+ s.TurnUsername = NewString("")
}
- if o.ComplianceSettings.EnableDaily == nil {
- o.ComplianceSettings.EnableDaily = new(bool)
- *o.ComplianceSettings.EnableDaily = false
+ 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
+}
- if o.LocalizationSettings.DefaultServerLocale == nil {
- o.LocalizationSettings.DefaultServerLocale = new(string)
- *o.LocalizationSettings.DefaultServerLocale = DEFAULT_LOCALE
+func (s *ElasticsearchSettings) SetDefaults() {
+ if s.ConnectionUrl == nil {
+ s.ConnectionUrl = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL)
}
- if o.LocalizationSettings.DefaultClientLocale == nil {
- o.LocalizationSettings.DefaultClientLocale = new(string)
- *o.LocalizationSettings.DefaultClientLocale = DEFAULT_LOCALE
+ if s.Username == nil {
+ s.Username = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME)
}
- if o.LocalizationSettings.AvailableLocales == nil {
- o.LocalizationSettings.AvailableLocales = new(string)
- *o.LocalizationSettings.AvailableLocales = ""
+ if s.Password == nil {
+ s.Password = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD)
}
- if o.LogSettings.EnableDiagnostics == nil {
- o.LogSettings.EnableDiagnostics = new(bool)
- *o.LogSettings.EnableDiagnostics = true
+ if s.EnableIndexing == nil {
+ s.EnableIndexing = NewBool(false)
}
- if o.SamlSettings.Enable == nil {
- o.SamlSettings.Enable = new(bool)
- *o.SamlSettings.Enable = false
+ if s.EnableSearching == nil {
+ s.EnableSearching = NewBool(false)
}
- if o.SamlSettings.Verify == nil {
- o.SamlSettings.Verify = new(bool)
- *o.SamlSettings.Verify = true
+ if s.Sniff == nil {
+ s.Sniff = NewBool(true)
}
- if o.SamlSettings.Encrypt == nil {
- o.SamlSettings.Encrypt = new(bool)
- *o.SamlSettings.Encrypt = true
+ if s.PostIndexReplicas == nil {
+ s.PostIndexReplicas = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_REPLICAS)
}
- if o.SamlSettings.IdpUrl == nil {
- o.SamlSettings.IdpUrl = new(string)
- *o.SamlSettings.IdpUrl = ""
+ if s.PostIndexShards == nil {
+ s.PostIndexShards = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_SHARDS)
}
- if o.SamlSettings.IdpDescriptorUrl == nil {
- o.SamlSettings.IdpDescriptorUrl = new(string)
- *o.SamlSettings.IdpDescriptorUrl = ""
+ if s.AggregatePostsAfterDays == nil {
+ s.AggregatePostsAfterDays = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_AGGREGATE_POSTS_AFTER_DAYS)
}
- if o.SamlSettings.IdpCertificateFile == nil {
- o.SamlSettings.IdpCertificateFile = new(string)
- *o.SamlSettings.IdpCertificateFile = ""
+ if s.PostsAggregatorJobStartTime == nil {
+ s.PostsAggregatorJobStartTime = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_POSTS_AGGREGATOR_JOB_START_TIME)
}
- if o.SamlSettings.PublicCertificateFile == nil {
- o.SamlSettings.PublicCertificateFile = new(string)
- *o.SamlSettings.PublicCertificateFile = ""
+ if s.IndexPrefix == nil {
+ s.IndexPrefix = NewString(ELASTICSEARCH_SETTINGS_DEFAULT_INDEX_PREFIX)
}
- if o.SamlSettings.PrivateKeyFile == nil {
- o.SamlSettings.PrivateKeyFile = new(string)
- *o.SamlSettings.PrivateKeyFile = ""
+ if s.LiveIndexingBatchSize == nil {
+ s.LiveIndexingBatchSize = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_LIVE_INDEXING_BATCH_SIZE)
}
- if o.SamlSettings.AssertionConsumerServiceURL == nil {
- o.SamlSettings.AssertionConsumerServiceURL = new(string)
- *o.SamlSettings.AssertionConsumerServiceURL = ""
+ if s.BulkIndexingTimeWindowSeconds == nil {
+ s.BulkIndexingTimeWindowSeconds = NewInt(ELASTICSEARCH_SETTINGS_DEFAULT_BULK_INDEXING_TIME_WINDOW_SECONDS)
}
- if o.SamlSettings.LoginButtonText == nil || *o.SamlSettings.LoginButtonText == "" {
- o.SamlSettings.LoginButtonText = new(string)
- *o.SamlSettings.LoginButtonText = USER_AUTH_SERVICE_SAML_TEXT
+ 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
+}
- if o.SamlSettings.FirstNameAttribute == nil {
- o.SamlSettings.FirstNameAttribute = new(string)
- *o.SamlSettings.FirstNameAttribute = SAML_SETTINGS_DEFAULT_FIRST_NAME_ATTRIBUTE
+func (s *DataRetentionSettings) SetDefaults() {
+ if s.EnableMessageDeletion == nil {
+ s.EnableMessageDeletion = NewBool(false)
}
- if o.SamlSettings.LastNameAttribute == nil {
- o.SamlSettings.LastNameAttribute = new(string)
- *o.SamlSettings.LastNameAttribute = SAML_SETTINGS_DEFAULT_LAST_NAME_ATTRIBUTE
+ if s.EnableFileDeletion == nil {
+ s.EnableFileDeletion = NewBool(false)
}
- if o.SamlSettings.EmailAttribute == nil {
- o.SamlSettings.EmailAttribute = new(string)
- *o.SamlSettings.EmailAttribute = SAML_SETTINGS_DEFAULT_EMAIL_ATTRIBUTE
+ if s.MessageRetentionDays == nil {
+ s.MessageRetentionDays = NewInt(DATA_RETENTION_SETTINGS_DEFAULT_MESSAGE_RETENTION_DAYS)
}
- if o.SamlSettings.UsernameAttribute == nil {
- o.SamlSettings.UsernameAttribute = new(string)
- *o.SamlSettings.UsernameAttribute = SAML_SETTINGS_DEFAULT_USERNAME_ATTRIBUTE
+ if s.FileRetentionDays == nil {
+ s.FileRetentionDays = NewInt(DATA_RETENTION_SETTINGS_DEFAULT_FILE_RETENTION_DAYS)
}
- if o.SamlSettings.NicknameAttribute == nil {
- o.SamlSettings.NicknameAttribute = new(string)
- *o.SamlSettings.NicknameAttribute = SAML_SETTINGS_DEFAULT_NICKNAME_ATTRIBUTE
+ if s.DeletionJobStartTime == nil {
+ s.DeletionJobStartTime = NewString(DATA_RETENTION_SETTINGS_DEFAULT_DELETION_JOB_START_TIME)
}
+}
+
+type JobSettings struct {
+ RunJobs *bool
+ RunScheduler *bool
+}
- if o.SamlSettings.PositionAttribute == nil {
- o.SamlSettings.PositionAttribute = new(string)
- *o.SamlSettings.PositionAttribute = SAML_SETTINGS_DEFAULT_POSITION_ATTRIBUTE
+func (s *JobSettings) SetDefaults() {
+ if s.RunJobs == nil {
+ s.RunJobs = NewBool(true)
}
- if o.SamlSettings.LocaleAttribute == nil {
- o.SamlSettings.LocaleAttribute = new(string)
- *o.SamlSettings.LocaleAttribute = SAML_SETTINGS_DEFAULT_LOCALE_ATTRIBUTE
+ if s.RunScheduler == nil {
+ s.RunScheduler = NewBool(true)
}
+}
- if o.TeamSettings.TeammateNameDisplay == nil {
- o.TeamSettings.TeammateNameDisplay = new(string)
- *o.TeamSettings.TeammateNameDisplay = SHOW_USERNAME
+type PluginState struct {
+ Enable bool
+}
- if *o.SamlSettings.Enable || *o.LdapSettings.Enable {
- *o.TeamSettings.TeammateNameDisplay = SHOW_FULLNAME
- }
+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 o.NativeAppSettings.AppDownloadLink == nil {
- o.NativeAppSettings.AppDownloadLink = new(string)
- *o.NativeAppSettings.AppDownloadLink = NATIVEAPP_SETTINGS_DEFAULT_APP_DOWNLOAD_LINK
+ if s.EnableUploads == nil {
+ s.EnableUploads = NewBool(false)
}
- if o.NativeAppSettings.AndroidAppDownloadLink == nil {
- o.NativeAppSettings.AndroidAppDownloadLink = new(string)
- *o.NativeAppSettings.AndroidAppDownloadLink = NATIVEAPP_SETTINGS_DEFAULT_ANDROID_APP_DOWNLOAD_LINK
+ if s.Directory == nil {
+ s.Directory = NewString(PLUGIN_SETTINGS_DEFAULT_DIRECTORY)
}
- if o.NativeAppSettings.IosAppDownloadLink == nil {
- o.NativeAppSettings.IosAppDownloadLink = new(string)
- *o.NativeAppSettings.IosAppDownloadLink = NATIVEAPP_SETTINGS_DEFAULT_IOS_APP_DOWNLOAD_LINK
+ if *s.Directory == "" {
+ *s.Directory = PLUGIN_SETTINGS_DEFAULT_DIRECTORY
}
- if o.RateLimitSettings.Enable == nil {
- o.RateLimitSettings.Enable = new(bool)
- *o.RateLimitSettings.Enable = false
+ if s.ClientDirectory == nil {
+ s.ClientDirectory = NewString(PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY)
}
- if o.ServiceSettings.GoroutineHealthThreshold == nil {
- o.ServiceSettings.GoroutineHealthThreshold = new(int)
- *o.ServiceSettings.GoroutineHealthThreshold = -1
+ if *s.ClientDirectory == "" {
+ *s.ClientDirectory = PLUGIN_SETTINGS_DEFAULT_CLIENT_DIRECTORY
}
- if o.RateLimitSettings.MaxBurst == nil {
- o.RateLimitSettings.MaxBurst = new(int)
- *o.RateLimitSettings.MaxBurst = 100
+ if s.Plugins == nil {
+ s.Plugins = make(map[string]interface{})
}
- if o.ServiceSettings.ConnectionSecurity == nil {
- o.ServiceSettings.ConnectionSecurity = new(string)
- *o.ServiceSettings.ConnectionSecurity = ""
+ if s.PluginStates == nil {
+ s.PluginStates = make(map[string]*PluginState)
}
+}
+
+type MessageExportSettings struct {
+ EnableExport *bool
+ DailyRunTime *string
+ ExportFromTimestamp *int64
+ BatchSize *int
+}
- if o.ServiceSettings.TLSKeyFile == nil {
- o.ServiceSettings.TLSKeyFile = new(string)
- *o.ServiceSettings.TLSKeyFile = SERVICE_SETTINGS_DEFAULT_TLS_KEY_FILE
+func (s *MessageExportSettings) SetDefaults() {
+ if s.EnableExport == nil {
+ s.EnableExport = NewBool(false)
}
- if o.ServiceSettings.TLSCertFile == nil {
- o.ServiceSettings.TLSCertFile = new(string)
- *o.ServiceSettings.TLSCertFile = SERVICE_SETTINGS_DEFAULT_TLS_CERT_FILE
+ if s.DailyRunTime == nil {
+ s.DailyRunTime = NewString("01:00")
}
- if o.ServiceSettings.UseLetsEncrypt == nil {
- o.ServiceSettings.UseLetsEncrypt = new(bool)
- *o.ServiceSettings.UseLetsEncrypt = false
+ if s.ExportFromTimestamp == nil {
+ s.ExportFromTimestamp = NewInt64(0)
}
- if o.ServiceSettings.LetsEncryptCertificateCacheFile == nil {
- o.ServiceSettings.LetsEncryptCertificateCacheFile = new(string)
- *o.ServiceSettings.LetsEncryptCertificateCacheFile = "./config/letsencrypt.cache"
+ 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 o.ServiceSettings.ReadTimeout == nil {
- o.ServiceSettings.ReadTimeout = new(int)
- *o.ServiceSettings.ReadTimeout = SERVICE_SETTINGS_DEFAULT_READ_TIMEOUT
+ 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
+}
- if o.ServiceSettings.WriteTimeout == nil {
- o.ServiceSettings.WriteTimeout = new(int)
- *o.ServiceSettings.WriteTimeout = SERVICE_SETTINGS_DEFAULT_WRITE_TIMEOUT
+func (o *Config) Clone() *Config {
+ var ret Config
+ if err := json.Unmarshal([]byte(o.ToJson()), &ret); err != nil {
+ panic(err)
}
+ return &ret
+}
- if o.ServiceSettings.Forward80To443 == nil {
- o.ServiceSettings.Forward80To443 = new(bool)
- *o.ServiceSettings.Forward80To443 = false
+func (o *Config) ToJson() string {
+ b, err := json.Marshal(o)
+ if err != nil {
+ return ""
+ } else {
+ return string(b)
}
+}
- if o.MetricsSettings.BlockProfileRate == nil {
- o.MetricsSettings.BlockProfileRate = new(int)
- *o.MetricsSettings.BlockProfileRate = 0
+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
}
- if o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds == nil {
- o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds = new(int64)
- *o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds = 5000
+ 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.ServiceSettings.EnablePostSearch == nil {
- o.ServiceSettings.EnablePostSearch = new(bool)
- *o.ServiceSettings.EnablePostSearch = true
+ if o.TeamSettings.TeammateNameDisplay == nil {
+ o.TeamSettings.TeammateNameDisplay = NewString(SHOW_USERNAME)
+
+ if *o.SamlSettings.Enable || *o.LdapSettings.Enable {
+ *o.TeamSettings.TeammateNameDisplay = SHOW_FULLNAME
+ }
}
- if o.ServiceSettings.EnableUserTypingMessages == nil {
- o.ServiceSettings.EnableUserTypingMessages = new(bool)
- *o.ServiceSettings.EnableUserTypingMessages = true
+ 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.ServiceSettings.EnableChannelViewedMessages == nil {
- o.ServiceSettings.EnableChannelViewedMessages = new(bool)
- *o.ServiceSettings.EnableChannelViewedMessages = true
+ if *o.ClusterSettings.Enable && *o.EmailSettings.EnableEmailBatching {
+ return NewAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "", http.StatusBadRequest)
}
- if o.ServiceSettings.EnableUserStatuses == nil {
- o.ServiceSettings.EnableUserStatuses = new(bool)
- *o.ServiceSettings.EnableUserStatuses = true
+ if err := o.TeamSettings.isValid(); err != nil {
+ return err
}
- if o.ServiceSettings.ClusterLogTimeoutMilliseconds == nil {
- o.ServiceSettings.ClusterLogTimeoutMilliseconds = new(int)
- *o.ServiceSettings.ClusterLogTimeoutMilliseconds = 2000
+ if err := o.SqlSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.ConnectionUrl == nil {
- o.ElasticsearchSettings.ConnectionUrl = new(string)
- *o.ElasticsearchSettings.ConnectionUrl = ELASTICSEARCH_SETTINGS_DEFAULT_CONNECTION_URL
+ if err := o.FileSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.Username == nil {
- o.ElasticsearchSettings.Username = new(string)
- *o.ElasticsearchSettings.Username = ELASTICSEARCH_SETTINGS_DEFAULT_USERNAME
+ if err := o.EmailSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.Password == nil {
- o.ElasticsearchSettings.Password = new(string)
- *o.ElasticsearchSettings.Password = ELASTICSEARCH_SETTINGS_DEFAULT_PASSWORD
+ if err := o.LdapSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.EnableIndexing == nil {
- o.ElasticsearchSettings.EnableIndexing = new(bool)
- *o.ElasticsearchSettings.EnableIndexing = false
+ if err := o.SamlSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.EnableSearching == nil {
- o.ElasticsearchSettings.EnableSearching = new(bool)
- *o.ElasticsearchSettings.EnableSearching = false
+ 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 o.ElasticsearchSettings.Sniff == nil {
- o.ElasticsearchSettings.Sniff = new(bool)
- *o.ElasticsearchSettings.Sniff = true
+ if err := o.RateLimitSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.PostIndexReplicas == nil {
- o.ElasticsearchSettings.PostIndexReplicas = new(int)
- *o.ElasticsearchSettings.PostIndexReplicas = ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_REPLICAS
+ if err := o.WebrtcSettings.isValid(); err != nil {
+ return err
}
- if o.ElasticsearchSettings.PostIndexShards == nil {
- o.ElasticsearchSettings.PostIndexShards = new(int)
- *o.ElasticsearchSettings.PostIndexShards = ELASTICSEARCH_SETTINGS_DEFAULT_POST_INDEX_SHARDS
+ if err := o.ServiceSettings.isValid(); err != nil {
+ return err
}
- if o.DataRetentionSettings.Enable == nil {
- o.DataRetentionSettings.Enable = new(bool)
- *o.DataRetentionSettings.Enable = false
+ if err := o.ElasticsearchSettings.isValid(); err != nil {
+ return err
}
- if o.JobSettings.RunJobs == nil {
- o.JobSettings.RunJobs = new(bool)
- *o.JobSettings.RunJobs = true
+ if err := o.DataRetentionSettings.isValid(); err != nil {
+ return err
}
- if o.JobSettings.RunScheduler == nil {
- o.JobSettings.RunScheduler = new(bool)
- *o.JobSettings.RunScheduler = true
+ if err := o.LocalizationSettings.isValid(); err != nil {
+ return err
}
- if o.PluginSettings.Plugins == nil {
- o.PluginSettings.Plugins = make(map[string]interface{})
+ if err := o.MessageExportSettings.isValid(o.FileSettings); err != nil {
+ return err
}
- o.defaultWebrtcSettings()
+ return nil
}
-func (o *Config) IsValid() *AppError {
-
- if o.ServiceSettings.MaximumLoginAttempts <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", 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 len(*o.ServiceSettings.SiteURL) != 0 {
- if _, err := url.ParseRequestURI(*o.ServiceSettings.SiteURL); err != nil {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.site_url.app_error", nil, "")
- }
+ if *ts.MaxChannelsPerTeam <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "", http.StatusBadRequest)
}
- if len(o.ServiceSettings.ListenAddress) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "")
+ if *ts.MaxNotificationsPerChannel <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", nil, "", http.StatusBadRequest)
}
- if *o.ClusterSettings.Enable && *o.EmailSettings.EnableEmailBatching {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.cluster_email_batching.app_error", nil, "")
+ 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 len(*o.ServiceSettings.SiteURL) == 0 && *o.EmailSettings.EnableEmailBatching {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.site_url_email_batching.app_error", nil, "")
+ 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 o.TeamSettings.MaxUsersPerTeam <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.max_users.app_error", nil, "")
+ 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)
}
- if *o.TeamSettings.MaxChannelsPerTeam <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.max_channels.app_error", nil, "")
- }
+ return nil
+}
- if *o.TeamSettings.MaxNotificationsPerChannel <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.max_notify_per_channel.app_error", 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 !(*o.TeamSettings.RestrictDirectMessage == DIRECT_MESSAGE_ANY || *o.TeamSettings.RestrictDirectMessage == DIRECT_MESSAGE_TEAM) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.restrict_direct_message.app_error", nil, "")
+ 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 !(*o.TeamSettings.TeammateNameDisplay == SHOW_FULLNAME || *o.TeamSettings.TeammateNameDisplay == SHOW_NICKNAME_FULLNAME || *o.TeamSettings.TeammateNameDisplay == SHOW_USERNAME) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.teammate_name_display.app_error", nil, "")
+ if *ss.MaxIdleConns <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.sql_idle.app_error", nil, "", http.StatusBadRequest)
}
- if len(o.SqlSettings.AtRestEncryptKey) < 32 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.encrypt_sql.app_error", nil, "")
+ if *ss.QueryTimeout <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest)
}
- if !(o.SqlSettings.DriverName == DATABASE_DRIVER_MYSQL || o.SqlSettings.DriverName == DATABASE_DRIVER_POSTGRES) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_driver.app_error", nil, "")
+ if len(*ss.DataSource) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", nil, "", http.StatusBadRequest)
}
- if o.SqlSettings.MaxIdleConns <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_idle.app_error", nil, "")
+ if *ss.MaxOpenConns <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "", http.StatusBadRequest)
}
- if *o.SqlSettings.QueryTimeout <= 0 {
- return NewAppError("Config.IsValid", "model.config.is_valid.sql_query_timeout.app_error", nil, "", http.StatusBadRequest)
- }
+ return nil
+}
- if len(o.SqlSettings.DataSource) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_data_src.app_error", 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 o.SqlSettings.MaxOpenConns <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.sql_max_conn.app_error", nil, "")
+ 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 *o.FileSettings.MaxFileSize <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.max_file_size.app_error", nil, "")
+ if len(*fs.PublicLinkSalt) < 32 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", nil, "", http.StatusBadRequest)
}
- if !(o.FileSettings.DriverName == IMAGE_DRIVER_LOCAL || o.FileSettings.DriverName == IMAGE_DRIVER_S3) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.file_driver.app_error", nil, "")
- }
+ return nil
+}
- if len(*o.FileSettings.PublicLinkSalt) < 32 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.file_salt.app_error", 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 !(o.EmailSettings.ConnectionSecurity == CONN_SECURITY_NONE || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_TLS || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_STARTTLS || o.EmailSettings.ConnectionSecurity == CONN_SECURITY_PLAIN) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.email_security.app_error", nil, "")
+ if len(es.InviteSalt) < 32 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.email_salt.app_error", nil, "", http.StatusBadRequest)
}
- if len(o.EmailSettings.InviteSalt) < 32 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.email_salt.app_error", nil, "")
+ if *es.EmailBatchingBufferSize <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_buffer_size.app_error", nil, "", http.StatusBadRequest)
}
- if *o.EmailSettings.EmailBatchingBufferSize <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.email_batching_buffer_size.app_error", nil, "")
+ if *es.EmailBatchingInterval < 30 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "", http.StatusBadRequest)
}
- if *o.EmailSettings.EmailBatchingInterval < 30 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.email_batching_interval.app_error", nil, "")
+ 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)
}
- if !(*o.EmailSettings.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_FULL || *o.EmailSettings.EmailNotificationContentsType == EMAIL_NOTIFICATION_CONTENTS_GENERIC) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.email_notification_contents_type.app_error", nil, "")
+ 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 o.RateLimitSettings.MemoryStoreSize <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.rate_mem.app_error", nil, "")
+ if *rls.PerSec <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.rate_sec.app_error", nil, "", http.StatusBadRequest)
}
- if o.RateLimitSettings.PerSec <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.rate_sec.app_error", nil, "")
+ if *rls.MaxBurst <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.max_burst.app_error", nil, "", http.StatusBadRequest)
}
- if !(*o.LdapSettings.ConnectionSecurity == CONN_SECURITY_NONE || *o.LdapSettings.ConnectionSecurity == CONN_SECURITY_TLS || *o.LdapSettings.ConnectionSecurity == CONN_SECURITY_STARTTLS) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_security.app_error", nil, "")
+ 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 *o.LdapSettings.SyncIntervalMinutes <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "")
+ if *ls.SyncIntervalMinutes <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_sync_interval.app_error", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.MaxPageSize < 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "")
+ if *ls.MaxPageSize < 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_max_page_size.app_error", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.Enable {
- if *o.LdapSettings.LdapServer == "" {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_server", nil, "")
+ if *ls.Enable {
+ if *ls.LdapServer == "" {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_server", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.BaseDN == "" {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "")
+ if *ls.BaseDN == "" {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_basedn", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.EmailAttribute == "" {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "")
+ if *ls.EmailAttribute == "" {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_email", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.UsernameAttribute == "" {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_username", nil, "")
+ if *ls.UsernameAttribute == "" {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_username", nil, "", http.StatusBadRequest)
}
- if *o.LdapSettings.IdAttribute == "" {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.ldap_id", nil, "")
+ if *ls.IdAttribute == "" {
+ return NewAppError("Config.IsValid", "model.config.is_valid.ldap_id", nil, "", http.StatusBadRequest)
}
}
- if *o.SamlSettings.Enable {
- if len(*o.SamlSettings.IdpUrl) == 0 || !IsValidHttpUrl(*o.SamlSettings.IdpUrl) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_url.app_error", nil, "")
+ 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(*o.SamlSettings.IdpDescriptorUrl) == 0 || !IsValidHttpUrl(*o.SamlSettings.IdpDescriptorUrl) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_descriptor_url.app_error", nil, "")
+ 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(*o.SamlSettings.IdpCertificateFile) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "")
+ if len(*ss.IdpCertificateFile) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.saml_idp_cert.app_error", nil, "", http.StatusBadRequest)
}
- if len(*o.SamlSettings.EmailAttribute) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
+ if len(*ss.EmailAttribute) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
}
- if len(*o.SamlSettings.UsernameAttribute) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "")
+ if len(*ss.UsernameAttribute) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.saml_username_attribute.app_error", nil, "", http.StatusBadRequest)
}
- if *o.SamlSettings.Verify {
- if len(*o.SamlSettings.AssertionConsumerServiceURL) == 0 || !IsValidHttpUrl(*o.SamlSettings.AssertionConsumerServiceURL) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_assertion_consumer_service_url.app_error", nil, "")
+ 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 *o.SamlSettings.Encrypt {
- if len(*o.SamlSettings.PrivateKeyFile) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_private_key.app_error", nil, "")
+ 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(*o.SamlSettings.PublicCertificateFile) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "")
+ if len(*ss.PublicCertificateFile) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.saml_public_cert.app_error", nil, "", http.StatusBadRequest)
}
}
- if len(*o.SamlSettings.EmailAttribute) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "")
+ if len(*ss.EmailAttribute) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.saml_email_attribute.app_error", nil, "", http.StatusBadRequest)
}
}
- if *o.PasswordSettings.MinimumLength < PASSWORD_MINIMUM_LENGTH || *o.PasswordSettings.MinimumLength > PASSWORD_MAXIMUM_LENGTH {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.password_length.app_error", map[string]interface{}{"MinLength": PASSWORD_MINIMUM_LENGTH, "MaxLength": PASSWORD_MAXIMUM_LENGTH}, "")
+ 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)
+ }
+ }
}
- if len(o.TeamSettings.SiteName) > SITENAME_MAX_LENGTH {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.sitename_length.app_error", map[string]interface{}{"MaxLength": SITENAME_MAX_LENGTH}, "")
+ 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 *o.RateLimitSettings.MaxBurst <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.max_burst.app_error", nil, "")
+ if *ss.ReadTimeout <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "", http.StatusBadRequest)
}
- if err := o.isValidWebrtcSettings(); err != nil {
- return err
+ if *ss.WriteTimeout <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.write_timeout.app_error", nil, "", http.StatusBadRequest)
}
- if !(*o.ServiceSettings.ConnectionSecurity == CONN_SECURITY_NONE || *o.ServiceSettings.ConnectionSecurity == CONN_SECURITY_TLS) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webserver_security.app_error", nil, "")
+ if *ss.TimeBetweenUserTypingUpdatesMilliseconds < 1000 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.time_between_user_typing.app_error", nil, "", http.StatusBadRequest)
}
- if *o.ServiceSettings.ReadTimeout <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.read_timeout.app_error", nil, "")
+ if *ss.MaximumLoginAttempts <= 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.login_attempts.app_error", nil, "", http.StatusBadRequest)
}
- if *o.ServiceSettings.WriteTimeout <= 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.write_timeout.app_error", nil, "")
+ 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 *o.ServiceSettings.TimeBetweenUserTypingUpdatesMilliseconds < 1000 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.time_between_user_typing.app_error", nil, "")
+ if len(*ss.ListenAddress) == 0 {
+ return NewAppError("Config.IsValid", "model.config.is_valid.listen_address.app_error", nil, "", http.StatusBadRequest)
}
- if *o.ElasticsearchSettings.EnableIndexing {
- if len(*o.ElasticsearchSettings.ConnectionUrl) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.elastic_search.connection_url.app_error", nil, "")
+ 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 *o.ElasticsearchSettings.EnableSearching && !*o.ElasticsearchSettings.EnableIndexing {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.elastic_search.enable_searching.app_error", nil, "")
+ 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
}
@@ -1725,7 +2153,7 @@ func (o *Config) Sanitize() {
o.GitLabSettings.Secret = FAKE_SETTING
}
- o.SqlSettings.DataSource = FAKE_SETTING
+ *o.SqlSettings.DataSource = FAKE_SETTING
o.SqlSettings.AtRestEncryptKey = FAKE_SETTING
for i := range o.SqlSettings.DataSourceReplicas {
@@ -1738,71 +2166,3 @@ func (o *Config) Sanitize() {
*o.ElasticsearchSettings.Password = FAKE_SETTING
}
-
-func (o *Config) defaultWebrtcSettings() {
- if o.WebrtcSettings.Enable == nil {
- o.WebrtcSettings.Enable = new(bool)
- *o.WebrtcSettings.Enable = false
- }
-
- if o.WebrtcSettings.GatewayWebsocketUrl == nil {
- o.WebrtcSettings.GatewayWebsocketUrl = new(string)
- *o.WebrtcSettings.GatewayWebsocketUrl = ""
- }
-
- if o.WebrtcSettings.GatewayAdminUrl == nil {
- o.WebrtcSettings.GatewayAdminUrl = new(string)
- *o.WebrtcSettings.GatewayAdminUrl = ""
- }
-
- if o.WebrtcSettings.GatewayAdminSecret == nil {
- o.WebrtcSettings.GatewayAdminSecret = new(string)
- *o.WebrtcSettings.GatewayAdminSecret = ""
- }
-
- if o.WebrtcSettings.StunURI == nil {
- o.WebrtcSettings.StunURI = new(string)
- *o.WebrtcSettings.StunURI = WEBRTC_SETTINGS_DEFAULT_STUN_URI
- }
-
- if o.WebrtcSettings.TurnURI == nil {
- o.WebrtcSettings.TurnURI = new(string)
- *o.WebrtcSettings.TurnURI = WEBRTC_SETTINGS_DEFAULT_TURN_URI
- }
-
- if o.WebrtcSettings.TurnUsername == nil {
- o.WebrtcSettings.TurnUsername = new(string)
- *o.WebrtcSettings.TurnUsername = ""
- }
-
- if o.WebrtcSettings.TurnSharedKey == nil {
- o.WebrtcSettings.TurnSharedKey = new(string)
- *o.WebrtcSettings.TurnSharedKey = ""
- }
-}
-
-func (o *Config) isValidWebrtcSettings() *AppError {
- if *o.WebrtcSettings.Enable {
- if len(*o.WebrtcSettings.GatewayWebsocketUrl) == 0 || !IsValidWebsocketUrl(*o.WebrtcSettings.GatewayWebsocketUrl) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_ws_url.app_error", nil, "")
- } else if len(*o.WebrtcSettings.GatewayAdminUrl) == 0 || !IsValidHttpUrl(*o.WebrtcSettings.GatewayAdminUrl) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_url.app_error", nil, "")
- } else if len(*o.WebrtcSettings.GatewayAdminSecret) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_gateway_admin_secret.app_error", nil, "")
- } else if len(*o.WebrtcSettings.StunURI) != 0 && !IsValidTurnOrStunServer(*o.WebrtcSettings.StunURI) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_stun_uri.app_error", nil, "")
- } else if len(*o.WebrtcSettings.TurnURI) != 0 {
- if !IsValidTurnOrStunServer(*o.WebrtcSettings.TurnURI) {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_uri.app_error", nil, "")
- }
- if len(*o.WebrtcSettings.TurnUsername) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_username.app_error", nil, "")
- } else if len(*o.WebrtcSettings.TurnSharedKey) == 0 {
- return NewLocAppError("Config.IsValid", "model.config.is_valid.webrtc_turn_shared_key.app_error", nil, "")
- }
-
- }
- }
-
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/model/data_retention_policy.go b/vendor/github.com/mattermost/platform/model/data_retention_policy.go
new file mode 100644
index 00000000..7284477e
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/data_retention_policy.go
@@ -0,0 +1,36 @@
+// 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
index 5ade868c..272616d9 100644
--- a/vendor/github.com/mattermost/platform/model/emoji.go
+++ b/vendor/github.com/mattermost/platform/model/emoji.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
)
type Emoji struct {
@@ -19,23 +20,23 @@ type Emoji struct {
func (emoji *Emoji) IsValid() *AppError {
if len(emoji.Id) != 26 {
- return NewLocAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "")
+ return NewAppError("Emoji.IsValid", "model.emoji.id.app_error", nil, "", http.StatusBadRequest)
}
if emoji.CreateAt == 0 {
- return NewLocAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id)
+ return NewAppError("Emoji.IsValid", "model.emoji.create_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest)
}
if emoji.UpdateAt == 0 {
- return NewLocAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id)
+ return NewAppError("Emoji.IsValid", "model.emoji.update_at.app_error", nil, "id="+emoji.Id, http.StatusBadRequest)
}
if len(emoji.CreatorId) != 26 {
- return NewLocAppError("Emoji.IsValid", "model.emoji.user_id.app_error", nil, "")
+ 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 NewLocAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "")
+ return NewAppError("Emoji.IsValid", "model.emoji.name.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/file_info.go b/vendor/github.com/mattermost/platform/model/file_info.go
index 8b568412..0ee2c50d 100644
--- a/vendor/github.com/mattermost/platform/model/file_info.go
+++ b/vendor/github.com/mattermost/platform/model/file_info.go
@@ -10,6 +10,7 @@ import (
"image/gif"
"io"
"mime"
+ "net/http"
"path/filepath"
"strings"
)
@@ -80,33 +81,36 @@ func (o *FileInfo) PreSave() {
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 NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "")
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.CreatorId) != 26 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.UpdateAt == 0 {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.Path == "" {
- return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id)
+ return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
return nil
@@ -144,7 +148,7 @@ func GetInfoForBytes(name string, data []byte) (*FileInfo, *AppError) {
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 = NewLocAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name)
+ err = NewAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name, http.StatusBadRequest)
} else {
info.HasPreviewImage = len(gifConfig.Image) == 1
}
diff --git a/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go b/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
index 7f1447ed..7e0cb10a 100644
--- a/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
+++ b/vendor/github.com/mattermost/platform/model/gitlab/gitlab.go
@@ -5,11 +5,12 @@ package oauthgitlab
import (
"encoding/json"
- "github.com/mattermost/platform/einterfaces"
- "github.com/mattermost/platform/model"
"io"
"strconv"
"strings"
+
+ "github.com/mattermost/mattermost-server/einterfaces"
+ "github.com/mattermost/mattermost-server/model"
)
type GitLabProvider struct {
@@ -45,7 +46,6 @@ func userFromGitLabUser(glu *GitLabUser) *model.User {
} else {
user.FirstName = glu.Name
}
- strings.TrimSpace(user.Email)
user.Email = glu.Email
userId := strconv.FormatInt(glu.Id, 10)
user.AuthData = &userId
diff --git a/vendor/github.com/mattermost/platform/model/incoming_webhook.go b/vendor/github.com/mattermost/platform/model/incoming_webhook.go
index ce755f88..3e0488d2 100644
--- a/vendor/github.com/mattermost/platform/model/incoming_webhook.go
+++ b/vendor/github.com/mattermost/platform/model/incoming_webhook.go
@@ -25,6 +25,8 @@ type IncomingWebhook struct {
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 {
@@ -112,6 +114,14 @@ func (o *IncomingWebhook) IsValid() *AppError {
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
}
@@ -193,7 +203,7 @@ func decodeIncomingWebhookRequest(by []byte) (*IncomingWebhookRequest, error) {
}
}
-func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest {
+func IncomingWebhookRequestFromJson(data io.Reader) (*IncomingWebhookRequest, *AppError) {
buf := new(bytes.Buffer)
buf.ReadFrom(data)
by := buf.Bytes()
@@ -204,12 +214,11 @@ func IncomingWebhookRequestFromJson(data io.Reader) *IncomingWebhookRequest {
if err != nil {
o, err = decodeIncomingWebhookRequest(escapeControlCharsFromPayload(by))
if err != nil {
- return nil
+ return nil, NewAppError("IncomingWebhookRequestFromJson", "Unable to parse incoming data", nil, err.Error(), http.StatusBadRequest)
}
}
- o.Text = ExpandAnnouncement(o.Text)
- o.Attachments = ProcessSlackAttachments(o.Attachments)
+ o.Attachments = StringifySlackFieldValue(o.Attachments)
- return o
+ return o, nil
}
diff --git a/vendor/github.com/mattermost/platform/model/job.go b/vendor/github.com/mattermost/platform/model/job.go
index 004331a1..9a756602 100644
--- a/vendor/github.com/mattermost/platform/model/job.go
+++ b/vendor/github.com/mattermost/platform/model/job.go
@@ -7,11 +7,15 @@ import (
"encoding/json"
"io"
"net/http"
+ "time"
)
const (
- JOB_TYPE_DATA_RETENTION = "data_retention"
- JOB_TYPE_ELASTICSEARCH_POST_INDEXING = "elasticsearch_post_indexing"
+ 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"
@@ -22,15 +26,15 @@ const (
)
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]interface{} `json:"data"`
+ 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 {
@@ -45,6 +49,9 @@ func (j *Job) IsValid() *AppError {
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)
}
@@ -112,6 +119,9 @@ type Worker interface {
}
type Scheduler interface {
- Run()
- Stop()
+ 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/license.go b/vendor/github.com/mattermost/platform/model/license.go
index ea108972..a81f882c 100644
--- a/vendor/github.com/mattermost/platform/model/license.go
+++ b/vendor/github.com/mattermost/platform/model/license.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
)
const (
@@ -51,7 +52,10 @@ type Features struct {
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"`
@@ -72,106 +76,96 @@ func (f *Features) ToMap() map[string]interface{} {
"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 = new(bool)
- *f.FutureFeatures = true
+ f.FutureFeatures = NewBool(true)
}
if f.Users == nil {
- f.Users = new(int)
- *f.Users = 0
+ f.Users = NewInt(0)
}
if f.LDAP == nil {
- f.LDAP = new(bool)
- *f.LDAP = *f.FutureFeatures
+ f.LDAP = NewBool(*f.FutureFeatures)
}
if f.MFA == nil {
- f.MFA = new(bool)
- *f.MFA = *f.FutureFeatures
+ f.MFA = NewBool(*f.FutureFeatures)
}
if f.GoogleOAuth == nil {
- f.GoogleOAuth = new(bool)
- *f.GoogleOAuth = *f.FutureFeatures
+ f.GoogleOAuth = NewBool(*f.FutureFeatures)
}
if f.Office365OAuth == nil {
- f.Office365OAuth = new(bool)
- *f.Office365OAuth = *f.FutureFeatures
+ f.Office365OAuth = NewBool(*f.FutureFeatures)
}
if f.Compliance == nil {
- f.Compliance = new(bool)
- *f.Compliance = *f.FutureFeatures
+ f.Compliance = NewBool(*f.FutureFeatures)
}
if f.Cluster == nil {
- f.Cluster = new(bool)
- *f.Cluster = *f.FutureFeatures
+ f.Cluster = NewBool(*f.FutureFeatures)
}
if f.Metrics == nil {
- f.Metrics = new(bool)
- *f.Metrics = *f.FutureFeatures
+ f.Metrics = NewBool(*f.FutureFeatures)
}
if f.CustomBrand == nil {
- f.CustomBrand = new(bool)
- *f.CustomBrand = *f.FutureFeatures
+ f.CustomBrand = NewBool(*f.FutureFeatures)
}
if f.MHPNS == nil {
- f.MHPNS = new(bool)
- *f.MHPNS = *f.FutureFeatures
+ f.MHPNS = NewBool(*f.FutureFeatures)
}
if f.SAML == nil {
- f.SAML = new(bool)
- *f.SAML = *f.FutureFeatures
+ f.SAML = NewBool(*f.FutureFeatures)
}
if f.PasswordRequirements == nil {
- f.PasswordRequirements = new(bool)
- *f.PasswordRequirements = *f.FutureFeatures
+ f.PasswordRequirements = NewBool(*f.FutureFeatures)
}
if f.Elasticsearch == nil {
- f.Elasticsearch = new(bool)
- *f.Elasticsearch = *f.FutureFeatures
+ f.Elasticsearch = NewBool(*f.FutureFeatures)
}
if f.Announcement == nil {
- f.Announcement = new(bool)
- *f.Announcement = true
+ f.Announcement = NewBool(true)
+ }
+
+ if f.ThemeManagement == nil {
+ f.ThemeManagement = NewBool(true)
}
if f.EmailNotificationContents == nil {
- f.EmailNotificationContents = new(bool)
- *f.EmailNotificationContents = *f.FutureFeatures
+ 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 {
- now := GetMillis()
- if l.ExpiresAt < now {
- return true
- }
- return false
+ return l.ExpiresAt < GetMillis()
}
func (l *License) IsStarted() bool {
- now := GetMillis()
- if l.StartsAt < now {
- return true
- }
- return false
+ return l.StartsAt < GetMillis()
}
func (l *License) ToJson() string {
@@ -196,15 +190,15 @@ func LicenseFromJson(data io.Reader) *License {
func (lr *LicenseRecord) IsValid() *AppError {
if len(lr.Id) != 26 {
- return NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.id.app_error", nil, "")
+ return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if lr.CreateAt == 0 {
- return NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "")
+ 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 NewLocAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "")
+ return NewAppError("LicenseRecord.IsValid", "model.license_record.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/manifest.go b/vendor/github.com/mattermost/platform/model/manifest.go
new file mode 100644
index 00000000..03d78f84
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/manifest.go
@@ -0,0 +1,246 @@
+// 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
new file mode 100644
index 00000000..b59b114d
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/message_export.go
@@ -0,0 +1,18 @@
+// 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/outgoing_webhook.go b/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
index 59408c24..477a277d 100644
--- a/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
+++ b/vendor/github.com/mattermost/platform/model/outgoing_webhook.go
@@ -45,6 +45,17 @@ type OutgoingWebhookPayload struct {
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 {
@@ -112,6 +123,26 @@ func OutgoingWebhookListFromJson(data io.Reader) []*OutgoingWebhook {
}
}
+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 {
diff --git a/vendor/github.com/mattermost/platform/model/plugin_key_value.go b/vendor/github.com/mattermost/platform/model/plugin_key_value.go
new file mode 100644
index 00000000..b7a7731c
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/plugin_key_value.go
@@ -0,0 +1,32 @@
+// 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
new file mode 100644
index 00000000..74c89af2
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/model/plugins_response.go
@@ -0,0 +1,39 @@
+// 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
index 55e6f591..6b282fbf 100644
--- a/vendor/github.com/mattermost/platform/model/post.go
+++ b/vendor/github.com/mattermost/platform/model/post.go
@@ -6,6 +6,9 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
+ "regexp"
+ "strings"
"unicode/utf8"
)
@@ -17,9 +20,13 @@ const (
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"
@@ -30,6 +37,9 @@ const (
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 {
@@ -68,8 +78,31 @@ type PostForIndexing struct {
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 {
- b, err := json.Marshal(o)
+ copy := *o
+ copy.StripActionIntegrations()
+ b, err := json.Marshal(&copy)
if err != nil {
return ""
} else {
@@ -95,73 +128,100 @@ func (o *Post) Etag() string {
func (o *Post) IsValid() *AppError {
if len(o.Id) != 26 {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "")
+ return NewAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "", http.StatusBadRequest)
}
if o.CreateAt == 0 {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.create_at.app_error", nil, "id="+o.Id)
+ return NewAppError("Post.IsValid", "model.post.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if o.UpdateAt == 0 {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.update_at.app_error", nil, "id="+o.Id)
+ return NewAppError("Post.IsValid", "model.post.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
if len(o.UserId) != 26 {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.user_id.app_error", nil, "")
+ return NewAppError("Post.IsValid", "model.post.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.ChannelId) != 26 {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.channel_id.app_error", nil, "")
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "")
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "")
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "")
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "")
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.msg.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.hashtags.app_error", nil, "id="+o.Id)
+ return NewAppError("Post.IsValid", "model.post.is_valid.hashtags.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}
- // should be removed once more message types are supported
- if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_ADD_REMOVE ||
- o.Type == POST_JOIN_CHANNEL || o.Type == POST_LEAVE_CHANNEL ||
- o.Type == POST_REMOVE_FROM_CHANNEL || o.Type == POST_ADD_TO_CHANNEL ||
- o.Type == POST_SLACK_ATTACHMENT || o.Type == POST_HEADER_CHANGE || o.Type == POST_PURPOSE_CHANGE ||
- o.Type == POST_DISPLAYNAME_CHANGE || o.Type == POST_CHANNEL_DELETED) {
- return NewLocAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type)
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.filenames.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.file_ids.app_error", nil, "id="+o.Id)
+ 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 NewLocAppError("Post.IsValid", "model.post.is_valid.props.app_error", nil, "id="+o.Id)
+ 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()
@@ -174,7 +234,10 @@ func (o *Post) PreSave() {
}
o.UpdateAt = o.CreateAt
+ o.PreCommit()
+}
+func (o *Post) PreCommit() {
if o.Props == nil {
o.Props = make(map[string]interface{})
}
@@ -186,6 +249,8 @@ func (o *Post) PreSave() {
if o.FileIds == nil {
o.FileIds = []string{}
}
+
+ o.GenerateActionIds()
}
func (o *Post) MakeNonNil() {
@@ -246,3 +311,84 @@ func PostPatchFromJson(data io.Reader) *PostPatch {
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
index 63f6d682..018f7d14 100644
--- a/vendor/github.com/mattermost/platform/model/post_list.go
+++ b/vendor/github.com/mattermost/platform/model/post_list.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "sort"
)
type PostList struct {
@@ -20,8 +21,20 @@ func NewPostList() *PostList {
}
}
+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 {
- b, err := json.Marshal(o)
+ copy := *o
+ copy.StripActionIntegrations()
+ b, err := json.Marshal(&copy)
if err != nil {
return ""
} else {
@@ -70,6 +83,12 @@ func (o *PostList) Extend(other *PostList) {
}
}
+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"
diff --git a/vendor/github.com/mattermost/platform/model/preference.go b/vendor/github.com/mattermost/platform/model/preference.go
index 6bbe7326..5d462de8 100644
--- a/vendor/github.com/mattermost/platform/model/preference.go
+++ b/vendor/github.com/mattermost/platform/model/preference.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"regexp"
"strings"
"unicode/utf8"
@@ -67,25 +68,25 @@ func PreferenceFromJson(data io.Reader) *Preference {
func (o *Preference) IsValid() *AppError {
if len(o.UserId) != 26 {
- return NewLocAppError("Preference.IsValid", "model.preference.is_valid.id.app_error", nil, "user_id="+o.UserId)
+ 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 NewLocAppError("Preference.IsValid", "model.preference.is_valid.category.app_error", nil, "category="+o.Category)
+ return NewAppError("Preference.IsValid", "model.preference.is_valid.category.app_error", nil, "category="+o.Category, http.StatusBadRequest)
}
if len(o.Name) > 32 {
- return NewLocAppError("Preference.IsValid", "model.preference.is_valid.name.app_error", nil, "name="+o.Name)
+ return NewAppError("Preference.IsValid", "model.preference.is_valid.name.app_error", nil, "name="+o.Name, http.StatusBadRequest)
}
if utf8.RuneCountInString(o.Value) > 2000 {
- return NewLocAppError("Preference.IsValid", "model.preference.is_valid.value.app_error", nil, "value="+o.Value)
+ 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 NewLocAppError("Preference.IsValid", "model.preference.is_valid.theme.app_error", nil, "value="+o.Value)
+ return NewAppError("Preference.IsValid", "model.preference.is_valid.theme.app_error", nil, "value="+o.Value, http.StatusBadRequest)
}
}
diff --git a/vendor/github.com/mattermost/platform/model/push_notification.go b/vendor/github.com/mattermost/platform/model/push_notification.go
index 654d1d9a..69719e74 100644
--- a/vendor/github.com/mattermost/platform/model/push_notification.go
+++ b/vendor/github.com/mattermost/platform/model/push_notification.go
@@ -18,7 +18,9 @@ const (
PUSH_TYPE_MESSAGE = "message"
PUSH_TYPE_CLEAR = "clear"
- CATEGORY_DM = "DIRECT_MESSAGE"
+ // 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"
)
@@ -34,6 +36,8 @@ type PushNotification struct {
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"`
diff --git a/vendor/github.com/mattermost/platform/model/reaction.go b/vendor/github.com/mattermost/platform/model/reaction.go
index 3d334c21..4b72dd44 100644
--- a/vendor/github.com/mattermost/platform/model/reaction.go
+++ b/vendor/github.com/mattermost/platform/model/reaction.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"regexp"
)
@@ -54,21 +55,21 @@ func ReactionsFromJson(data io.Reader) []*Reaction {
func (o *Reaction) IsValid() *AppError {
if len(o.UserId) != 26 {
- return NewLocAppError("Reaction.IsValid", "model.reaction.is_valid.user_id.app_error", nil, "user_id="+o.UserId)
+ 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 NewLocAppError("Reaction.IsValid", "model.reaction.is_valid.post_id.app_error", nil, "post_id="+o.PostId)
+ 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 NewLocAppError("Reaction.IsValid", "model.reaction.is_valid.emoji_name.app_error", nil, "emoji_name="+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 NewLocAppError("Reaction.IsValid", "model.reaction.is_valid.create_at.app_error", nil, "")
+ return NewAppError("Reaction.IsValid", "model.reaction.is_valid.create_at.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/search_params.go b/vendor/github.com/mattermost/platform/model/search_params.go
index 070ac6d2..2feea8da 100644
--- a/vendor/github.com/mattermost/platform/model/search_params.go
+++ b/vendor/github.com/mattermost/platform/model/search_params.go
@@ -31,16 +31,6 @@ func (o *SearchParams) ToJson() string {
var searchFlags = [...]string{"from", "channel", "in"}
-func splitWordsNoQuotes(text string) []string {
- words := []string{}
-
- for _, word := range strings.Fields(text) {
- words = append(words, word)
- }
-
- return words
-}
-
func splitWords(text string) []string {
words := []string{}
@@ -55,14 +45,14 @@ func splitWords(text string) []string {
foundQuote = false
location = i + 1
} else {
- words = append(words, splitWordsNoQuotes(text[location:i])...)
+ words = append(words, strings.Fields(text[location:i])...)
foundQuote = true
location = i
}
}
}
- words = append(words, splitWordsNoQuotes(text[location:])...)
+ words = append(words, strings.Fields(text[location:])...)
return words
}
diff --git a/vendor/github.com/mattermost/platform/model/session.go b/vendor/github.com/mattermost/platform/model/session.go
index 960c18cb..704af067 100644
--- a/vendor/github.com/mattermost/platform/model/session.go
+++ b/vendor/github.com/mattermost/platform/model/session.go
@@ -37,6 +37,11 @@ type Session struct {
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 {
diff --git a/vendor/github.com/mattermost/platform/model/slack_attachment.go b/vendor/github.com/mattermost/platform/model/slack_attachment.go
index 85583821..197d3f0f 100644
--- a/vendor/github.com/mattermost/platform/model/slack_attachment.go
+++ b/vendor/github.com/mattermost/platform/model/slack_attachment.go
@@ -5,7 +5,6 @@ package model
import (
"fmt"
- "strings"
)
type SlackAttachment struct {
@@ -25,6 +24,7 @@ type SlackAttachment struct {
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 {
@@ -33,23 +33,7 @@ type SlackAttachmentField struct {
Short bool `json:"short"`
}
-// To mention @channel via a webhook in Slack, the message should contain
-// <!channel>, as explained at the bottom of this article:
-// https://get.slack.help/hc/en-us/articles/202009646-Making-announcements
-func ExpandAnnouncement(text string) string {
- c1 := "<!channel>"
- c2 := "@channel"
- if strings.Contains(text, c1) {
- return strings.Replace(text, c1, c2, -1)
- }
- return text
-}
-
-// Expand announcements in incoming webhooks from Slack. Those announcements
-// can be found in the text attribute, or in the pretext, text, title and value
-// attributes of the attachment structure. The Slack attachment structure is
-// documented here: https://api.slack.com/docs/attachments
-func ProcessSlackAttachments(a []*SlackAttachment) []*SlackAttachment {
+func StringifySlackFieldValue(a []*SlackAttachment) []*SlackAttachment {
var nonNilAttachments []*SlackAttachment
for _, attachment := range a {
if attachment == nil {
@@ -57,10 +41,6 @@ func ProcessSlackAttachments(a []*SlackAttachment) []*SlackAttachment {
}
nonNilAttachments = append(nonNilAttachments, attachment)
- attachment.Pretext = ExpandAnnouncement(attachment.Pretext)
- attachment.Text = ExpandAnnouncement(attachment.Text)
- attachment.Title = ExpandAnnouncement(attachment.Title)
-
var nonNilFields []*SlackAttachmentField
for _, field := range attachment.Fields {
if field == nil {
@@ -70,7 +50,7 @@ func ProcessSlackAttachments(a []*SlackAttachment) []*SlackAttachment {
if field.Value != nil {
// Ensure the value is set to a string if it is set
- field.Value = ExpandAnnouncement(fmt.Sprintf("%v", field.Value))
+ field.Value = fmt.Sprintf("%v", field.Value)
}
}
attachment.Fields = nonNilFields
diff --git a/vendor/github.com/mattermost/platform/model/status.go b/vendor/github.com/mattermost/platform/model/status.go
index d838eea0..6da6161e 100644
--- a/vendor/github.com/mattermost/platform/model/status.go
+++ b/vendor/github.com/mattermost/platform/model/status.go
@@ -11,6 +11,7 @@ import (
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
diff --git a/vendor/github.com/mattermost/platform/model/team_member.go b/vendor/github.com/mattermost/platform/model/team_member.go
index 3a0befa3..6c70b75e 100644
--- a/vendor/github.com/mattermost/platform/model/team_member.go
+++ b/vendor/github.com/mattermost/platform/model/team_member.go
@@ -6,6 +6,7 @@ package model
import (
"encoding/json"
"io"
+ "net/http"
"strings"
)
@@ -103,11 +104,11 @@ func TeamsUnreadFromJson(data io.Reader) []*TeamUnread {
func (o *TeamMember) IsValid() *AppError {
if len(o.TeamId) != 26 {
- return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.team_id.app_error", nil, "")
+ return NewAppError("TeamMember.IsValid", "model.team_member.is_valid.team_id.app_error", nil, "", http.StatusBadRequest)
}
if len(o.UserId) != 26 {
- return NewLocAppError("TeamMember.IsValid", "model.team_member.is_valid.user_id.app_error", nil, "")
+ return NewAppError("TeamMember.IsValid", "model.team_member.is_valid.user_id.app_error", nil, "", http.StatusBadRequest)
}
return nil
diff --git a/vendor/github.com/mattermost/platform/model/user.go b/vendor/github.com/mattermost/platform/model/user.go
index ab4b21e2..7e767fd5 100644
--- a/vendor/github.com/mattermost/platform/model/user.go
+++ b/vendor/github.com/mattermost/platform/model/user.go
@@ -88,6 +88,12 @@ type UserPatch struct {
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 {
@@ -228,16 +234,13 @@ 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_ALL
+ u.NotifyProps["desktop"] = USER_NOTIFY_MENTION
u.NotifyProps["desktop_sound"] = "true"
u.NotifyProps["mention_keys"] = u.Username + ",@" + u.Username
u.NotifyProps["channel"] = "true"
-
- if u.FirstName == "" {
- u.NotifyProps["first_name"] = "false"
- } else {
- u.NotifyProps["first_name"] = "true"
- }
+ u.NotifyProps["push_status"] = STATUS_AWAY
+ u.NotifyProps["comments"] = "never"
+ u.NotifyProps["first_name"] = "false"
}
func (user *User) UpdateMentionKeysFromUsername(oldUsername string) {
@@ -312,6 +315,15 @@ func (u *UserPatch) ToJson() string {
}
}
+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)
@@ -320,8 +332,7 @@ func (u *User) Etag(showFullName, showEmail bool) string {
// Remove any private data from the user object
func (u *User) Sanitize(options map[string]bool) {
u.Password = ""
- u.AuthData = new(string)
- *u.AuthData = ""
+ u.AuthData = NewString("")
u.MfaSecret = ""
if len(options) != 0 && !options["email"] {
@@ -341,12 +352,10 @@ func (u *User) Sanitize(options map[string]bool) {
func (u *User) ClearNonProfileFields() {
u.Password = ""
- u.AuthData = new(string)
- *u.AuthData = ""
+ u.AuthData = NewString("")
u.MfaSecret = ""
u.EmailVerified = false
u.AllowMarketing = false
- u.Props = StringMap{}
u.NotifyProps = StringMap{}
u.LastPasswordUpdate = 0
u.FailedAttempts = 0
@@ -437,7 +446,7 @@ func IsValidUserRoles(userRoles string) bool {
}
func isValidRole(roleId string) bool {
- _, ok := BuiltInRoles[roleId]
+ _, ok := DefaultRoles[roleId]
return ok
}
@@ -500,6 +509,17 @@ func UserPatchFromJson(data io.Reader) *UserPatch {
}
}
+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 {
diff --git a/vendor/github.com/mattermost/platform/model/user_access_token.go b/vendor/github.com/mattermost/platform/model/user_access_token.go
index 090780fd..e189ec23 100644
--- a/vendor/github.com/mattermost/platform/model/user_access_token.go
+++ b/vendor/github.com/mattermost/platform/model/user_access_token.go
@@ -14,6 +14,7 @@ type UserAccessToken struct {
Token string `json:"token,omitempty"`
UserId string `json:"user_id"`
Description string `json:"description"`
+ IsActive bool `json:"is_active"`
}
func (t *UserAccessToken) IsValid() *AppError {
@@ -38,6 +39,7 @@ func (t *UserAccessToken) IsValid() *AppError {
func (t *UserAccessToken) PreSave() {
t.Id = NewId()
+ t.IsActive = true
}
func (t *UserAccessToken) ToJson() string {
diff --git a/vendor/github.com/mattermost/platform/model/utils.go b/vendor/github.com/mattermost/platform/model/utils.go
index 090644ec..e84d44f7 100644
--- a/vendor/github.com/mattermost/platform/model/utils.go
+++ b/vendor/github.com/mattermost/platform/model/utils.go
@@ -12,12 +12,14 @@ import (
"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"
@@ -90,7 +92,7 @@ func AppErrorFromJson(data io.Reader) *AppError {
if err == nil {
return &er
} else {
- return NewLocAppError("AppErrorFromJson", "model.utils.decode_json.app_error", nil, "body: "+str)
+ return NewAppError("AppErrorFromJson", "model.utils.decode_json.app_error", nil, "body: "+str, http.StatusInternalServerError)
}
}
@@ -106,18 +108,6 @@ func NewAppError(where string, id string, params map[string]interface{}, details
return ap
}
-func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError {
- ap := &AppError{}
- ap.Id = id
- ap.params = params
- ap.Message = id
- ap.Where = where
- ap.DetailedError = details
- ap.StatusCode = 500
- ap.IsOAuth = false
- return ap
-}
-
var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769")
// NewId is a globally unique identifier. It is a [A-Z0-9] string 26
@@ -283,11 +273,7 @@ func GetServerIpAddress() string {
}
func IsLower(s string) bool {
- if strings.ToLower(s) == s {
- return true
- }
-
- return false
+ return strings.ToLower(s) == s
}
func IsValidEmail(email string) bool {
@@ -492,3 +478,17 @@ func IsValidNumberString(value string) bool {
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
index b08af46b..430924ee 100644
--- a/vendor/github.com/mattermost/platform/model/version.go
+++ b/vendor/github.com/mattermost/platform/model/version.go
@@ -13,6 +13,11 @@ import (
// 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",
diff --git a/vendor/github.com/mattermost/platform/model/websocket_client.go b/vendor/github.com/mattermost/platform/model/websocket_client.go
index 2fa405f3..e5c44dde 100644
--- a/vendor/github.com/mattermost/platform/model/websocket_client.go
+++ b/vendor/github.com/mattermost/platform/model/websocket_client.go
@@ -5,6 +5,8 @@ package model
import (
"encoding/json"
+ "net/http"
+
"github.com/gorilla/websocket"
)
@@ -29,7 +31,7 @@ type WebSocketClient struct {
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, NewLocAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error())
+ return nil, NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
client := &WebSocketClient{
@@ -54,7 +56,7 @@ func NewWebSocketClient(url, authToken string) (*WebSocketClient, *AppError) {
func NewWebSocketClient4(url, authToken string) (*WebSocketClient, *AppError) {
conn, _, err := websocket.DefaultDialer.Dial(url+API_URL_SUFFIX+"/websocket", nil)
if err != nil {
- return nil, NewLocAppError("NewWebSocketClient4", "model.websocket_client.connect_fail.app_error", nil, err.Error())
+ return nil, NewAppError("NewWebSocketClient4", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
client := &WebSocketClient{
@@ -78,7 +80,7 @@ func (wsc *WebSocketClient) Connect() *AppError {
var err error
wsc.Conn, _, err = websocket.DefaultDialer.Dial(wsc.ConnectUrl, nil)
if err != nil {
- return NewLocAppError("Connect", "model.websocket_client.connect_fail.app_error", nil, err.Error())
+ return NewAppError("Connect", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
wsc.EventChannel = make(chan *WebSocketEvent, 100)
@@ -106,7 +108,7 @@ func (wsc *WebSocketClient) Listen() {
var err error
if _, rawMsg, err = wsc.Conn.ReadMessage(); err != nil {
if !websocket.IsCloseError(err, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
- wsc.ListenError = NewLocAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error())
+ wsc.ListenError = NewAppError("NewWebSocketClient", "model.websocket_client.connect_fail.app_error", nil, err.Error(), http.StatusInternalServerError)
}
return
diff --git a/vendor/github.com/mattermost/platform/model/websocket_message.go b/vendor/github.com/mattermost/platform/model/websocket_message.go
index 6b8c0342..bf2535dc 100644
--- a/vendor/github.com/mattermost/platform/model/websocket_message.go
+++ b/vendor/github.com/mattermost/platform/model/websocket_message.go
@@ -24,6 +24,7 @@ const (
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"
@@ -39,6 +40,8 @@ const (
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 {
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/LICENSE.txt b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/LICENSE.txt
deleted file mode 100644
index e5875711..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/config.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/config.go
deleted file mode 100644
index 577c3eb2..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/config.go
+++ /dev/null
@@ -1,288 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "encoding/xml"
- "fmt"
- "io/ioutil"
- "os"
- "strconv"
- "strings"
-)
-
-type xmlProperty struct {
- Name string `xml:"name,attr"`
- Value string `xml:",chardata"`
-}
-
-type xmlFilter struct {
- Enabled string `xml:"enabled,attr"`
- Tag string `xml:"tag"`
- Level string `xml:"level"`
- Type string `xml:"type"`
- Property []xmlProperty `xml:"property"`
-}
-
-type xmlLoggerConfig struct {
- Filter []xmlFilter `xml:"filter"`
-}
-
-// Load XML configuration; see examples/example.xml for documentation
-func (log Logger) LoadConfiguration(filename string) {
- log.Close()
-
- // Open the configuration file
- fd, err := os.Open(filename)
- if err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not open %q for reading: %s\n", filename, err)
- os.Exit(1)
- }
-
- contents, err := ioutil.ReadAll(fd)
- if err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not read %q: %s\n", filename, err)
- os.Exit(1)
- }
-
- xc := new(xmlLoggerConfig)
- if err := xml.Unmarshal(contents, xc); err != nil {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not parse XML configuration in %q: %s\n", filename, err)
- os.Exit(1)
- }
-
- for _, xmlfilt := range xc.Filter {
- var filt LogWriter
- var lvl Level
- bad, good, enabled := false, true, false
-
- // Check required children
- if len(xmlfilt.Enabled) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required attribute %s for filter missing in %s\n", "enabled", filename)
- bad = true
- } else {
- enabled = xmlfilt.Enabled != "false"
- }
- if len(xmlfilt.Tag) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "tag", filename)
- bad = true
- }
- if len(xmlfilt.Type) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "type", filename)
- bad = true
- }
- if len(xmlfilt.Level) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter missing in %s\n", "level", filename)
- bad = true
- }
-
- switch xmlfilt.Level {
- case "FINEST":
- lvl = FINEST
- case "FINE":
- lvl = FINE
- case "DEBUG":
- lvl = DEBUG
- case "TRACE":
- lvl = TRACE
- case "INFO":
- lvl = INFO
- case "WARNING":
- lvl = WARNING
- case "ERROR":
- lvl = ERROR
- case "CRITICAL":
- lvl = CRITICAL
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required child <%s> for filter has unknown value in %s: %s\n", "level", filename, xmlfilt.Level)
- bad = true
- }
-
- // Just so all of the required attributes are errored at the same time if missing
- if bad {
- os.Exit(1)
- }
-
- switch xmlfilt.Type {
- case "console":
- filt, good = xmlToConsoleLogWriter(filename, xmlfilt.Property, enabled)
- case "file":
- filt, good = xmlToFileLogWriter(filename, xmlfilt.Property, enabled)
- case "xml":
- filt, good = xmlToXMLLogWriter(filename, xmlfilt.Property, enabled)
- case "socket":
- filt, good = xmlToSocketLogWriter(filename, xmlfilt.Property, enabled)
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Could not load XML configuration in %s: unknown filter type \"%s\"\n", filename, xmlfilt.Type)
- os.Exit(1)
- }
-
- // Just so all of the required params are errored at the same time if wrong
- if !good {
- os.Exit(1)
- }
-
- // If we're disabled (syntax and correctness checks only), don't add to logger
- if !enabled {
- continue
- }
-
- log[xmlfilt.Tag] = &Filter{lvl, filt}
- }
-}
-
-func xmlToConsoleLogWriter(filename string, props []xmlProperty, enabled bool) (*ConsoleLogWriter, bool) {
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for console filter in %s\n", prop.Name, filename)
- }
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- return NewConsoleLogWriter(), true
-}
-
-// Parse a number with K/M/G suffixes based on thousands (1000) or 2^10 (1024)
-func strToNumSuffix(str string, mult int) int {
- num := 1
- if len(str) > 1 {
- switch str[len(str)-1] {
- case 'G', 'g':
- num *= mult
- fallthrough
- case 'M', 'm':
- num *= mult
- fallthrough
- case 'K', 'k':
- num *= mult
- str = str[0 : len(str)-1]
- }
- }
- parsed, _ := strconv.Atoi(str)
- return parsed * num
-}
-func xmlToFileLogWriter(filename string, props []xmlProperty, enabled bool) (*FileLogWriter, bool) {
- file := ""
- format := "[%D %T] [%L] (%S) %M"
- maxlines := 0
- maxsize := 0
- daily := false
- rotate := false
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "filename":
- file = strings.Trim(prop.Value, " \r\n")
- case "format":
- format = strings.Trim(prop.Value, " \r\n")
- case "maxlines":
- maxlines = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1000)
- case "maxsize":
- maxsize = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1024)
- case "daily":
- daily = strings.Trim(prop.Value, " \r\n") != "false"
- case "rotate":
- rotate = strings.Trim(prop.Value, " \r\n") != "false"
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for file filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(file) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for file filter missing in %s\n", "filename", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- flw := NewFileLogWriter(file, rotate)
- flw.SetFormat(format)
- flw.SetRotateLines(maxlines)
- flw.SetRotateSize(maxsize)
- flw.SetRotateDaily(daily)
- return flw, true
-}
-
-func xmlToXMLLogWriter(filename string, props []xmlProperty, enabled bool) (*FileLogWriter, bool) {
- file := ""
- maxrecords := 0
- maxsize := 0
- daily := false
- rotate := false
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "filename":
- file = strings.Trim(prop.Value, " \r\n")
- case "maxrecords":
- maxrecords = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1000)
- case "maxsize":
- maxsize = strToNumSuffix(strings.Trim(prop.Value, " \r\n"), 1024)
- case "daily":
- daily = strings.Trim(prop.Value, " \r\n") != "false"
- case "rotate":
- rotate = strings.Trim(prop.Value, " \r\n") != "false"
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for xml filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(file) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for xml filter missing in %s\n", "filename", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- xlw := NewXMLLogWriter(file, rotate)
- xlw.SetRotateLines(maxrecords)
- xlw.SetRotateSize(maxsize)
- xlw.SetRotateDaily(daily)
- return xlw, true
-}
-
-func xmlToSocketLogWriter(filename string, props []xmlProperty, enabled bool) (SocketLogWriter, bool) {
- endpoint := ""
- protocol := "udp"
-
- // Parse properties
- for _, prop := range props {
- switch prop.Name {
- case "endpoint":
- endpoint = strings.Trim(prop.Value, " \r\n")
- case "protocol":
- protocol = strings.Trim(prop.Value, " \r\n")
- default:
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Warning: Unknown property \"%s\" for file filter in %s\n", prop.Name, filename)
- }
- }
-
- // Check properties
- if len(endpoint) == 0 {
- fmt.Fprintf(os.Stderr, "LoadConfiguration: Error: Required property \"%s\" for file filter missing in %s\n", "endpoint", filename)
- return nil, false
- }
-
- // If it's disabled, we're just checking syntax
- if !enabled {
- return nil, true
- }
-
- return NewSocketLogWriter(protocol, endpoint), true
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/filelog.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/filelog.go
deleted file mode 100644
index ee0ab0c0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/filelog.go
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "fmt"
- "os"
- "time"
-)
-
-// This log writer sends output to a file
-type FileLogWriter struct {
- rec chan *LogRecord
- rot chan bool
-
- // The opened file
- filename string
- file *os.File
-
- // The logging format
- format string
-
- // File header/trailer
- header, trailer string
-
- // Rotate at linecount
- maxlines int
- maxlines_curlines int
-
- // Rotate at size
- maxsize int
- maxsize_cursize int
-
- // Rotate daily
- daily bool
- daily_opendate int
-
- // Keep old logfiles (.001, .002, etc)
- rotate bool
- maxbackup int
-}
-
-// This is the FileLogWriter's output method
-func (w *FileLogWriter) LogWrite(rec *LogRecord) {
- w.rec <- rec
-}
-
-func (w *FileLogWriter) Close() {
- close(w.rec)
- w.file.Sync()
-}
-
-// NewFileLogWriter creates a new LogWriter which writes to the given file and
-// has rotation enabled if rotate is true.
-//
-// If rotate is true, any time a new log file is opened, the old one is renamed
-// with a .### extension to preserve it. The various Set* methods can be used
-// to configure log rotation based on lines, size, and daily.
-//
-// The standard log-line format is:
-// [%D %T] [%L] (%S) %M
-func NewFileLogWriter(fname string, rotate bool) *FileLogWriter {
- w := &FileLogWriter{
- rec: make(chan *LogRecord, LogBufferLength),
- rot: make(chan bool),
- filename: fname,
- format: "[%D %T] [%L] (%S) %M",
- rotate: rotate,
- maxbackup: 999,
- }
-
- // open the file for the first time
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return nil
- }
-
- go func() {
- defer func() {
- if w.file != nil {
- fmt.Fprint(w.file, FormatLogRecord(w.trailer, &LogRecord{Created: time.Now()}))
- w.file.Close()
- }
- }()
-
- for {
- select {
- case <-w.rot:
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
- case rec, ok := <-w.rec:
- if !ok {
- return
- }
- now := time.Now()
- if (w.maxlines > 0 && w.maxlines_curlines >= w.maxlines) ||
- (w.maxsize > 0 && w.maxsize_cursize >= w.maxsize) ||
- (w.daily && now.Day() != w.daily_opendate) {
- if err := w.intRotate(); err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
- }
-
- // Perform the write
- n, err := fmt.Fprint(w.file, FormatLogRecord(w.format, rec))
- if err != nil {
- fmt.Fprintf(os.Stderr, "FileLogWriter(%q): %s\n", w.filename, err)
- return
- }
-
- // Update the counts
- w.maxlines_curlines++
- w.maxsize_cursize += n
- }
- }
- }()
-
- return w
-}
-
-// Request that the logs rotate
-func (w *FileLogWriter) Rotate() {
- w.rot <- true
-}
-
-// If this is called in a threaded context, it MUST be synchronized
-func (w *FileLogWriter) intRotate() error {
- // Close any log file that may be open
- if w.file != nil {
- fmt.Fprint(w.file, FormatLogRecord(w.trailer, &LogRecord{Created: time.Now()}))
- w.file.Close()
- }
-
- // If we are keeping log files, move it to the next available number
- if w.rotate {
- _, err := os.Lstat(w.filename)
- if err == nil { // file exists
- // Find the next available number
- num := 1
- fname := ""
- if w.daily && time.Now().Day() != w.daily_opendate {
- yesterday := time.Now().AddDate(0, 0, -1).Format("2006-01-02")
-
- for ; err == nil && num <= 999; num++ {
- fname = w.filename + fmt.Sprintf(".%s.%03d", yesterday, num)
- _, err = os.Lstat(fname)
- }
- // return error if the last file checked still existed
- if err == nil {
- return fmt.Errorf("Rotate: Cannot find free log number to rename %s\n", w.filename)
- }
- } else {
- num = w.maxbackup - 1
- for ; num >= 1; num-- {
- fname = w.filename + fmt.Sprintf(".%d", num)
- nfname := w.filename + fmt.Sprintf(".%d", num+1)
- _, err = os.Lstat(fname)
- if err == nil {
- os.Rename(fname, nfname)
- }
- }
- }
-
- w.file.Close()
- // Rename the file to its newfound home
- err = os.Rename(w.filename, fname)
- if err != nil {
- return fmt.Errorf("Rotate: %s\n", err)
- }
- }
- }
-
- // Open the log file
- fd, err := os.OpenFile(w.filename, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0660)
- if err != nil {
- return err
- }
- w.file = fd
-
- now := time.Now()
- fmt.Fprint(w.file, FormatLogRecord(w.header, &LogRecord{Created: now}))
-
- // Set the daily open date to the current date
- w.daily_opendate = now.Day()
-
- // initialize rotation values
- w.maxlines_curlines = 0
- w.maxsize_cursize = 0
-
- return nil
-}
-
-// Set the logging format (chainable). Must be called before the first log
-// message is written.
-func (w *FileLogWriter) SetFormat(format string) *FileLogWriter {
- w.format = format
- return w
-}
-
-// Set the logfile header and footer (chainable). Must be called before the first log
-// message is written. These are formatted similar to the FormatLogRecord (e.g.
-// you can use %D and %T in your header/footer for date and time).
-func (w *FileLogWriter) SetHeadFoot(head, foot string) *FileLogWriter {
- w.header, w.trailer = head, foot
- if w.maxlines_curlines == 0 {
- fmt.Fprint(w.file, FormatLogRecord(w.header, &LogRecord{Created: time.Now()}))
- }
- return w
-}
-
-// Set rotate at linecount (chainable). Must be called before the first log
-// message is written.
-func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateLines: %v\n", maxlines)
- w.maxlines = maxlines
- return w
-}
-
-// Set rotate at size (chainable). Must be called before the first log message
-// is written.
-func (w *FileLogWriter) SetRotateSize(maxsize int) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateSize: %v\n", maxsize)
- w.maxsize = maxsize
- return w
-}
-
-// Set rotate daily (chainable). Must be called before the first log message is
-// written.
-func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotateDaily: %v\n", daily)
- w.daily = daily
- return w
-}
-
-// Set max backup files. Must be called before the first log message
-// is written.
-func (w *FileLogWriter) SetRotateMaxBackup(maxbackup int) *FileLogWriter {
- w.maxbackup = maxbackup
- return w
-}
-
-// SetRotate changes whether or not the old logs are kept. (chainable) Must be
-// called before the first log message is written. If rotate is false, the
-// files are overwritten; otherwise, they are rotated to another file before the
-// new log is opened.
-func (w *FileLogWriter) SetRotate(rotate bool) *FileLogWriter {
- //fmt.Fprintf(os.Stderr, "FileLogWriter.SetRotate: %v\n", rotate)
- w.rotate = rotate
- return w
-}
-
-// NewXMLLogWriter is a utility method for creating a FileLogWriter set up to
-// output XML record log messages instead of line-based ones.
-func NewXMLLogWriter(fname string, rotate bool) *FileLogWriter {
- return NewFileLogWriter(fname, rotate).SetFormat(
- ` <record level="%L">
- <timestamp>%D %T</timestamp>
- <source>%S</source>
- <message>%M</message>
- </record>`).SetHeadFoot("<log created=\"%D %T\">", "</log>")
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/log4go.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/log4go.go
deleted file mode 100644
index 822e890c..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/log4go.go
+++ /dev/null
@@ -1,484 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-// Package log4go provides level-based and highly configurable logging.
-//
-// Enhanced Logging
-//
-// This is inspired by the logging functionality in Java. Essentially, you create a Logger
-// object and create output filters for it. You can send whatever you want to the Logger,
-// and it will filter that based on your settings and send it to the outputs. This way, you
-// can put as much debug code in your program as you want, and when you're done you can filter
-// out the mundane messages so only the important ones show up.
-//
-// Utility functions are provided to make life easier. Here is some example code to get started:
-//
-// log := log4go.NewLogger()
-// log.AddFilter("stdout", log4go.DEBUG, log4go.NewConsoleLogWriter())
-// log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true))
-// log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))
-//
-// The first two lines can be combined with the utility NewDefaultLogger:
-//
-// log := log4go.NewDefaultLogger(log4go.DEBUG)
-// log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true))
-// log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))
-//
-// Usage notes:
-// - The ConsoleLogWriter does not display the source of the message to standard
-// output, but the FileLogWriter does.
-// - The utility functions (Info, Debug, Warn, etc) derive their source from the
-// calling function, and this incurs extra overhead.
-//
-// Changes from 2.0:
-// - The external interface has remained mostly stable, but a lot of the
-// internals have been changed, so if you depended on any of this or created
-// your own LogWriter, then you will probably have to update your code. In
-// particular, Logger is now a map and ConsoleLogWriter is now a channel
-// behind-the-scenes, and the LogWrite method no longer has return values.
-//
-// Future work: (please let me know if you think I should work on any of these particularly)
-// - Log file rotation
-// - Logging configuration files ala log4j
-// - Have the ability to remove filters?
-// - Have GetInfoChannel, GetDebugChannel, etc return a chan string that allows
-// for another method of logging
-// - Add an XML filter type
-package log4go
-
-import (
- "errors"
- "fmt"
- "os"
- "runtime"
- "strings"
- "time"
-)
-
-// Version information
-const (
- L4G_VERSION = "log4go-v3.0.1"
- L4G_MAJOR = 3
- L4G_MINOR = 0
- L4G_BUILD = 1
-)
-
-/****** Constants ******/
-
-// These are the integer logging levels used by the logger
-type Level int
-
-const (
- FINEST Level = iota
- FINE
- DEBUG
- TRACE
- INFO
- WARNING
- ERROR
- CRITICAL
-)
-
-// Logging level strings
-var (
- levelStrings = [...]string{"FNST", "FINE", "DEBG", "TRAC", "INFO", "WARN", "EROR", "CRIT"}
-)
-
-func (l Level) String() string {
- if l < 0 || int(l) > len(levelStrings) {
- return "UNKNOWN"
- }
- return levelStrings[int(l)]
-}
-
-/****** Variables ******/
-var (
- // LogBufferLength specifies how many log messages a particular log4go
- // logger can buffer at a time before writing them.
- LogBufferLength = 32
-)
-
-/****** LogRecord ******/
-
-// A LogRecord contains all of the pertinent information for each message
-type LogRecord struct {
- Level Level // The log level
- Created time.Time // The time at which the log message was created (nanoseconds)
- Source string // The message source
- Message string // The log message
-}
-
-/****** LogWriter ******/
-
-// This is an interface for anything that should be able to write logs
-type LogWriter interface {
- // This will be called to log a LogRecord message.
- LogWrite(rec *LogRecord)
-
- // This should clean up anything lingering about the LogWriter, as it is called before
- // the LogWriter is removed. LogWrite should not be called after Close.
- Close()
-}
-
-/****** Logger ******/
-
-// A Filter represents the log level below which no log records are written to
-// the associated LogWriter.
-type Filter struct {
- Level Level
- LogWriter
-}
-
-// A Logger represents a collection of Filters through which log messages are
-// written.
-type Logger map[string]*Filter
-
-// Create a new logger.
-//
-// DEPRECATED: Use make(Logger) instead.
-func NewLogger() Logger {
- os.Stderr.WriteString("warning: use of deprecated NewLogger\n")
- return make(Logger)
-}
-
-// Create a new logger with a "stdout" filter configured to send log messages at
-// or above lvl to standard output.
-//
-// DEPRECATED: use NewDefaultLogger instead.
-func NewConsoleLogger(lvl Level) Logger {
- os.Stderr.WriteString("warning: use of deprecated NewConsoleLogger\n")
- return Logger{
- "stdout": &Filter{lvl, NewConsoleLogWriter()},
- }
-}
-
-// Create a new logger with a "stdout" filter configured to send log messages at
-// or above lvl to standard output.
-func NewDefaultLogger(lvl Level) Logger {
- return Logger{
- "stdout": &Filter{lvl, NewConsoleLogWriter()},
- }
-}
-
-// Closes all log writers in preparation for exiting the program or a
-// reconfiguration of logging. Calling this is not really imperative, unless
-// you want to guarantee that all log messages are written. Close removes
-// all filters (and thus all LogWriters) from the logger.
-func (log Logger) Close() {
- // Close all open loggers
- for name, filt := range log {
- filt.Close()
- delete(log, name)
- }
-}
-
-// Add a new LogWriter to the Logger which will only log messages at lvl or
-// higher. This function should not be called from multiple goroutines.
-// Returns the logger for chaining.
-func (log Logger) AddFilter(name string, lvl Level, writer LogWriter) Logger {
- log[name] = &Filter{lvl, writer}
- return log
-}
-
-/******* Logging *******/
-// Send a formatted log message internally
-func (log Logger) intLogf(lvl Level, format string, args ...interface{}) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Determine caller func
- pc, _, lineno, ok := runtime.Caller(2)
- src := ""
- if ok {
- src = fmt.Sprintf("%s:%d", runtime.FuncForPC(pc).Name(), lineno)
- }
-
- msg := format
- if len(args) > 0 {
- msg = fmt.Sprintf(format, args...)
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: src,
- Message: msg,
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Send a closure log message internally
-func (log Logger) intLogc(lvl Level, closure func() string) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Determine caller func
- pc, _, lineno, ok := runtime.Caller(2)
- src := ""
- if ok {
- src = fmt.Sprintf("%s:%d", runtime.FuncForPC(pc).Name(), lineno)
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: src,
- Message: closure(),
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Send a log message with manual level, source, and message.
-func (log Logger) Log(lvl Level, source, message string) {
- skip := true
-
- // Determine if any logging will be done
- for _, filt := range log {
- if lvl >= filt.Level {
- skip = false
- break
- }
- }
- if skip {
- return
- }
-
- // Make the log record
- rec := &LogRecord{
- Level: lvl,
- Created: time.Now(),
- Source: source,
- Message: message,
- }
-
- // Dispatch the logs
- for _, filt := range log {
- if lvl < filt.Level {
- continue
- }
- filt.LogWrite(rec)
- }
-}
-
-// Logf logs a formatted log message at the given log level, using the caller as
-// its source.
-func (log Logger) Logf(lvl Level, format string, args ...interface{}) {
- log.intLogf(lvl, format, args...)
-}
-
-// Logc logs a string returned by the closure at the given log level, using the caller as
-// its source. If no log message would be written, the closure is never called.
-func (log Logger) Logc(lvl Level, closure func() string) {
- log.intLogc(lvl, closure)
-}
-
-// Finest logs a message at the finest log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Finest(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINEST
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Fine logs a message at the fine log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Fine(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Debug is a utility method for debug log messages.
-// The behavior of Debug depends on the first argument:
-// - arg0 is a string
-// When given a string as the first argument, this behaves like Logf but with
-// the DEBUG log level: the first argument is interpreted as a format for the
-// latter arguments.
-// - arg0 is a func()string
-// When given a closure of type func()string, this logs the string returned by
-// the closure iff it will be logged. The closure runs at most one time.
-// - arg0 is interface{}
-// When given anything else, the log message will be each of the arguments
-// formatted with %v and separated by spaces (ala Sprint).
-func (log Logger) Debug(arg0 interface{}, args ...interface{}) {
- const (
- lvl = DEBUG
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Trace logs a message at the trace log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Trace(arg0 interface{}, args ...interface{}) {
- const (
- lvl = TRACE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Info logs a message at the info log level.
-// See Debug for an explanation of the arguments.
-func (log Logger) Info(arg0 interface{}, args ...interface{}) {
- const (
- lvl = INFO
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- log.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- log.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Warn logs a message at the warning log level and returns the formatted error.
-// At the warning level and higher, there is no performance benefit if the
-// message is not actually logged, because all formats are processed and all
-// closures are executed to format the error message.
-// See Debug for further explanation of the arguments.
-func (log Logger) Warn(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = WARNING
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
-
-// Error logs a message at the error log level and returns the formatted error,
-// See Warn for an explanation of the performance and Debug for an explanation
-// of the parameters.
-func (log Logger) Error(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = ERROR
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
-
-// Critical logs a message at the critical log level and returns the formatted error,
-// See Warn for an explanation of the performance and Debug for an explanation
-// of the parameters.
-func (log Logger) Critical(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = CRITICAL
- )
- var msg string
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- msg = fmt.Sprintf(first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- msg = first()
- default:
- // Build a format string so that it will be similar to Sprint
- msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- }
- log.intLogf(lvl, msg)
- return errors.New(msg)
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/pattlog.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/pattlog.go
deleted file mode 100644
index 82b4e36b..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/pattlog.go
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "bytes"
- "fmt"
- "io"
- "strings"
-)
-
-const (
- FORMAT_DEFAULT = "[%D %T] [%L] (%S) %M"
- FORMAT_SHORT = "[%t %d] [%L] %M"
- FORMAT_ABBREV = "[%L] %M"
-)
-
-type formatCacheType struct {
- LastUpdateSeconds int64
- shortTime, shortDate string
- longTime, longDate string
-}
-
-var formatCache = &formatCacheType{}
-
-// Known format codes:
-// %T - Time (15:04:05 MST)
-// %t - Time (15:04)
-// %D - Date (2006/01/02)
-// %d - Date (01/02/06)
-// %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT)
-// %S - Source
-// %M - Message
-// Ignores unknown formats
-// Recommended: "[%D %T] [%L] (%S) %M"
-func FormatLogRecord(format string, rec *LogRecord) string {
- if rec == nil {
- return "<nil>"
- }
- if len(format) == 0 {
- return ""
- }
-
- out := bytes.NewBuffer(make([]byte, 0, 64))
- secs := rec.Created.UnixNano() / 1e9
-
- cache := *formatCache
- if cache.LastUpdateSeconds != secs {
- month, day, year := rec.Created.Month(), rec.Created.Day(), rec.Created.Year()
- hour, minute, second := rec.Created.Hour(), rec.Created.Minute(), rec.Created.Second()
- zone, _ := rec.Created.Zone()
- updated := &formatCacheType{
- LastUpdateSeconds: secs,
- shortTime: fmt.Sprintf("%02d:%02d", hour, minute),
- shortDate: fmt.Sprintf("%02d/%02d/%02d", day, month, year%100),
- longTime: fmt.Sprintf("%02d:%02d:%02d %s", hour, minute, second, zone),
- longDate: fmt.Sprintf("%04d/%02d/%02d", year, month, day),
- }
- cache = *updated
- formatCache = updated
- }
-
- // Split the string into pieces by % signs
- pieces := bytes.Split([]byte(format), []byte{'%'})
-
- // Iterate over the pieces, replacing known formats
- for i, piece := range pieces {
- if i > 0 && len(piece) > 0 {
- switch piece[0] {
- case 'T':
- out.WriteString(cache.longTime)
- case 't':
- out.WriteString(cache.shortTime)
- case 'D':
- out.WriteString(cache.longDate)
- case 'd':
- out.WriteString(cache.shortDate)
- case 'L':
- out.WriteString(levelStrings[rec.Level])
- case 'S':
- out.WriteString(rec.Source)
- case 's':
- slice := strings.Split(rec.Source, "/")
- out.WriteString(slice[len(slice)-1])
- case 'M':
- out.WriteString(rec.Message)
- }
- if len(piece) > 1 {
- out.Write(piece[1:])
- }
- } else if len(piece) > 0 {
- out.Write(piece)
- }
- }
- out.WriteByte('\n')
-
- return out.String()
-}
-
-// This is the standard writer that prints to standard output.
-type FormatLogWriter chan *LogRecord
-
-// This creates a new FormatLogWriter
-func NewFormatLogWriter(out io.Writer, format string) FormatLogWriter {
- records := make(FormatLogWriter, LogBufferLength)
- go records.run(out, format)
- return records
-}
-
-func (w FormatLogWriter) run(out io.Writer, format string) {
- for rec := range w {
- fmt.Fprint(out, FormatLogRecord(format, rec))
- }
-}
-
-// This is the FormatLogWriter's output method. This will block if the output
-// buffer is full.
-func (w FormatLogWriter) LogWrite(rec *LogRecord) {
- w <- rec
-}
-
-// Close stops the logger from sending messages to standard output. Attempts to
-// send log messages to this logger after a Close have undefined behavior.
-func (w FormatLogWriter) Close() {
- close(w)
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/socklog.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/socklog.go
deleted file mode 100644
index 1d224a99..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/socklog.go
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "encoding/json"
- "fmt"
- "net"
- "os"
-)
-
-// This log writer sends output to a socket
-type SocketLogWriter chan *LogRecord
-
-// This is the SocketLogWriter's output method
-func (w SocketLogWriter) LogWrite(rec *LogRecord) {
- w <- rec
-}
-
-func (w SocketLogWriter) Close() {
- close(w)
-}
-
-func NewSocketLogWriter(proto, hostport string) SocketLogWriter {
- sock, err := net.Dial(proto, hostport)
- if err != nil {
- fmt.Fprintf(os.Stderr, "NewSocketLogWriter(%q): %s\n", hostport, err)
- return nil
- }
-
- w := SocketLogWriter(make(chan *LogRecord, LogBufferLength))
-
- go func() {
- defer func() {
- if sock != nil && proto == "tcp" {
- sock.Close()
- }
- }()
-
- for rec := range w {
- // Marshall into JSON
- js, err := json.Marshal(rec)
- if err != nil {
- fmt.Fprint(os.Stderr, "SocketLogWriter(%q): %s", hostport, err)
- return
- }
-
- _, err = sock.Write(js)
- if err != nil {
- fmt.Fprint(os.Stderr, "SocketLogWriter(%q): %s", hostport, err)
- return
- }
- }
- }()
-
- return w
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/termlog.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/termlog.go
deleted file mode 100644
index 8a941e26..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/termlog.go
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "fmt"
- "io"
- "os"
- "time"
-)
-
-var stdout io.Writer = os.Stdout
-
-// This is the standard writer that prints to standard output.
-type ConsoleLogWriter struct {
- format string
- w chan *LogRecord
-}
-
-// This creates a new ConsoleLogWriter
-func NewConsoleLogWriter() *ConsoleLogWriter {
- consoleWriter := &ConsoleLogWriter{
- format: "[%T %D] [%L] (%S) %M",
- w: make(chan *LogRecord, LogBufferLength),
- }
- go consoleWriter.run(stdout)
- return consoleWriter
-}
-func (c *ConsoleLogWriter) SetFormat(format string) {
- c.format = format
-}
-func (c *ConsoleLogWriter) run(out io.Writer) {
- for rec := range c.w {
- fmt.Fprint(out, FormatLogRecord(c.format, rec))
- }
-}
-
-// This is the ConsoleLogWriter's output method. This will block if the output
-// buffer is full.
-func (c *ConsoleLogWriter) LogWrite(rec *LogRecord) {
- c.w <- rec
-}
-
-// Close stops the logger from sending messages to standard output. Attempts to
-// send log messages to this logger after a Close have undefined behavior.
-func (c *ConsoleLogWriter) Close() {
- close(c.w)
- time.Sleep(50 * time.Millisecond) // Try to give console I/O time to complete
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/wrapper.go b/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/wrapper.go
deleted file mode 100644
index 2ae222b0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/alecthomas/log4go/wrapper.go
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright (C) 2010, Kyle Lemons <kyle@kylelemons.net>. All rights reserved.
-
-package log4go
-
-import (
- "errors"
- "fmt"
- "os"
- "strings"
-)
-
-var (
- Global Logger
-)
-
-func init() {
- Global = NewDefaultLogger(DEBUG)
-}
-
-// Wrapper for (*Logger).LoadConfiguration
-func LoadConfiguration(filename string) {
- Global.LoadConfiguration(filename)
-}
-
-// Wrapper for (*Logger).AddFilter
-func AddFilter(name string, lvl Level, writer LogWriter) {
- Global.AddFilter(name, lvl, writer)
-}
-
-// Wrapper for (*Logger).Close (closes and removes all logwriters)
-func Close() {
- Global.Close()
-}
-
-func Crash(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(CRITICAL, strings.Repeat(" %v", len(args))[1:], args...)
- }
- panic(args)
-}
-
-// Logs the given message and crashes the program
-func Crashf(format string, args ...interface{}) {
- Global.intLogf(CRITICAL, format, args...)
- Global.Close() // so that hopefully the messages get logged
- panic(fmt.Sprintf(format, args...))
-}
-
-// Compatibility with `log`
-func Exit(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(ERROR, strings.Repeat(" %v", len(args))[1:], args...)
- }
- Global.Close() // so that hopefully the messages get logged
- os.Exit(0)
-}
-
-// Compatibility with `log`
-func Exitf(format string, args ...interface{}) {
- Global.intLogf(ERROR, format, args...)
- Global.Close() // so that hopefully the messages get logged
- os.Exit(0)
-}
-
-// Compatibility with `log`
-func Stderr(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(ERROR, strings.Repeat(" %v", len(args))[1:], args...)
- }
-}
-
-// Compatibility with `log`
-func Stderrf(format string, args ...interface{}) {
- Global.intLogf(ERROR, format, args...)
-}
-
-// Compatibility with `log`
-func Stdout(args ...interface{}) {
- if len(args) > 0 {
- Global.intLogf(INFO, strings.Repeat(" %v", len(args))[1:], args...)
- }
-}
-
-// Compatibility with `log`
-func Stdoutf(format string, args ...interface{}) {
- Global.intLogf(INFO, format, args...)
-}
-
-// Send a log message manually
-// Wrapper for (*Logger).Log
-func Log(lvl Level, source, message string) {
- Global.Log(lvl, source, message)
-}
-
-// Send a formatted log message easily
-// Wrapper for (*Logger).Logf
-func Logf(lvl Level, format string, args ...interface{}) {
- Global.intLogf(lvl, format, args...)
-}
-
-// Send a closure log message
-// Wrapper for (*Logger).Logc
-func Logc(lvl Level, closure func() string) {
- Global.intLogc(lvl, closure)
-}
-
-// Utility for finest log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Finest
-func Finest(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINEST
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for fine log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Fine
-func Fine(arg0 interface{}, args ...interface{}) {
- const (
- lvl = FINE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for debug log messages
-// When given a string as the first argument, this behaves like Logf but with the DEBUG log level (e.g. the first argument is interpreted as a format for the latter arguments)
-// When given a closure of type func()string, this logs the string returned by the closure iff it will be logged. The closure runs at most one time.
-// When given anything else, the log message will be each of the arguments formatted with %v and separated by spaces (ala Sprint).
-// Wrapper for (*Logger).Debug
-func Debug(arg0 interface{}, args ...interface{}) {
- const (
- lvl = DEBUG
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for trace log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Trace
-func Trace(arg0 interface{}, args ...interface{}) {
- const (
- lvl = TRACE
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for info log messages (see Debug() for parameter explanation)
-// Wrapper for (*Logger).Info
-func Info(arg0 interface{}, args ...interface{}) {
- const (
- lvl = INFO
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- case func() string:
- // Log the closure (no other arguments used)
- Global.intLogc(lvl, first)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
- }
-}
-
-// Utility for warn log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Warn
-func Warn(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = WARNING
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
-
-// Utility for error log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Error
-func Error(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = ERROR
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
-
-// Utility for critical log messages (returns an error for easy function returns) (see Debug() for parameter explanation)
-// These functions will execute a closure exactly once, to build the error message for the return
-// Wrapper for (*Logger).Critical
-func Critical(arg0 interface{}, args ...interface{}) error {
- const (
- lvl = CRITICAL
- )
- switch first := arg0.(type) {
- case string:
- // Use the string as a format string
- Global.intLogf(lvl, first, args...)
- return errors.New(fmt.Sprintf(first, args...))
- case func() string:
- // Log the closure (no other arguments used)
- str := first()
- Global.intLogf(lvl, "%s", str)
- return errors.New(str)
- default:
- // Build a format string so that it will be similar to Sprint
- Global.intLogf(lvl, fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
- return errors.New(fmt.Sprint(first) + fmt.Sprintf(strings.Repeat(" %v", len(args)), args...))
- }
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/LICENSE.txt b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/LICENSE.txt
deleted file mode 100644
index ead98cf0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client.go
deleted file mode 100644
index 43a87c75..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client.go
+++ /dev/null
@@ -1,392 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "bufio"
- "bytes"
- "crypto/tls"
- "encoding/base64"
- "errors"
- "io"
- "io/ioutil"
- "net"
- "net/http"
- "net/url"
- "strings"
- "time"
-)
-
-// ErrBadHandshake is returned when the server response to opening handshake is
-// invalid.
-var ErrBadHandshake = errors.New("websocket: bad handshake")
-
-var errInvalidCompression = errors.New("websocket: invalid compression negotiation")
-
-// NewClient creates a new client connection using the given net connection.
-// The URL u specifies the host and request URI. Use requestHeader to specify
-// the origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies
-// (Cookie). Use the response.Header to get the selected subprotocol
-// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
-//
-// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
-// non-nil *http.Response so that callers can handle redirects, authentication,
-// etc.
-//
-// Deprecated: Use Dialer instead.
-func NewClient(netConn net.Conn, u *url.URL, requestHeader http.Header, readBufSize, writeBufSize int) (c *Conn, response *http.Response, err error) {
- d := Dialer{
- ReadBufferSize: readBufSize,
- WriteBufferSize: writeBufSize,
- NetDial: func(net, addr string) (net.Conn, error) {
- return netConn, nil
- },
- }
- return d.Dial(u.String(), requestHeader)
-}
-
-// A Dialer contains options for connecting to WebSocket server.
-type Dialer struct {
- // NetDial specifies the dial function for creating TCP connections. If
- // NetDial is nil, net.Dial is used.
- NetDial func(network, addr string) (net.Conn, error)
-
- // Proxy specifies a function to return a proxy for a given
- // Request. If the function returns a non-nil error, the
- // request is aborted with the provided error.
- // If Proxy is nil or returns a nil *URL, no proxy is used.
- Proxy func(*http.Request) (*url.URL, error)
-
- // TLSClientConfig specifies the TLS configuration to use with tls.Client.
- // If nil, the default configuration is used.
- TLSClientConfig *tls.Config
-
- // HandshakeTimeout specifies the duration for the handshake to complete.
- HandshakeTimeout time.Duration
-
- // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
- // size is zero, then a useful default size is used. The I/O buffer sizes
- // do not limit the size of the messages that can be sent or received.
- ReadBufferSize, WriteBufferSize int
-
- // Subprotocols specifies the client's requested subprotocols.
- Subprotocols []string
-
- // EnableCompression specifies if the client should attempt to negotiate
- // per message compression (RFC 7692). Setting this value to true does not
- // guarantee that compression will be supported. Currently only "no context
- // takeover" modes are supported.
- EnableCompression bool
-
- // Jar specifies the cookie jar.
- // If Jar is nil, cookies are not sent in requests and ignored
- // in responses.
- Jar http.CookieJar
-}
-
-var errMalformedURL = errors.New("malformed ws or wss URL")
-
-// parseURL parses the URL.
-//
-// This function is a replacement for the standard library url.Parse function.
-// In Go 1.4 and earlier, url.Parse loses information from the path.
-func parseURL(s string) (*url.URL, error) {
- // From the RFC:
- //
- // ws-URI = "ws:" "//" host [ ":" port ] path [ "?" query ]
- // wss-URI = "wss:" "//" host [ ":" port ] path [ "?" query ]
- var u url.URL
- switch {
- case strings.HasPrefix(s, "ws://"):
- u.Scheme = "ws"
- s = s[len("ws://"):]
- case strings.HasPrefix(s, "wss://"):
- u.Scheme = "wss"
- s = s[len("wss://"):]
- default:
- return nil, errMalformedURL
- }
-
- if i := strings.Index(s, "?"); i >= 0 {
- u.RawQuery = s[i+1:]
- s = s[:i]
- }
-
- if i := strings.Index(s, "/"); i >= 0 {
- u.Opaque = s[i:]
- s = s[:i]
- } else {
- u.Opaque = "/"
- }
-
- u.Host = s
-
- if strings.Contains(u.Host, "@") {
- // Don't bother parsing user information because user information is
- // not allowed in websocket URIs.
- return nil, errMalformedURL
- }
-
- return &u, nil
-}
-
-func hostPortNoPort(u *url.URL) (hostPort, hostNoPort string) {
- hostPort = u.Host
- hostNoPort = u.Host
- if i := strings.LastIndex(u.Host, ":"); i > strings.LastIndex(u.Host, "]") {
- hostNoPort = hostNoPort[:i]
- } else {
- switch u.Scheme {
- case "wss":
- hostPort += ":443"
- case "https":
- hostPort += ":443"
- default:
- hostPort += ":80"
- }
- }
- return hostPort, hostNoPort
-}
-
-// DefaultDialer is a dialer with all fields set to the default zero values.
-var DefaultDialer = &Dialer{
- Proxy: http.ProxyFromEnvironment,
-}
-
-// Dial creates a new client connection. Use requestHeader to specify the
-// origin (Origin), subprotocols (Sec-WebSocket-Protocol) and cookies (Cookie).
-// Use the response.Header to get the selected subprotocol
-// (Sec-WebSocket-Protocol) and cookies (Set-Cookie).
-//
-// If the WebSocket handshake fails, ErrBadHandshake is returned along with a
-// non-nil *http.Response so that callers can handle redirects, authentication,
-// etcetera. The response body may not contain the entire response and does not
-// need to be closed by the application.
-func (d *Dialer) Dial(urlStr string, requestHeader http.Header) (*Conn, *http.Response, error) {
-
- if d == nil {
- d = &Dialer{
- Proxy: http.ProxyFromEnvironment,
- }
- }
-
- challengeKey, err := generateChallengeKey()
- if err != nil {
- return nil, nil, err
- }
-
- u, err := parseURL(urlStr)
- if err != nil {
- return nil, nil, err
- }
-
- switch u.Scheme {
- case "ws":
- u.Scheme = "http"
- case "wss":
- u.Scheme = "https"
- default:
- return nil, nil, errMalformedURL
- }
-
- if u.User != nil {
- // User name and password are not allowed in websocket URIs.
- return nil, nil, errMalformedURL
- }
-
- req := &http.Request{
- Method: "GET",
- URL: u,
- Proto: "HTTP/1.1",
- ProtoMajor: 1,
- ProtoMinor: 1,
- Header: make(http.Header),
- Host: u.Host,
- }
-
- // Set the cookies present in the cookie jar of the dialer
- if d.Jar != nil {
- for _, cookie := range d.Jar.Cookies(u) {
- req.AddCookie(cookie)
- }
- }
-
- // Set the request headers using the capitalization for names and values in
- // RFC examples. Although the capitalization shouldn't matter, there are
- // servers that depend on it. The Header.Set method is not used because the
- // method canonicalizes the header names.
- req.Header["Upgrade"] = []string{"websocket"}
- req.Header["Connection"] = []string{"Upgrade"}
- req.Header["Sec-WebSocket-Key"] = []string{challengeKey}
- req.Header["Sec-WebSocket-Version"] = []string{"13"}
- if len(d.Subprotocols) > 0 {
- req.Header["Sec-WebSocket-Protocol"] = []string{strings.Join(d.Subprotocols, ", ")}
- }
- for k, vs := range requestHeader {
- switch {
- case k == "Host":
- if len(vs) > 0 {
- req.Host = vs[0]
- }
- case k == "Upgrade" ||
- k == "Connection" ||
- k == "Sec-Websocket-Key" ||
- k == "Sec-Websocket-Version" ||
- k == "Sec-Websocket-Extensions" ||
- (k == "Sec-Websocket-Protocol" && len(d.Subprotocols) > 0):
- return nil, nil, errors.New("websocket: duplicate header not allowed: " + k)
- default:
- req.Header[k] = vs
- }
- }
-
- if d.EnableCompression {
- req.Header.Set("Sec-Websocket-Extensions", "permessage-deflate; server_no_context_takeover; client_no_context_takeover")
- }
-
- hostPort, hostNoPort := hostPortNoPort(u)
-
- var proxyURL *url.URL
- // Check wether the proxy method has been configured
- if d.Proxy != nil {
- proxyURL, err = d.Proxy(req)
- }
- if err != nil {
- return nil, nil, err
- }
-
- var targetHostPort string
- if proxyURL != nil {
- targetHostPort, _ = hostPortNoPort(proxyURL)
- } else {
- targetHostPort = hostPort
- }
-
- var deadline time.Time
- if d.HandshakeTimeout != 0 {
- deadline = time.Now().Add(d.HandshakeTimeout)
- }
-
- netDial := d.NetDial
- if netDial == nil {
- netDialer := &net.Dialer{Deadline: deadline}
- netDial = netDialer.Dial
- }
-
- netConn, err := netDial("tcp", targetHostPort)
- if err != nil {
- return nil, nil, err
- }
-
- defer func() {
- if netConn != nil {
- netConn.Close()
- }
- }()
-
- if err := netConn.SetDeadline(deadline); err != nil {
- return nil, nil, err
- }
-
- if proxyURL != nil {
- connectHeader := make(http.Header)
- if user := proxyURL.User; user != nil {
- proxyUser := user.Username()
- if proxyPassword, passwordSet := user.Password(); passwordSet {
- credential := base64.StdEncoding.EncodeToString([]byte(proxyUser + ":" + proxyPassword))
- connectHeader.Set("Proxy-Authorization", "Basic "+credential)
- }
- }
- connectReq := &http.Request{
- Method: "CONNECT",
- URL: &url.URL{Opaque: hostPort},
- Host: hostPort,
- Header: connectHeader,
- }
-
- connectReq.Write(netConn)
-
- // Read response.
- // Okay to use and discard buffered reader here, because
- // TLS server will not speak until spoken to.
- br := bufio.NewReader(netConn)
- resp, err := http.ReadResponse(br, connectReq)
- if err != nil {
- return nil, nil, err
- }
- if resp.StatusCode != 200 {
- f := strings.SplitN(resp.Status, " ", 2)
- return nil, nil, errors.New(f[1])
- }
- }
-
- if u.Scheme == "https" {
- cfg := cloneTLSConfig(d.TLSClientConfig)
- if cfg.ServerName == "" {
- cfg.ServerName = hostNoPort
- }
- tlsConn := tls.Client(netConn, cfg)
- netConn = tlsConn
- if err := tlsConn.Handshake(); err != nil {
- return nil, nil, err
- }
- if !cfg.InsecureSkipVerify {
- if err := tlsConn.VerifyHostname(cfg.ServerName); err != nil {
- return nil, nil, err
- }
- }
- }
-
- conn := newConn(netConn, false, d.ReadBufferSize, d.WriteBufferSize)
-
- if err := req.Write(netConn); err != nil {
- return nil, nil, err
- }
-
- resp, err := http.ReadResponse(conn.br, req)
- if err != nil {
- return nil, nil, err
- }
-
- if d.Jar != nil {
- if rc := resp.Cookies(); len(rc) > 0 {
- d.Jar.SetCookies(u, rc)
- }
- }
-
- if resp.StatusCode != 101 ||
- !strings.EqualFold(resp.Header.Get("Upgrade"), "websocket") ||
- !strings.EqualFold(resp.Header.Get("Connection"), "upgrade") ||
- resp.Header.Get("Sec-Websocket-Accept") != computeAcceptKey(challengeKey) {
- // Before closing the network connection on return from this
- // function, slurp up some of the response to aid application
- // debugging.
- buf := make([]byte, 1024)
- n, _ := io.ReadFull(resp.Body, buf)
- resp.Body = ioutil.NopCloser(bytes.NewReader(buf[:n]))
- return nil, resp, ErrBadHandshake
- }
-
- for _, ext := range parseExtensions(resp.Header) {
- if ext[""] != "permessage-deflate" {
- continue
- }
- _, snct := ext["server_no_context_takeover"]
- _, cnct := ext["client_no_context_takeover"]
- if !snct || !cnct {
- return nil, resp, errInvalidCompression
- }
- conn.newCompressionWriter = compressNoContextTakeover
- conn.newDecompressionReader = decompressNoContextTakeover
- break
- }
-
- resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{}))
- conn.subprotocol = resp.Header.Get("Sec-Websocket-Protocol")
-
- netConn.SetDeadline(time.Time{})
- netConn = nil // to avoid close in defer.
- return conn, resp, nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone.go
deleted file mode 100644
index 4f0d9437..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone.go
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.8
-
-package websocket
-
-import "crypto/tls"
-
-func cloneTLSConfig(cfg *tls.Config) *tls.Config {
- if cfg == nil {
- return &tls.Config{}
- }
- return cfg.Clone()
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone_legacy.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone_legacy.go
deleted file mode 100644
index babb007f..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/client_clone_legacy.go
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.8
-
-package websocket
-
-import "crypto/tls"
-
-// cloneTLSConfig clones all public fields except the fields
-// SessionTicketsDisabled and SessionTicketKey. This avoids copying the
-// sync.Mutex in the sync.Once and makes it safe to call cloneTLSConfig on a
-// config in active use.
-func cloneTLSConfig(cfg *tls.Config) *tls.Config {
- if cfg == nil {
- return &tls.Config{}
- }
- return &tls.Config{
- Rand: cfg.Rand,
- Time: cfg.Time,
- Certificates: cfg.Certificates,
- NameToCertificate: cfg.NameToCertificate,
- GetCertificate: cfg.GetCertificate,
- RootCAs: cfg.RootCAs,
- NextProtos: cfg.NextProtos,
- ServerName: cfg.ServerName,
- ClientAuth: cfg.ClientAuth,
- ClientCAs: cfg.ClientCAs,
- InsecureSkipVerify: cfg.InsecureSkipVerify,
- CipherSuites: cfg.CipherSuites,
- PreferServerCipherSuites: cfg.PreferServerCipherSuites,
- ClientSessionCache: cfg.ClientSessionCache,
- MinVersion: cfg.MinVersion,
- MaxVersion: cfg.MaxVersion,
- CurvePreferences: cfg.CurvePreferences,
- }
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/compression.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/compression.go
deleted file mode 100644
index 813ffb1e..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/compression.go
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "compress/flate"
- "errors"
- "io"
- "strings"
- "sync"
-)
-
-const (
- minCompressionLevel = -2 // flate.HuffmanOnly not defined in Go < 1.6
- maxCompressionLevel = flate.BestCompression
- defaultCompressionLevel = 1
-)
-
-var (
- flateWriterPools [maxCompressionLevel - minCompressionLevel + 1]sync.Pool
- flateReaderPool = sync.Pool{New: func() interface{} {
- return flate.NewReader(nil)
- }}
-)
-
-func decompressNoContextTakeover(r io.Reader) io.ReadCloser {
- const tail =
- // Add four bytes as specified in RFC
- "\x00\x00\xff\xff" +
- // Add final block to squelch unexpected EOF error from flate reader.
- "\x01\x00\x00\xff\xff"
-
- fr, _ := flateReaderPool.Get().(io.ReadCloser)
- fr.(flate.Resetter).Reset(io.MultiReader(r, strings.NewReader(tail)), nil)
- return &flateReadWrapper{fr}
-}
-
-func isValidCompressionLevel(level int) bool {
- return minCompressionLevel <= level && level <= maxCompressionLevel
-}
-
-func compressNoContextTakeover(w io.WriteCloser, level int) io.WriteCloser {
- p := &flateWriterPools[level-minCompressionLevel]
- tw := &truncWriter{w: w}
- fw, _ := p.Get().(*flate.Writer)
- if fw == nil {
- fw, _ = flate.NewWriter(tw, level)
- } else {
- fw.Reset(tw)
- }
- return &flateWriteWrapper{fw: fw, tw: tw, p: p}
-}
-
-// truncWriter is an io.Writer that writes all but the last four bytes of the
-// stream to another io.Writer.
-type truncWriter struct {
- w io.WriteCloser
- n int
- p [4]byte
-}
-
-func (w *truncWriter) Write(p []byte) (int, error) {
- n := 0
-
- // fill buffer first for simplicity.
- if w.n < len(w.p) {
- n = copy(w.p[w.n:], p)
- p = p[n:]
- w.n += n
- if len(p) == 0 {
- return n, nil
- }
- }
-
- m := len(p)
- if m > len(w.p) {
- m = len(w.p)
- }
-
- if nn, err := w.w.Write(w.p[:m]); err != nil {
- return n + nn, err
- }
-
- copy(w.p[:], w.p[m:])
- copy(w.p[len(w.p)-m:], p[len(p)-m:])
- nn, err := w.w.Write(p[:len(p)-m])
- return n + nn, err
-}
-
-type flateWriteWrapper struct {
- fw *flate.Writer
- tw *truncWriter
- p *sync.Pool
-}
-
-func (w *flateWriteWrapper) Write(p []byte) (int, error) {
- if w.fw == nil {
- return 0, errWriteClosed
- }
- return w.fw.Write(p)
-}
-
-func (w *flateWriteWrapper) Close() error {
- if w.fw == nil {
- return errWriteClosed
- }
- err1 := w.fw.Flush()
- w.p.Put(w.fw)
- w.fw = nil
- if w.tw.p != [4]byte{0, 0, 0xff, 0xff} {
- return errors.New("websocket: internal error, unexpected bytes at end of flate stream")
- }
- err2 := w.tw.w.Close()
- if err1 != nil {
- return err1
- }
- return err2
-}
-
-type flateReadWrapper struct {
- fr io.ReadCloser
-}
-
-func (r *flateReadWrapper) Read(p []byte) (int, error) {
- if r.fr == nil {
- return 0, io.ErrClosedPipe
- }
- n, err := r.fr.Read(p)
- if err == io.EOF {
- // Preemptively place the reader back in the pool. This helps with
- // scenarios where the application does not call NextReader() soon after
- // this final read.
- r.Close()
- }
- return n, err
-}
-
-func (r *flateReadWrapper) Close() error {
- if r.fr == nil {
- return io.ErrClosedPipe
- }
- err := r.fr.Close()
- flateReaderPool.Put(r.fr)
- r.fr = nil
- return err
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn.go
deleted file mode 100644
index 97e1dbac..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn.go
+++ /dev/null
@@ -1,1149 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "bufio"
- "encoding/binary"
- "errors"
- "io"
- "io/ioutil"
- "math/rand"
- "net"
- "strconv"
- "sync"
- "time"
- "unicode/utf8"
-)
-
-const (
- // Frame header byte 0 bits from Section 5.2 of RFC 6455
- finalBit = 1 << 7
- rsv1Bit = 1 << 6
- rsv2Bit = 1 << 5
- rsv3Bit = 1 << 4
-
- // Frame header byte 1 bits from Section 5.2 of RFC 6455
- maskBit = 1 << 7
-
- maxFrameHeaderSize = 2 + 8 + 4 // Fixed header + length + mask
- maxControlFramePayloadSize = 125
-
- writeWait = time.Second
-
- defaultReadBufferSize = 4096
- defaultWriteBufferSize = 4096
-
- continuationFrame = 0
- noFrame = -1
-)
-
-// Close codes defined in RFC 6455, section 11.7.
-const (
- CloseNormalClosure = 1000
- CloseGoingAway = 1001
- CloseProtocolError = 1002
- CloseUnsupportedData = 1003
- CloseNoStatusReceived = 1005
- CloseAbnormalClosure = 1006
- CloseInvalidFramePayloadData = 1007
- ClosePolicyViolation = 1008
- CloseMessageTooBig = 1009
- CloseMandatoryExtension = 1010
- CloseInternalServerErr = 1011
- CloseServiceRestart = 1012
- CloseTryAgainLater = 1013
- CloseTLSHandshake = 1015
-)
-
-// The message types are defined in RFC 6455, section 11.8.
-const (
- // TextMessage denotes a text data message. The text message payload is
- // interpreted as UTF-8 encoded text data.
- TextMessage = 1
-
- // BinaryMessage denotes a binary data message.
- BinaryMessage = 2
-
- // CloseMessage denotes a close control message. The optional message
- // payload contains a numeric code and text. Use the FormatCloseMessage
- // function to format a close message payload.
- CloseMessage = 8
-
- // PingMessage denotes a ping control message. The optional message payload
- // is UTF-8 encoded text.
- PingMessage = 9
-
- // PongMessage denotes a ping control message. The optional message payload
- // is UTF-8 encoded text.
- PongMessage = 10
-)
-
-// ErrCloseSent is returned when the application writes a message to the
-// connection after sending a close message.
-var ErrCloseSent = errors.New("websocket: close sent")
-
-// ErrReadLimit is returned when reading a message that is larger than the
-// read limit set for the connection.
-var ErrReadLimit = errors.New("websocket: read limit exceeded")
-
-// netError satisfies the net Error interface.
-type netError struct {
- msg string
- temporary bool
- timeout bool
-}
-
-func (e *netError) Error() string { return e.msg }
-func (e *netError) Temporary() bool { return e.temporary }
-func (e *netError) Timeout() bool { return e.timeout }
-
-// CloseError represents close frame.
-type CloseError struct {
-
- // Code is defined in RFC 6455, section 11.7.
- Code int
-
- // Text is the optional text payload.
- Text string
-}
-
-func (e *CloseError) Error() string {
- s := []byte("websocket: close ")
- s = strconv.AppendInt(s, int64(e.Code), 10)
- switch e.Code {
- case CloseNormalClosure:
- s = append(s, " (normal)"...)
- case CloseGoingAway:
- s = append(s, " (going away)"...)
- case CloseProtocolError:
- s = append(s, " (protocol error)"...)
- case CloseUnsupportedData:
- s = append(s, " (unsupported data)"...)
- case CloseNoStatusReceived:
- s = append(s, " (no status)"...)
- case CloseAbnormalClosure:
- s = append(s, " (abnormal closure)"...)
- case CloseInvalidFramePayloadData:
- s = append(s, " (invalid payload data)"...)
- case ClosePolicyViolation:
- s = append(s, " (policy violation)"...)
- case CloseMessageTooBig:
- s = append(s, " (message too big)"...)
- case CloseMandatoryExtension:
- s = append(s, " (mandatory extension missing)"...)
- case CloseInternalServerErr:
- s = append(s, " (internal server error)"...)
- case CloseTLSHandshake:
- s = append(s, " (TLS handshake error)"...)
- }
- if e.Text != "" {
- s = append(s, ": "...)
- s = append(s, e.Text...)
- }
- return string(s)
-}
-
-// IsCloseError returns boolean indicating whether the error is a *CloseError
-// with one of the specified codes.
-func IsCloseError(err error, codes ...int) bool {
- if e, ok := err.(*CloseError); ok {
- for _, code := range codes {
- if e.Code == code {
- return true
- }
- }
- }
- return false
-}
-
-// IsUnexpectedCloseError returns boolean indicating whether the error is a
-// *CloseError with a code not in the list of expected codes.
-func IsUnexpectedCloseError(err error, expectedCodes ...int) bool {
- if e, ok := err.(*CloseError); ok {
- for _, code := range expectedCodes {
- if e.Code == code {
- return false
- }
- }
- return true
- }
- return false
-}
-
-var (
- errWriteTimeout = &netError{msg: "websocket: write timeout", timeout: true, temporary: true}
- errUnexpectedEOF = &CloseError{Code: CloseAbnormalClosure, Text: io.ErrUnexpectedEOF.Error()}
- errBadWriteOpCode = errors.New("websocket: bad write message type")
- errWriteClosed = errors.New("websocket: write closed")
- errInvalidControlFrame = errors.New("websocket: invalid control frame")
-)
-
-func newMaskKey() [4]byte {
- n := rand.Uint32()
- return [4]byte{byte(n), byte(n >> 8), byte(n >> 16), byte(n >> 24)}
-}
-
-func hideTempErr(err error) error {
- if e, ok := err.(net.Error); ok && e.Temporary() {
- err = &netError{msg: e.Error(), timeout: e.Timeout()}
- }
- return err
-}
-
-func isControl(frameType int) bool {
- return frameType == CloseMessage || frameType == PingMessage || frameType == PongMessage
-}
-
-func isData(frameType int) bool {
- return frameType == TextMessage || frameType == BinaryMessage
-}
-
-var validReceivedCloseCodes = map[int]bool{
- // see http://www.iana.org/assignments/websocket/websocket.xhtml#close-code-number
-
- CloseNormalClosure: true,
- CloseGoingAway: true,
- CloseProtocolError: true,
- CloseUnsupportedData: true,
- CloseNoStatusReceived: false,
- CloseAbnormalClosure: false,
- CloseInvalidFramePayloadData: true,
- ClosePolicyViolation: true,
- CloseMessageTooBig: true,
- CloseMandatoryExtension: true,
- CloseInternalServerErr: true,
- CloseServiceRestart: true,
- CloseTryAgainLater: true,
- CloseTLSHandshake: false,
-}
-
-func isValidReceivedCloseCode(code int) bool {
- return validReceivedCloseCodes[code] || (code >= 3000 && code <= 4999)
-}
-
-// The Conn type represents a WebSocket connection.
-type Conn struct {
- conn net.Conn
- isServer bool
- subprotocol string
-
- // Write fields
- mu chan bool // used as mutex to protect write to conn
- writeBuf []byte // frame is constructed in this buffer.
- writeDeadline time.Time
- writer io.WriteCloser // the current writer returned to the application
- isWriting bool // for best-effort concurrent write detection
-
- writeErrMu sync.Mutex
- writeErr error
-
- enableWriteCompression bool
- compressionLevel int
- newCompressionWriter func(io.WriteCloser, int) io.WriteCloser
-
- // Read fields
- reader io.ReadCloser // the current reader returned to the application
- readErr error
- br *bufio.Reader
- readRemaining int64 // bytes remaining in current frame.
- readFinal bool // true the current message has more frames.
- readLength int64 // Message size.
- readLimit int64 // Maximum message size.
- readMaskPos int
- readMaskKey [4]byte
- handlePong func(string) error
- handlePing func(string) error
- handleClose func(int, string) error
- readErrCount int
- messageReader *messageReader // the current low-level reader
-
- readDecompress bool // whether last read frame had RSV1 set
- newDecompressionReader func(io.Reader) io.ReadCloser
-}
-
-func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int) *Conn {
- return newConnBRW(conn, isServer, readBufferSize, writeBufferSize, nil)
-}
-
-type writeHook struct {
- p []byte
-}
-
-func (wh *writeHook) Write(p []byte) (int, error) {
- wh.p = p
- return len(p), nil
-}
-
-func newConnBRW(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, brw *bufio.ReadWriter) *Conn {
- mu := make(chan bool, 1)
- mu <- true
-
- var br *bufio.Reader
- if readBufferSize == 0 && brw != nil && brw.Reader != nil {
- // Reuse the supplied bufio.Reader if the buffer has a useful size.
- // This code assumes that peek on a reader returns
- // bufio.Reader.buf[:0].
- brw.Reader.Reset(conn)
- if p, err := brw.Reader.Peek(0); err == nil && cap(p) >= 256 {
- br = brw.Reader
- }
- }
- if br == nil {
- if readBufferSize == 0 {
- readBufferSize = defaultReadBufferSize
- }
- if readBufferSize < maxControlFramePayloadSize {
- readBufferSize = maxControlFramePayloadSize
- }
- br = bufio.NewReaderSize(conn, readBufferSize)
- }
-
- var writeBuf []byte
- if writeBufferSize == 0 && brw != nil && brw.Writer != nil {
- // Use the bufio.Writer's buffer if the buffer has a useful size. This
- // code assumes that bufio.Writer.buf[:1] is passed to the
- // bufio.Writer's underlying writer.
- var wh writeHook
- brw.Writer.Reset(&wh)
- brw.Writer.WriteByte(0)
- brw.Flush()
- if cap(wh.p) >= maxFrameHeaderSize+256 {
- writeBuf = wh.p[:cap(wh.p)]
- }
- }
-
- if writeBuf == nil {
- if writeBufferSize == 0 {
- writeBufferSize = defaultWriteBufferSize
- }
- writeBuf = make([]byte, writeBufferSize+maxFrameHeaderSize)
- }
-
- c := &Conn{
- isServer: isServer,
- br: br,
- conn: conn,
- mu: mu,
- readFinal: true,
- writeBuf: writeBuf,
- enableWriteCompression: true,
- compressionLevel: defaultCompressionLevel,
- }
- c.SetCloseHandler(nil)
- c.SetPingHandler(nil)
- c.SetPongHandler(nil)
- return c
-}
-
-// Subprotocol returns the negotiated protocol for the connection.
-func (c *Conn) Subprotocol() string {
- return c.subprotocol
-}
-
-// Close closes the underlying network connection without sending or waiting for a close frame.
-func (c *Conn) Close() error {
- return c.conn.Close()
-}
-
-// LocalAddr returns the local network address.
-func (c *Conn) LocalAddr() net.Addr {
- return c.conn.LocalAddr()
-}
-
-// RemoteAddr returns the remote network address.
-func (c *Conn) RemoteAddr() net.Addr {
- return c.conn.RemoteAddr()
-}
-
-// Write methods
-
-func (c *Conn) writeFatal(err error) error {
- err = hideTempErr(err)
- c.writeErrMu.Lock()
- if c.writeErr == nil {
- c.writeErr = err
- }
- c.writeErrMu.Unlock()
- return err
-}
-
-func (c *Conn) write(frameType int, deadline time.Time, bufs ...[]byte) error {
- <-c.mu
- defer func() { c.mu <- true }()
-
- c.writeErrMu.Lock()
- err := c.writeErr
- c.writeErrMu.Unlock()
- if err != nil {
- return err
- }
-
- c.conn.SetWriteDeadline(deadline)
- for _, buf := range bufs {
- if len(buf) > 0 {
- _, err := c.conn.Write(buf)
- if err != nil {
- return c.writeFatal(err)
- }
- }
- }
-
- if frameType == CloseMessage {
- c.writeFatal(ErrCloseSent)
- }
- return nil
-}
-
-// WriteControl writes a control message with the given deadline. The allowed
-// message types are CloseMessage, PingMessage and PongMessage.
-func (c *Conn) WriteControl(messageType int, data []byte, deadline time.Time) error {
- if !isControl(messageType) {
- return errBadWriteOpCode
- }
- if len(data) > maxControlFramePayloadSize {
- return errInvalidControlFrame
- }
-
- b0 := byte(messageType) | finalBit
- b1 := byte(len(data))
- if !c.isServer {
- b1 |= maskBit
- }
-
- buf := make([]byte, 0, maxFrameHeaderSize+maxControlFramePayloadSize)
- buf = append(buf, b0, b1)
-
- if c.isServer {
- buf = append(buf, data...)
- } else {
- key := newMaskKey()
- buf = append(buf, key[:]...)
- buf = append(buf, data...)
- maskBytes(key, 0, buf[6:])
- }
-
- d := time.Hour * 1000
- if !deadline.IsZero() {
- d = deadline.Sub(time.Now())
- if d < 0 {
- return errWriteTimeout
- }
- }
-
- timer := time.NewTimer(d)
- select {
- case <-c.mu:
- timer.Stop()
- case <-timer.C:
- return errWriteTimeout
- }
- defer func() { c.mu <- true }()
-
- c.writeErrMu.Lock()
- err := c.writeErr
- c.writeErrMu.Unlock()
- if err != nil {
- return err
- }
-
- c.conn.SetWriteDeadline(deadline)
- _, err = c.conn.Write(buf)
- if err != nil {
- return c.writeFatal(err)
- }
- if messageType == CloseMessage {
- c.writeFatal(ErrCloseSent)
- }
- return err
-}
-
-func (c *Conn) prepWrite(messageType int) error {
- // Close previous writer if not already closed by the application. It's
- // probably better to return an error in this situation, but we cannot
- // change this without breaking existing applications.
- if c.writer != nil {
- c.writer.Close()
- c.writer = nil
- }
-
- if !isControl(messageType) && !isData(messageType) {
- return errBadWriteOpCode
- }
-
- c.writeErrMu.Lock()
- err := c.writeErr
- c.writeErrMu.Unlock()
- return err
-}
-
-// NextWriter returns a writer for the next message to send. The writer's Close
-// method flushes the complete message to the network.
-//
-// There can be at most one open writer on a connection. NextWriter closes the
-// previous writer if the application has not already done so.
-func (c *Conn) NextWriter(messageType int) (io.WriteCloser, error) {
- if err := c.prepWrite(messageType); err != nil {
- return nil, err
- }
-
- mw := &messageWriter{
- c: c,
- frameType: messageType,
- pos: maxFrameHeaderSize,
- }
- c.writer = mw
- if c.newCompressionWriter != nil && c.enableWriteCompression && isData(messageType) {
- w := c.newCompressionWriter(c.writer, c.compressionLevel)
- mw.compress = true
- c.writer = w
- }
- return c.writer, nil
-}
-
-type messageWriter struct {
- c *Conn
- compress bool // whether next call to flushFrame should set RSV1
- pos int // end of data in writeBuf.
- frameType int // type of the current frame.
- err error
-}
-
-func (w *messageWriter) fatal(err error) error {
- if w.err != nil {
- w.err = err
- w.c.writer = nil
- }
- return err
-}
-
-// flushFrame writes buffered data and extra as a frame to the network. The
-// final argument indicates that this is the last frame in the message.
-func (w *messageWriter) flushFrame(final bool, extra []byte) error {
- c := w.c
- length := w.pos - maxFrameHeaderSize + len(extra)
-
- // Check for invalid control frames.
- if isControl(w.frameType) &&
- (!final || length > maxControlFramePayloadSize) {
- return w.fatal(errInvalidControlFrame)
- }
-
- b0 := byte(w.frameType)
- if final {
- b0 |= finalBit
- }
- if w.compress {
- b0 |= rsv1Bit
- }
- w.compress = false
-
- b1 := byte(0)
- if !c.isServer {
- b1 |= maskBit
- }
-
- // Assume that the frame starts at beginning of c.writeBuf.
- framePos := 0
- if c.isServer {
- // Adjust up if mask not included in the header.
- framePos = 4
- }
-
- switch {
- case length >= 65536:
- c.writeBuf[framePos] = b0
- c.writeBuf[framePos+1] = b1 | 127
- binary.BigEndian.PutUint64(c.writeBuf[framePos+2:], uint64(length))
- case length > 125:
- framePos += 6
- c.writeBuf[framePos] = b0
- c.writeBuf[framePos+1] = b1 | 126
- binary.BigEndian.PutUint16(c.writeBuf[framePos+2:], uint16(length))
- default:
- framePos += 8
- c.writeBuf[framePos] = b0
- c.writeBuf[framePos+1] = b1 | byte(length)
- }
-
- if !c.isServer {
- key := newMaskKey()
- copy(c.writeBuf[maxFrameHeaderSize-4:], key[:])
- maskBytes(key, 0, c.writeBuf[maxFrameHeaderSize:w.pos])
- if len(extra) > 0 {
- return c.writeFatal(errors.New("websocket: internal error, extra used in client mode"))
- }
- }
-
- // Write the buffers to the connection with best-effort detection of
- // concurrent writes. See the concurrency section in the package
- // documentation for more info.
-
- if c.isWriting {
- panic("concurrent write to websocket connection")
- }
- c.isWriting = true
-
- err := c.write(w.frameType, c.writeDeadline, c.writeBuf[framePos:w.pos], extra)
-
- if !c.isWriting {
- panic("concurrent write to websocket connection")
- }
- c.isWriting = false
-
- if err != nil {
- return w.fatal(err)
- }
-
- if final {
- c.writer = nil
- return nil
- }
-
- // Setup for next frame.
- w.pos = maxFrameHeaderSize
- w.frameType = continuationFrame
- return nil
-}
-
-func (w *messageWriter) ncopy(max int) (int, error) {
- n := len(w.c.writeBuf) - w.pos
- if n <= 0 {
- if err := w.flushFrame(false, nil); err != nil {
- return 0, err
- }
- n = len(w.c.writeBuf) - w.pos
- }
- if n > max {
- n = max
- }
- return n, nil
-}
-
-func (w *messageWriter) Write(p []byte) (int, error) {
- if w.err != nil {
- return 0, w.err
- }
-
- if len(p) > 2*len(w.c.writeBuf) && w.c.isServer {
- // Don't buffer large messages.
- err := w.flushFrame(false, p)
- if err != nil {
- return 0, err
- }
- return len(p), nil
- }
-
- nn := len(p)
- for len(p) > 0 {
- n, err := w.ncopy(len(p))
- if err != nil {
- return 0, err
- }
- copy(w.c.writeBuf[w.pos:], p[:n])
- w.pos += n
- p = p[n:]
- }
- return nn, nil
-}
-
-func (w *messageWriter) WriteString(p string) (int, error) {
- if w.err != nil {
- return 0, w.err
- }
-
- nn := len(p)
- for len(p) > 0 {
- n, err := w.ncopy(len(p))
- if err != nil {
- return 0, err
- }
- copy(w.c.writeBuf[w.pos:], p[:n])
- w.pos += n
- p = p[n:]
- }
- return nn, nil
-}
-
-func (w *messageWriter) ReadFrom(r io.Reader) (nn int64, err error) {
- if w.err != nil {
- return 0, w.err
- }
- for {
- if w.pos == len(w.c.writeBuf) {
- err = w.flushFrame(false, nil)
- if err != nil {
- break
- }
- }
- var n int
- n, err = r.Read(w.c.writeBuf[w.pos:])
- w.pos += n
- nn += int64(n)
- if err != nil {
- if err == io.EOF {
- err = nil
- }
- break
- }
- }
- return nn, err
-}
-
-func (w *messageWriter) Close() error {
- if w.err != nil {
- return w.err
- }
- if err := w.flushFrame(true, nil); err != nil {
- return err
- }
- w.err = errWriteClosed
- return nil
-}
-
-// WritePreparedMessage writes prepared message into connection.
-func (c *Conn) WritePreparedMessage(pm *PreparedMessage) error {
- frameType, frameData, err := pm.frame(prepareKey{
- isServer: c.isServer,
- compress: c.newCompressionWriter != nil && c.enableWriteCompression && isData(pm.messageType),
- compressionLevel: c.compressionLevel,
- })
- if err != nil {
- return err
- }
- if c.isWriting {
- panic("concurrent write to websocket connection")
- }
- c.isWriting = true
- err = c.write(frameType, c.writeDeadline, frameData, nil)
- if !c.isWriting {
- panic("concurrent write to websocket connection")
- }
- c.isWriting = false
- return err
-}
-
-// WriteMessage is a helper method for getting a writer using NextWriter,
-// writing the message and closing the writer.
-func (c *Conn) WriteMessage(messageType int, data []byte) error {
-
- if c.isServer && (c.newCompressionWriter == nil || !c.enableWriteCompression) {
- // Fast path with no allocations and single frame.
-
- if err := c.prepWrite(messageType); err != nil {
- return err
- }
- mw := messageWriter{c: c, frameType: messageType, pos: maxFrameHeaderSize}
- n := copy(c.writeBuf[mw.pos:], data)
- mw.pos += n
- data = data[n:]
- return mw.flushFrame(true, data)
- }
-
- w, err := c.NextWriter(messageType)
- if err != nil {
- return err
- }
- if _, err = w.Write(data); err != nil {
- return err
- }
- return w.Close()
-}
-
-// SetWriteDeadline sets the write deadline on the underlying network
-// connection. After a write has timed out, the websocket state is corrupt and
-// all future writes will return an error. A zero value for t means writes will
-// not time out.
-func (c *Conn) SetWriteDeadline(t time.Time) error {
- c.writeDeadline = t
- return nil
-}
-
-// Read methods
-
-func (c *Conn) advanceFrame() (int, error) {
-
- // 1. Skip remainder of previous frame.
-
- if c.readRemaining > 0 {
- if _, err := io.CopyN(ioutil.Discard, c.br, c.readRemaining); err != nil {
- return noFrame, err
- }
- }
-
- // 2. Read and parse first two bytes of frame header.
-
- p, err := c.read(2)
- if err != nil {
- return noFrame, err
- }
-
- final := p[0]&finalBit != 0
- frameType := int(p[0] & 0xf)
- mask := p[1]&maskBit != 0
- c.readRemaining = int64(p[1] & 0x7f)
-
- c.readDecompress = false
- if c.newDecompressionReader != nil && (p[0]&rsv1Bit) != 0 {
- c.readDecompress = true
- p[0] &^= rsv1Bit
- }
-
- if rsv := p[0] & (rsv1Bit | rsv2Bit | rsv3Bit); rsv != 0 {
- return noFrame, c.handleProtocolError("unexpected reserved bits 0x" + strconv.FormatInt(int64(rsv), 16))
- }
-
- switch frameType {
- case CloseMessage, PingMessage, PongMessage:
- if c.readRemaining > maxControlFramePayloadSize {
- return noFrame, c.handleProtocolError("control frame length > 125")
- }
- if !final {
- return noFrame, c.handleProtocolError("control frame not final")
- }
- case TextMessage, BinaryMessage:
- if !c.readFinal {
- return noFrame, c.handleProtocolError("message start before final message frame")
- }
- c.readFinal = final
- case continuationFrame:
- if c.readFinal {
- return noFrame, c.handleProtocolError("continuation after final message frame")
- }
- c.readFinal = final
- default:
- return noFrame, c.handleProtocolError("unknown opcode " + strconv.Itoa(frameType))
- }
-
- // 3. Read and parse frame length.
-
- switch c.readRemaining {
- case 126:
- p, err := c.read(2)
- if err != nil {
- return noFrame, err
- }
- c.readRemaining = int64(binary.BigEndian.Uint16(p))
- case 127:
- p, err := c.read(8)
- if err != nil {
- return noFrame, err
- }
- c.readRemaining = int64(binary.BigEndian.Uint64(p))
- }
-
- // 4. Handle frame masking.
-
- if mask != c.isServer {
- return noFrame, c.handleProtocolError("incorrect mask flag")
- }
-
- if mask {
- c.readMaskPos = 0
- p, err := c.read(len(c.readMaskKey))
- if err != nil {
- return noFrame, err
- }
- copy(c.readMaskKey[:], p)
- }
-
- // 5. For text and binary messages, enforce read limit and return.
-
- if frameType == continuationFrame || frameType == TextMessage || frameType == BinaryMessage {
-
- c.readLength += c.readRemaining
- if c.readLimit > 0 && c.readLength > c.readLimit {
- c.WriteControl(CloseMessage, FormatCloseMessage(CloseMessageTooBig, ""), time.Now().Add(writeWait))
- return noFrame, ErrReadLimit
- }
-
- return frameType, nil
- }
-
- // 6. Read control frame payload.
-
- var payload []byte
- if c.readRemaining > 0 {
- payload, err = c.read(int(c.readRemaining))
- c.readRemaining = 0
- if err != nil {
- return noFrame, err
- }
- if c.isServer {
- maskBytes(c.readMaskKey, 0, payload)
- }
- }
-
- // 7. Process control frame payload.
-
- switch frameType {
- case PongMessage:
- if err := c.handlePong(string(payload)); err != nil {
- return noFrame, err
- }
- case PingMessage:
- if err := c.handlePing(string(payload)); err != nil {
- return noFrame, err
- }
- case CloseMessage:
- closeCode := CloseNoStatusReceived
- closeText := ""
- if len(payload) >= 2 {
- closeCode = int(binary.BigEndian.Uint16(payload))
- if !isValidReceivedCloseCode(closeCode) {
- return noFrame, c.handleProtocolError("invalid close code")
- }
- closeText = string(payload[2:])
- if !utf8.ValidString(closeText) {
- return noFrame, c.handleProtocolError("invalid utf8 payload in close frame")
- }
- }
- if err := c.handleClose(closeCode, closeText); err != nil {
- return noFrame, err
- }
- return noFrame, &CloseError{Code: closeCode, Text: closeText}
- }
-
- return frameType, nil
-}
-
-func (c *Conn) handleProtocolError(message string) error {
- c.WriteControl(CloseMessage, FormatCloseMessage(CloseProtocolError, message), time.Now().Add(writeWait))
- return errors.New("websocket: " + message)
-}
-
-// NextReader returns the next data message received from the peer. The
-// returned messageType is either TextMessage or BinaryMessage.
-//
-// There can be at most one open reader on a connection. NextReader discards
-// the previous message if the application has not already consumed it.
-//
-// Applications must break out of the application's read loop when this method
-// returns a non-nil error value. Errors returned from this method are
-// permanent. Once this method returns a non-nil error, all subsequent calls to
-// this method return the same error.
-func (c *Conn) NextReader() (messageType int, r io.Reader, err error) {
- // Close previous reader, only relevant for decompression.
- if c.reader != nil {
- c.reader.Close()
- c.reader = nil
- }
-
- c.messageReader = nil
- c.readLength = 0
-
- for c.readErr == nil {
- frameType, err := c.advanceFrame()
- if err != nil {
- c.readErr = hideTempErr(err)
- break
- }
- if frameType == TextMessage || frameType == BinaryMessage {
- c.messageReader = &messageReader{c}
- c.reader = c.messageReader
- if c.readDecompress {
- c.reader = c.newDecompressionReader(c.reader)
- }
- return frameType, c.reader, nil
- }
- }
-
- // Applications that do handle the error returned from this method spin in
- // tight loop on connection failure. To help application developers detect
- // this error, panic on repeated reads to the failed connection.
- c.readErrCount++
- if c.readErrCount >= 1000 {
- panic("repeated read on failed websocket connection")
- }
-
- return noFrame, nil, c.readErr
-}
-
-type messageReader struct{ c *Conn }
-
-func (r *messageReader) Read(b []byte) (int, error) {
- c := r.c
- if c.messageReader != r {
- return 0, io.EOF
- }
-
- for c.readErr == nil {
-
- if c.readRemaining > 0 {
- if int64(len(b)) > c.readRemaining {
- b = b[:c.readRemaining]
- }
- n, err := c.br.Read(b)
- c.readErr = hideTempErr(err)
- if c.isServer {
- c.readMaskPos = maskBytes(c.readMaskKey, c.readMaskPos, b[:n])
- }
- c.readRemaining -= int64(n)
- if c.readRemaining > 0 && c.readErr == io.EOF {
- c.readErr = errUnexpectedEOF
- }
- return n, c.readErr
- }
-
- if c.readFinal {
- c.messageReader = nil
- return 0, io.EOF
- }
-
- frameType, err := c.advanceFrame()
- switch {
- case err != nil:
- c.readErr = hideTempErr(err)
- case frameType == TextMessage || frameType == BinaryMessage:
- c.readErr = errors.New("websocket: internal error, unexpected text or binary in Reader")
- }
- }
-
- err := c.readErr
- if err == io.EOF && c.messageReader == r {
- err = errUnexpectedEOF
- }
- return 0, err
-}
-
-func (r *messageReader) Close() error {
- return nil
-}
-
-// ReadMessage is a helper method for getting a reader using NextReader and
-// reading from that reader to a buffer.
-func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
- var r io.Reader
- messageType, r, err = c.NextReader()
- if err != nil {
- return messageType, nil, err
- }
- p, err = ioutil.ReadAll(r)
- return messageType, p, err
-}
-
-// SetReadDeadline sets the read deadline on the underlying network connection.
-// After a read has timed out, the websocket connection state is corrupt and
-// all future reads will return an error. A zero value for t means reads will
-// not time out.
-func (c *Conn) SetReadDeadline(t time.Time) error {
- return c.conn.SetReadDeadline(t)
-}
-
-// SetReadLimit sets the maximum size for a message read from the peer. If a
-// message exceeds the limit, the connection sends a close frame to the peer
-// and returns ErrReadLimit to the application.
-func (c *Conn) SetReadLimit(limit int64) {
- c.readLimit = limit
-}
-
-// CloseHandler returns the current close handler
-func (c *Conn) CloseHandler() func(code int, text string) error {
- return c.handleClose
-}
-
-// SetCloseHandler sets the handler for close messages received from the peer.
-// The code argument to h is the received close code or CloseNoStatusReceived
-// if the close message is empty. The default close handler sends a close frame
-// back to the peer.
-//
-// The application must read the connection to process close messages as
-// described in the section on Control Frames above.
-//
-// The connection read methods return a CloseError when a close frame is
-// received. Most applications should handle close messages as part of their
-// normal error handling. Applications should only set a close handler when the
-// application must perform some action before sending a close frame back to
-// the peer.
-func (c *Conn) SetCloseHandler(h func(code int, text string) error) {
- if h == nil {
- h = func(code int, text string) error {
- message := []byte{}
- if code != CloseNoStatusReceived {
- message = FormatCloseMessage(code, "")
- }
- c.WriteControl(CloseMessage, message, time.Now().Add(writeWait))
- return nil
- }
- }
- c.handleClose = h
-}
-
-// PingHandler returns the current ping handler
-func (c *Conn) PingHandler() func(appData string) error {
- return c.handlePing
-}
-
-// SetPingHandler sets the handler for ping messages received from the peer.
-// The appData argument to h is the PING frame application data. The default
-// ping handler sends a pong to the peer.
-//
-// The application must read the connection to process ping messages as
-// described in the section on Control Frames above.
-func (c *Conn) SetPingHandler(h func(appData string) error) {
- if h == nil {
- h = func(message string) error {
- err := c.WriteControl(PongMessage, []byte(message), time.Now().Add(writeWait))
- if err == ErrCloseSent {
- return nil
- } else if e, ok := err.(net.Error); ok && e.Temporary() {
- return nil
- }
- return err
- }
- }
- c.handlePing = h
-}
-
-// PongHandler returns the current pong handler
-func (c *Conn) PongHandler() func(appData string) error {
- return c.handlePong
-}
-
-// SetPongHandler sets the handler for pong messages received from the peer.
-// The appData argument to h is the PONG frame application data. The default
-// pong handler does nothing.
-//
-// The application must read the connection to process ping messages as
-// described in the section on Control Frames above.
-func (c *Conn) SetPongHandler(h func(appData string) error) {
- if h == nil {
- h = func(string) error { return nil }
- }
- c.handlePong = h
-}
-
-// UnderlyingConn returns the internal net.Conn. This can be used to further
-// modifications to connection specific flags.
-func (c *Conn) UnderlyingConn() net.Conn {
- return c.conn
-}
-
-// EnableWriteCompression enables and disables write compression of
-// subsequent text and binary messages. This function is a noop if
-// compression was not negotiated with the peer.
-func (c *Conn) EnableWriteCompression(enable bool) {
- c.enableWriteCompression = enable
-}
-
-// SetCompressionLevel sets the flate compression level for subsequent text and
-// binary messages. This function is a noop if compression was not negotiated
-// with the peer. See the compress/flate package for a description of
-// compression levels.
-func (c *Conn) SetCompressionLevel(level int) error {
- if !isValidCompressionLevel(level) {
- return errors.New("websocket: invalid compression level")
- }
- c.compressionLevel = level
- return nil
-}
-
-// FormatCloseMessage formats closeCode and text as a WebSocket close message.
-func FormatCloseMessage(closeCode int, text string) []byte {
- buf := make([]byte, 2+len(text))
- binary.BigEndian.PutUint16(buf, uint16(closeCode))
- copy(buf[2:], text)
- return buf
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read.go
deleted file mode 100644
index 1ea15059..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read.go
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build go1.5
-
-package websocket
-
-import "io"
-
-func (c *Conn) read(n int) ([]byte, error) {
- p, err := c.br.Peek(n)
- if err == io.EOF {
- err = errUnexpectedEOF
- }
- c.br.Discard(len(p))
- return p, err
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read_legacy.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read_legacy.go
deleted file mode 100644
index 018541cf..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/conn_read_legacy.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build !go1.5
-
-package websocket
-
-import "io"
-
-func (c *Conn) read(n int) ([]byte, error) {
- p, err := c.br.Peek(n)
- if err == io.EOF {
- err = errUnexpectedEOF
- }
- if len(p) > 0 {
- // advance over the bytes just read
- io.ReadFull(c.br, p)
- }
- return p, err
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/doc.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/doc.go
deleted file mode 100644
index e291a952..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/doc.go
+++ /dev/null
@@ -1,180 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package websocket implements the WebSocket protocol defined in RFC 6455.
-//
-// Overview
-//
-// The Conn type represents a WebSocket connection. A server application uses
-// the Upgrade function from an Upgrader object with a HTTP request handler
-// to get a pointer to a Conn:
-//
-// var upgrader = websocket.Upgrader{
-// ReadBufferSize: 1024,
-// WriteBufferSize: 1024,
-// }
-//
-// func handler(w http.ResponseWriter, r *http.Request) {
-// conn, err := upgrader.Upgrade(w, r, nil)
-// if err != nil {
-// log.Println(err)
-// return
-// }
-// ... Use conn to send and receive messages.
-// }
-//
-// Call the connection's WriteMessage and ReadMessage methods to send and
-// receive messages as a slice of bytes. This snippet of code shows how to echo
-// messages using these methods:
-//
-// for {
-// messageType, p, err := conn.ReadMessage()
-// if err != nil {
-// return
-// }
-// if err = conn.WriteMessage(messageType, p); err != nil {
-// return err
-// }
-// }
-//
-// In above snippet of code, p is a []byte and messageType is an int with value
-// websocket.BinaryMessage or websocket.TextMessage.
-//
-// An application can also send and receive messages using the io.WriteCloser
-// and io.Reader interfaces. To send a message, call the connection NextWriter
-// method to get an io.WriteCloser, write the message to the writer and close
-// the writer when done. To receive a message, call the connection NextReader
-// method to get an io.Reader and read until io.EOF is returned. This snippet
-// shows how to echo messages using the NextWriter and NextReader methods:
-//
-// for {
-// messageType, r, err := conn.NextReader()
-// if err != nil {
-// return
-// }
-// w, err := conn.NextWriter(messageType)
-// if err != nil {
-// return err
-// }
-// if _, err := io.Copy(w, r); err != nil {
-// return err
-// }
-// if err := w.Close(); err != nil {
-// return err
-// }
-// }
-//
-// Data Messages
-//
-// The WebSocket protocol distinguishes between text and binary data messages.
-// Text messages are interpreted as UTF-8 encoded text. The interpretation of
-// binary messages is left to the application.
-//
-// This package uses the TextMessage and BinaryMessage integer constants to
-// identify the two data message types. The ReadMessage and NextReader methods
-// return the type of the received message. The messageType argument to the
-// WriteMessage and NextWriter methods specifies the type of a sent message.
-//
-// It is the application's responsibility to ensure that text messages are
-// valid UTF-8 encoded text.
-//
-// Control Messages
-//
-// The WebSocket protocol defines three types of control messages: close, ping
-// and pong. Call the connection WriteControl, WriteMessage or NextWriter
-// methods to send a control message to the peer.
-//
-// Connections handle received close messages by sending a close message to the
-// peer and returning a *CloseError from the the NextReader, ReadMessage or the
-// message Read method.
-//
-// Connections handle received ping and pong messages by invoking callback
-// functions set with SetPingHandler and SetPongHandler methods. The callback
-// functions are called from the NextReader, ReadMessage and the message Read
-// methods.
-//
-// The default ping handler sends a pong to the peer. The application's reading
-// goroutine can block for a short time while the handler writes the pong data
-// to the connection.
-//
-// The application must read the connection to process ping, pong and close
-// messages sent from the peer. If the application is not otherwise interested
-// in messages from the peer, then the application should start a goroutine to
-// read and discard messages from the peer. A simple example is:
-//
-// func readLoop(c *websocket.Conn) {
-// for {
-// if _, _, err := c.NextReader(); err != nil {
-// c.Close()
-// break
-// }
-// }
-// }
-//
-// Concurrency
-//
-// Connections support one concurrent reader and one concurrent writer.
-//
-// Applications are responsible for ensuring that no more than one goroutine
-// calls the write methods (NextWriter, SetWriteDeadline, WriteMessage,
-// WriteJSON, EnableWriteCompression, SetCompressionLevel) concurrently and
-// that no more than one goroutine calls the read methods (NextReader,
-// SetReadDeadline, ReadMessage, ReadJSON, SetPongHandler, SetPingHandler)
-// concurrently.
-//
-// The Close and WriteControl methods can be called concurrently with all other
-// methods.
-//
-// Origin Considerations
-//
-// Web browsers allow Javascript applications to open a WebSocket connection to
-// any host. It's up to the server to enforce an origin policy using the Origin
-// request header sent by the browser.
-//
-// The Upgrader calls the function specified in the CheckOrigin field to check
-// the origin. If the CheckOrigin function returns false, then the Upgrade
-// method fails the WebSocket handshake with HTTP status 403.
-//
-// If the CheckOrigin field is nil, then the Upgrader uses a safe default: fail
-// the handshake if the Origin request header is present and not equal to the
-// Host request header.
-//
-// An application can allow connections from any origin by specifying a
-// function that always returns true:
-//
-// var upgrader = websocket.Upgrader{
-// CheckOrigin: func(r *http.Request) bool { return true },
-// }
-//
-// The deprecated Upgrade function does not enforce an origin policy. It's the
-// application's responsibility to check the Origin header before calling
-// Upgrade.
-//
-// Compression EXPERIMENTAL
-//
-// Per message compression extensions (RFC 7692) are experimentally supported
-// by this package in a limited capacity. Setting the EnableCompression option
-// to true in Dialer or Upgrader will attempt to negotiate per message deflate
-// support.
-//
-// var upgrader = websocket.Upgrader{
-// EnableCompression: true,
-// }
-//
-// If compression was successfully negotiated with the connection's peer, any
-// message received in compressed form will be automatically decompressed.
-// All Read methods will return uncompressed bytes.
-//
-// Per message compression of messages written to a connection can be enabled
-// or disabled by calling the corresponding Conn method:
-//
-// conn.EnableWriteCompression(false)
-//
-// Currently this package does not support compression with "context takeover".
-// This means that messages must be compressed and decompressed in isolation,
-// without retaining sliding window or dictionary state across messages. For
-// more details refer to RFC 7692.
-//
-// Use of compression is experimental and may result in decreased performance.
-package websocket
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/autobahn/server.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/autobahn/server.go
deleted file mode 100644
index 3db880f9..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/autobahn/server.go
+++ /dev/null
@@ -1,265 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Command server is a test server for the Autobahn WebSockets Test Suite.
-package main
-
-import (
- "errors"
- "flag"
- "io"
- "log"
- "net/http"
- "time"
- "unicode/utf8"
-
- "github.com/gorilla/websocket"
-)
-
-var upgrader = websocket.Upgrader{
- ReadBufferSize: 4096,
- WriteBufferSize: 4096,
- EnableCompression: true,
- CheckOrigin: func(r *http.Request) bool {
- return true
- },
-}
-
-// echoCopy echoes messages from the client using io.Copy.
-func echoCopy(w http.ResponseWriter, r *http.Request, writerOnly bool) {
- conn, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Println("Upgrade:", err)
- return
- }
- defer conn.Close()
- for {
- mt, r, err := conn.NextReader()
- if err != nil {
- if err != io.EOF {
- log.Println("NextReader:", err)
- }
- return
- }
- if mt == websocket.TextMessage {
- r = &validator{r: r}
- }
- w, err := conn.NextWriter(mt)
- if err != nil {
- log.Println("NextWriter:", err)
- return
- }
- if mt == websocket.TextMessage {
- r = &validator{r: r}
- }
- if writerOnly {
- _, err = io.Copy(struct{ io.Writer }{w}, r)
- } else {
- _, err = io.Copy(w, r)
- }
- if err != nil {
- if err == errInvalidUTF8 {
- conn.WriteControl(websocket.CloseMessage,
- websocket.FormatCloseMessage(websocket.CloseInvalidFramePayloadData, ""),
- time.Time{})
- }
- log.Println("Copy:", err)
- return
- }
- err = w.Close()
- if err != nil {
- log.Println("Close:", err)
- return
- }
- }
-}
-
-func echoCopyWriterOnly(w http.ResponseWriter, r *http.Request) {
- echoCopy(w, r, true)
-}
-
-func echoCopyFull(w http.ResponseWriter, r *http.Request) {
- echoCopy(w, r, false)
-}
-
-// echoReadAll echoes messages from the client by reading the entire message
-// with ioutil.ReadAll.
-func echoReadAll(w http.ResponseWriter, r *http.Request, writeMessage, writePrepared bool) {
- conn, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Println("Upgrade:", err)
- return
- }
- defer conn.Close()
- for {
- mt, b, err := conn.ReadMessage()
- if err != nil {
- if err != io.EOF {
- log.Println("NextReader:", err)
- }
- return
- }
- if mt == websocket.TextMessage {
- if !utf8.Valid(b) {
- conn.WriteControl(websocket.CloseMessage,
- websocket.FormatCloseMessage(websocket.CloseInvalidFramePayloadData, ""),
- time.Time{})
- log.Println("ReadAll: invalid utf8")
- }
- }
- if writeMessage {
- if !writePrepared {
- err = conn.WriteMessage(mt, b)
- if err != nil {
- log.Println("WriteMessage:", err)
- }
- } else {
- pm, err := websocket.NewPreparedMessage(mt, b)
- if err != nil {
- log.Println("NewPreparedMessage:", err)
- return
- }
- err = conn.WritePreparedMessage(pm)
- if err != nil {
- log.Println("WritePreparedMessage:", err)
- }
- }
- } else {
- w, err := conn.NextWriter(mt)
- if err != nil {
- log.Println("NextWriter:", err)
- return
- }
- if _, err := w.Write(b); err != nil {
- log.Println("Writer:", err)
- return
- }
- if err := w.Close(); err != nil {
- log.Println("Close:", err)
- return
- }
- }
- }
-}
-
-func echoReadAllWriter(w http.ResponseWriter, r *http.Request) {
- echoReadAll(w, r, false, false)
-}
-
-func echoReadAllWriteMessage(w http.ResponseWriter, r *http.Request) {
- echoReadAll(w, r, true, false)
-}
-
-func echoReadAllWritePreparedMessage(w http.ResponseWriter, r *http.Request) {
- echoReadAll(w, r, true, true)
-}
-
-func serveHome(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/" {
- http.Error(w, "Not found.", 404)
- return
- }
- if r.Method != "GET" {
- http.Error(w, "Method not allowed", 405)
- return
- }
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- io.WriteString(w, "<html><body>Echo Server</body></html>")
-}
-
-var addr = flag.String("addr", ":9000", "http service address")
-
-func main() {
- flag.Parse()
- http.HandleFunc("/", serveHome)
- http.HandleFunc("/c", echoCopyWriterOnly)
- http.HandleFunc("/f", echoCopyFull)
- http.HandleFunc("/r", echoReadAllWriter)
- http.HandleFunc("/m", echoReadAllWriteMessage)
- http.HandleFunc("/p", echoReadAllWritePreparedMessage)
- err := http.ListenAndServe(*addr, nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
-}
-
-type validator struct {
- state int
- x rune
- r io.Reader
-}
-
-var errInvalidUTF8 = errors.New("invalid utf8")
-
-func (r *validator) Read(p []byte) (int, error) {
- n, err := r.r.Read(p)
- state := r.state
- x := r.x
- for _, b := range p[:n] {
- state, x = decode(state, x, b)
- if state == utf8Reject {
- break
- }
- }
- r.state = state
- r.x = x
- if state == utf8Reject || (err == io.EOF && state != utf8Accept) {
- return n, errInvalidUTF8
- }
- return n, err
-}
-
-// UTF-8 decoder from http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
-//
-// Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to
-// deal in the Software without restriction, including without limitation the
-// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-// sell copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in
-// all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-// IN THE SOFTWARE.
-var utf8d = [...]byte{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1f
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 20..3f
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40..5f
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60..7f
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, // 80..9f
- 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, // a0..bf
- 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // c0..df
- 0xa, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x3, 0x4, 0x3, 0x3, // e0..ef
- 0xb, 0x6, 0x6, 0x6, 0x5, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, // f0..ff
- 0x0, 0x1, 0x2, 0x3, 0x5, 0x8, 0x7, 0x1, 0x1, 0x1, 0x4, 0x6, 0x1, 0x1, 0x1, 0x1, // s0..s0
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, // s1..s2
- 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, // s3..s4
- 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, // s5..s6
- 1, 3, 1, 1, 1, 1, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // s7..s8
-}
-
-const (
- utf8Accept = 0
- utf8Reject = 1
-)
-
-func decode(state int, x rune, b byte) (int, rune) {
- t := utf8d[b]
- if state != utf8Accept {
- x = rune(b&0x3f) | (x << 6)
- } else {
- x = rune((0xff >> t) & b)
- }
- state = int(utf8d[256+state*16+int(t)])
- return state, x
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/client.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/client.go
deleted file mode 100644
index ecfd9a7a..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/client.go
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "bytes"
- "log"
- "net/http"
- "time"
-
- "github.com/gorilla/websocket"
-)
-
-const (
- // Time allowed to write a message to the peer.
- writeWait = 10 * time.Second
-
- // Time allowed to read the next pong message from the peer.
- pongWait = 60 * time.Second
-
- // Send pings to peer with this period. Must be less than pongWait.
- pingPeriod = (pongWait * 9) / 10
-
- // Maximum message size allowed from peer.
- maxMessageSize = 512
-)
-
-var (
- newline = []byte{'\n'}
- space = []byte{' '}
-)
-
-var upgrader = websocket.Upgrader{
- ReadBufferSize: 1024,
- WriteBufferSize: 1024,
-}
-
-// Client is a middleman between the websocket connection and the hub.
-type Client struct {
- hub *Hub
-
- // The websocket connection.
- conn *websocket.Conn
-
- // Buffered channel of outbound messages.
- send chan []byte
-}
-
-// readPump pumps messages from the websocket connection to the hub.
-//
-// The application runs readPump in a per-connection goroutine. The application
-// ensures that there is at most one reader on a connection by executing all
-// reads from this goroutine.
-func (c *Client) readPump() {
- defer func() {
- c.hub.unregister <- c
- c.conn.Close()
- }()
- c.conn.SetReadLimit(maxMessageSize)
- c.conn.SetReadDeadline(time.Now().Add(pongWait))
- c.conn.SetPongHandler(func(string) error { c.conn.SetReadDeadline(time.Now().Add(pongWait)); return nil })
- for {
- _, message, err := c.conn.ReadMessage()
- if err != nil {
- if websocket.IsUnexpectedCloseError(err, websocket.CloseGoingAway) {
- log.Printf("error: %v", err)
- }
- break
- }
- message = bytes.TrimSpace(bytes.Replace(message, newline, space, -1))
- c.hub.broadcast <- message
- }
-}
-
-// writePump pumps messages from the hub to the websocket connection.
-//
-// A goroutine running writePump is started for each connection. The
-// application ensures that there is at most one writer to a connection by
-// executing all writes from this goroutine.
-func (c *Client) writePump() {
- ticker := time.NewTicker(pingPeriod)
- defer func() {
- ticker.Stop()
- c.conn.Close()
- }()
- for {
- select {
- case message, ok := <-c.send:
- c.conn.SetWriteDeadline(time.Now().Add(writeWait))
- if !ok {
- // The hub closed the channel.
- c.conn.WriteMessage(websocket.CloseMessage, []byte{})
- return
- }
-
- w, err := c.conn.NextWriter(websocket.TextMessage)
- if err != nil {
- return
- }
- w.Write(message)
-
- // Add queued chat messages to the current websocket message.
- n := len(c.send)
- for i := 0; i < n; i++ {
- w.Write(newline)
- w.Write(<-c.send)
- }
-
- if err := w.Close(); err != nil {
- return
- }
- case <-ticker.C:
- c.conn.SetWriteDeadline(time.Now().Add(writeWait))
- if err := c.conn.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
- return
- }
- }
- }
-}
-
-// serveWs handles websocket requests from the peer.
-func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
- conn, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Println(err)
- return
- }
- client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)}
- client.hub.register <- client
-
- // Allow collection of memory referenced by the caller by doing all work in
- // new goroutines.
- go client.writePump()
- go client.readPump()
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/hub.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/hub.go
deleted file mode 100644
index 7f07ea07..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/hub.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-// hub maintains the set of active clients and broadcasts messages to the
-// clients.
-type Hub struct {
- // Registered clients.
- clients map[*Client]bool
-
- // Inbound messages from the clients.
- broadcast chan []byte
-
- // Register requests from the clients.
- register chan *Client
-
- // Unregister requests from clients.
- unregister chan *Client
-}
-
-func newHub() *Hub {
- return &Hub{
- broadcast: make(chan []byte),
- register: make(chan *Client),
- unregister: make(chan *Client),
- clients: make(map[*Client]bool),
- }
-}
-
-func (h *Hub) run() {
- for {
- select {
- case client := <-h.register:
- h.clients[client] = true
- case client := <-h.unregister:
- if _, ok := h.clients[client]; ok {
- delete(h.clients, client)
- close(client.send)
- }
- case message := <-h.broadcast:
- for client := range h.clients {
- select {
- case client.send <- message:
- default:
- close(client.send)
- delete(h.clients, client)
- }
- }
- }
- }
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/main.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/main.go
deleted file mode 100644
index 74615d59..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/chat/main.go
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "flag"
- "log"
- "net/http"
-)
-
-var addr = flag.String("addr", ":8080", "http service address")
-
-func serveHome(w http.ResponseWriter, r *http.Request) {
- log.Println(r.URL)
- if r.URL.Path != "/" {
- http.Error(w, "Not found", 404)
- return
- }
- if r.Method != "GET" {
- http.Error(w, "Method not allowed", 405)
- return
- }
- http.ServeFile(w, r, "home.html")
-}
-
-func main() {
- flag.Parse()
- hub := newHub()
- go hub.run()
- http.HandleFunc("/", serveHome)
- http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
- serveWs(hub, w, r)
- })
- err := http.ListenAndServe(*addr, nil)
- if err != nil {
- log.Fatal("ListenAndServe: ", err)
- }
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/command/main.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/command/main.go
deleted file mode 100644
index 239c5c85..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/command/main.go
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright 2015 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "bufio"
- "flag"
- "io"
- "log"
- "net/http"
- "os"
- "os/exec"
- "time"
-
- "github.com/gorilla/websocket"
-)
-
-var (
- addr = flag.String("addr", "127.0.0.1:8080", "http service address")
- cmdPath string
-)
-
-const (
- // Time allowed to write a message to the peer.
- writeWait = 10 * time.Second
-
- // Maximum message size allowed from peer.
- maxMessageSize = 8192
-
- // Time allowed to read the next pong message from the peer.
- pongWait = 60 * time.Second
-
- // Send pings to peer with this period. Must be less than pongWait.
- pingPeriod = (pongWait * 9) / 10
-
- // Time to wait before force close on connection.
- closeGracePeriod = 10 * time.Second
-)
-
-func pumpStdin(ws *websocket.Conn, w io.Writer) {
- defer ws.Close()
- ws.SetReadLimit(maxMessageSize)
- ws.SetReadDeadline(time.Now().Add(pongWait))
- ws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })
- for {
- _, message, err := ws.ReadMessage()
- if err != nil {
- break
- }
- message = append(message, '\n')
- if _, err := w.Write(message); err != nil {
- break
- }
- }
-}
-
-func pumpStdout(ws *websocket.Conn, r io.Reader, done chan struct{}) {
- defer func() {
- }()
- s := bufio.NewScanner(r)
- for s.Scan() {
- ws.SetWriteDeadline(time.Now().Add(writeWait))
- if err := ws.WriteMessage(websocket.TextMessage, s.Bytes()); err != nil {
- ws.Close()
- break
- }
- }
- if s.Err() != nil {
- log.Println("scan:", s.Err())
- }
- close(done)
-
- ws.SetWriteDeadline(time.Now().Add(writeWait))
- ws.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
- time.Sleep(closeGracePeriod)
- ws.Close()
-}
-
-func ping(ws *websocket.Conn, done chan struct{}) {
- ticker := time.NewTicker(pingPeriod)
- defer ticker.Stop()
- for {
- select {
- case <-ticker.C:
- if err := ws.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(writeWait)); err != nil {
- log.Println("ping:", err)
- }
- case <-done:
- return
- }
- }
-}
-
-func internalError(ws *websocket.Conn, msg string, err error) {
- log.Println(msg, err)
- ws.WriteMessage(websocket.TextMessage, []byte("Internal server error."))
-}
-
-var upgrader = websocket.Upgrader{}
-
-func serveWs(w http.ResponseWriter, r *http.Request) {
- ws, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Println("upgrade:", err)
- return
- }
-
- defer ws.Close()
-
- outr, outw, err := os.Pipe()
- if err != nil {
- internalError(ws, "stdout:", err)
- return
- }
- defer outr.Close()
- defer outw.Close()
-
- inr, inw, err := os.Pipe()
- if err != nil {
- internalError(ws, "stdin:", err)
- return
- }
- defer inr.Close()
- defer inw.Close()
-
- proc, err := os.StartProcess(cmdPath, flag.Args(), &os.ProcAttr{
- Files: []*os.File{inr, outw, outw},
- })
- if err != nil {
- internalError(ws, "start:", err)
- return
- }
-
- inr.Close()
- outw.Close()
-
- stdoutDone := make(chan struct{})
- go pumpStdout(ws, outr, stdoutDone)
- go ping(ws, stdoutDone)
-
- pumpStdin(ws, inw)
-
- // Some commands will exit when stdin is closed.
- inw.Close()
-
- // Other commands need a bonk on the head.
- if err := proc.Signal(os.Interrupt); err != nil {
- log.Println("inter:", err)
- }
-
- select {
- case <-stdoutDone:
- case <-time.After(time.Second):
- // A bigger bonk on the head.
- if err := proc.Signal(os.Kill); err != nil {
- log.Println("term:", err)
- }
- <-stdoutDone
- }
-
- if _, err := proc.Wait(); err != nil {
- log.Println("wait:", err)
- }
-}
-
-func serveHome(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/" {
- http.Error(w, "Not found", 404)
- return
- }
- if r.Method != "GET" {
- http.Error(w, "Method not allowed", 405)
- return
- }
- http.ServeFile(w, r, "home.html")
-}
-
-func main() {
- flag.Parse()
- if len(flag.Args()) < 1 {
- log.Fatal("must specify at least one argument")
- }
- var err error
- cmdPath, err = exec.LookPath(flag.Args()[0])
- if err != nil {
- log.Fatal(err)
- }
- http.HandleFunc("/", serveHome)
- http.HandleFunc("/ws", serveWs)
- log.Fatal(http.ListenAndServe(*addr, nil))
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/client.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/client.go
deleted file mode 100644
index 6578094e..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/client.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2015 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-package main
-
-import (
- "flag"
- "log"
- "net/url"
- "os"
- "os/signal"
- "time"
-
- "github.com/gorilla/websocket"
-)
-
-var addr = flag.String("addr", "localhost:8080", "http service address")
-
-func main() {
- flag.Parse()
- log.SetFlags(0)
-
- interrupt := make(chan os.Signal, 1)
- signal.Notify(interrupt, os.Interrupt)
-
- u := url.URL{Scheme: "ws", Host: *addr, Path: "/echo"}
- log.Printf("connecting to %s", u.String())
-
- c, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
- if err != nil {
- log.Fatal("dial:", err)
- }
- defer c.Close()
-
- done := make(chan struct{})
-
- go func() {
- defer c.Close()
- defer close(done)
- for {
- _, message, err := c.ReadMessage()
- if err != nil {
- log.Println("read:", err)
- return
- }
- log.Printf("recv: %s", message)
- }
- }()
-
- ticker := time.NewTicker(time.Second)
- defer ticker.Stop()
-
- for {
- select {
- case t := <-ticker.C:
- err := c.WriteMessage(websocket.TextMessage, []byte(t.String()))
- if err != nil {
- log.Println("write:", err)
- return
- }
- case <-interrupt:
- log.Println("interrupt")
- // To cleanly close a connection, a client should send a close
- // frame and wait for the server to close the connection.
- err := c.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, ""))
- if err != nil {
- log.Println("write close:", err)
- return
- }
- select {
- case <-done:
- case <-time.After(time.Second):
- }
- c.Close()
- return
- }
- }
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/server.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/server.go
deleted file mode 100644
index a685b097..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/echo/server.go
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2015 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// +build ignore
-
-package main
-
-import (
- "flag"
- "html/template"
- "log"
- "net/http"
-
- "github.com/gorilla/websocket"
-)
-
-var addr = flag.String("addr", "localhost:8080", "http service address")
-
-var upgrader = websocket.Upgrader{} // use default options
-
-func echo(w http.ResponseWriter, r *http.Request) {
- c, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- log.Print("upgrade:", err)
- return
- }
- defer c.Close()
- for {
- mt, message, err := c.ReadMessage()
- if err != nil {
- log.Println("read:", err)
- break
- }
- log.Printf("recv: %s", message)
- err = c.WriteMessage(mt, message)
- if err != nil {
- log.Println("write:", err)
- break
- }
- }
-}
-
-func home(w http.ResponseWriter, r *http.Request) {
- homeTemplate.Execute(w, "ws://"+r.Host+"/echo")
-}
-
-func main() {
- flag.Parse()
- log.SetFlags(0)
- http.HandleFunc("/echo", echo)
- http.HandleFunc("/", home)
- log.Fatal(http.ListenAndServe(*addr, nil))
-}
-
-var homeTemplate = template.Must(template.New("").Parse(`
-<!DOCTYPE html>
-<head>
-<meta charset="utf-8">
-<script>
-window.addEventListener("load", function(evt) {
-
- var output = document.getElementById("output");
- var input = document.getElementById("input");
- var ws;
-
- var print = function(message) {
- var d = document.createElement("div");
- d.innerHTML = message;
- output.appendChild(d);
- };
-
- document.getElementById("open").onclick = function(evt) {
- if (ws) {
- return false;
- }
- ws = new WebSocket("{{.}}");
- ws.onopen = function(evt) {
- print("OPEN");
- }
- ws.onclose = function(evt) {
- print("CLOSE");
- ws = null;
- }
- ws.onmessage = function(evt) {
- print("RESPONSE: " + evt.data);
- }
- ws.onerror = function(evt) {
- print("ERROR: " + evt.data);
- }
- return false;
- };
-
- document.getElementById("send").onclick = function(evt) {
- if (!ws) {
- return false;
- }
- print("SEND: " + input.value);
- ws.send(input.value);
- return false;
- };
-
- document.getElementById("close").onclick = function(evt) {
- if (!ws) {
- return false;
- }
- ws.close();
- return false;
- };
-
-});
-</script>
-</head>
-<body>
-<table>
-<tr><td valign="top" width="50%">
-<p>Click "Open" to create a connection to the server,
-"Send" to send a message to the server and "Close" to close the connection.
-You can change the message and send multiple times.
-<p>
-<form>
-<button id="open">Open</button>
-<button id="close">Close</button>
-<p><input id="input" type="text" value="Hello world!">
-<button id="send">Send</button>
-</form>
-</td><td valign="top" width="50%">
-<div id="output"></div>
-</td></tr></table>
-</body>
-</html>
-`))
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/filewatch/main.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/filewatch/main.go
deleted file mode 100644
index f5f9da5c..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/examples/filewatch/main.go
+++ /dev/null
@@ -1,193 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package main
-
-import (
- "flag"
- "html/template"
- "io/ioutil"
- "log"
- "net/http"
- "os"
- "strconv"
- "time"
-
- "github.com/gorilla/websocket"
-)
-
-const (
- // Time allowed to write the file to the client.
- writeWait = 10 * time.Second
-
- // Time allowed to read the next pong message from the client.
- pongWait = 60 * time.Second
-
- // Send pings to client with this period. Must be less than pongWait.
- pingPeriod = (pongWait * 9) / 10
-
- // Poll file for changes with this period.
- filePeriod = 10 * time.Second
-)
-
-var (
- addr = flag.String("addr", ":8080", "http service address")
- homeTempl = template.Must(template.New("").Parse(homeHTML))
- filename string
- upgrader = websocket.Upgrader{
- ReadBufferSize: 1024,
- WriteBufferSize: 1024,
- }
-)
-
-func readFileIfModified(lastMod time.Time) ([]byte, time.Time, error) {
- fi, err := os.Stat(filename)
- if err != nil {
- return nil, lastMod, err
- }
- if !fi.ModTime().After(lastMod) {
- return nil, lastMod, nil
- }
- p, err := ioutil.ReadFile(filename)
- if err != nil {
- return nil, fi.ModTime(), err
- }
- return p, fi.ModTime(), nil
-}
-
-func reader(ws *websocket.Conn) {
- defer ws.Close()
- ws.SetReadLimit(512)
- ws.SetReadDeadline(time.Now().Add(pongWait))
- ws.SetPongHandler(func(string) error { ws.SetReadDeadline(time.Now().Add(pongWait)); return nil })
- for {
- _, _, err := ws.ReadMessage()
- if err != nil {
- break
- }
- }
-}
-
-func writer(ws *websocket.Conn, lastMod time.Time) {
- lastError := ""
- pingTicker := time.NewTicker(pingPeriod)
- fileTicker := time.NewTicker(filePeriod)
- defer func() {
- pingTicker.Stop()
- fileTicker.Stop()
- ws.Close()
- }()
- for {
- select {
- case <-fileTicker.C:
- var p []byte
- var err error
-
- p, lastMod, err = readFileIfModified(lastMod)
-
- if err != nil {
- if s := err.Error(); s != lastError {
- lastError = s
- p = []byte(lastError)
- }
- } else {
- lastError = ""
- }
-
- if p != nil {
- ws.SetWriteDeadline(time.Now().Add(writeWait))
- if err := ws.WriteMessage(websocket.TextMessage, p); err != nil {
- return
- }
- }
- case <-pingTicker.C:
- ws.SetWriteDeadline(time.Now().Add(writeWait))
- if err := ws.WriteMessage(websocket.PingMessage, []byte{}); err != nil {
- return
- }
- }
- }
-}
-
-func serveWs(w http.ResponseWriter, r *http.Request) {
- ws, err := upgrader.Upgrade(w, r, nil)
- if err != nil {
- if _, ok := err.(websocket.HandshakeError); !ok {
- log.Println(err)
- }
- return
- }
-
- var lastMod time.Time
- if n, err := strconv.ParseInt(r.FormValue("lastMod"), 16, 64); err == nil {
- lastMod = time.Unix(0, n)
- }
-
- go writer(ws, lastMod)
- reader(ws)
-}
-
-func serveHome(w http.ResponseWriter, r *http.Request) {
- if r.URL.Path != "/" {
- http.Error(w, "Not found", 404)
- return
- }
- if r.Method != "GET" {
- http.Error(w, "Method not allowed", 405)
- return
- }
- w.Header().Set("Content-Type", "text/html; charset=utf-8")
- p, lastMod, err := readFileIfModified(time.Time{})
- if err != nil {
- p = []byte(err.Error())
- lastMod = time.Unix(0, 0)
- }
- var v = struct {
- Host string
- Data string
- LastMod string
- }{
- r.Host,
- string(p),
- strconv.FormatInt(lastMod.UnixNano(), 16),
- }
- homeTempl.Execute(w, &v)
-}
-
-func main() {
- flag.Parse()
- if flag.NArg() != 1 {
- log.Fatal("filename not specified")
- }
- filename = flag.Args()[0]
- http.HandleFunc("/", serveHome)
- http.HandleFunc("/ws", serveWs)
- if err := http.ListenAndServe(*addr, nil); err != nil {
- log.Fatal(err)
- }
-}
-
-const homeHTML = `<!DOCTYPE html>
-<html lang="en">
- <head>
- <title>WebSocket Example</title>
- </head>
- <body>
- <pre id="fileData">{{.Data}}</pre>
- <script type="text/javascript">
- (function() {
- var data = document.getElementById("fileData");
- var conn = new WebSocket("ws://{{.Host}}/ws?lastMod={{.LastMod}}");
- conn.onclose = function(evt) {
- data.textContent = 'Connection closed';
- }
- conn.onmessage = function(evt) {
- console.log('file updated');
- data.textContent = evt.data;
- }
- })();
- </script>
- </body>
-</html>
-`
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/json.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/json.go
deleted file mode 100644
index 4f0e3687..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/json.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "encoding/json"
- "io"
-)
-
-// WriteJSON is deprecated, use c.WriteJSON instead.
-func WriteJSON(c *Conn, v interface{}) error {
- return c.WriteJSON(v)
-}
-
-// WriteJSON writes the JSON encoding of v to the connection.
-//
-// See the documentation for encoding/json Marshal for details about the
-// conversion of Go values to JSON.
-func (c *Conn) WriteJSON(v interface{}) error {
- w, err := c.NextWriter(TextMessage)
- if err != nil {
- return err
- }
- err1 := json.NewEncoder(w).Encode(v)
- err2 := w.Close()
- if err1 != nil {
- return err1
- }
- return err2
-}
-
-// ReadJSON is deprecated, use c.ReadJSON instead.
-func ReadJSON(c *Conn, v interface{}) error {
- return c.ReadJSON(v)
-}
-
-// ReadJSON reads the next JSON-encoded message from the connection and stores
-// it in the value pointed to by v.
-//
-// See the documentation for the encoding/json Unmarshal function for details
-// about the conversion of JSON to a Go value.
-func (c *Conn) ReadJSON(v interface{}) error {
- _, r, err := c.NextReader()
- if err != nil {
- return err
- }
- err = json.NewDecoder(r).Decode(v)
- if err == io.EOF {
- // One value is expected in the message.
- err = io.ErrUnexpectedEOF
- }
- return err
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask.go
deleted file mode 100644
index 6a88bbc7..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask.go
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
-// this source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-// +build !appengine
-
-package websocket
-
-import "unsafe"
-
-const wordSize = int(unsafe.Sizeof(uintptr(0)))
-
-func maskBytes(key [4]byte, pos int, b []byte) int {
-
- // Mask one byte at a time for small buffers.
- if len(b) < 2*wordSize {
- for i := range b {
- b[i] ^= key[pos&3]
- pos++
- }
- return pos & 3
- }
-
- // Mask one byte at a time to word boundary.
- if n := int(uintptr(unsafe.Pointer(&b[0]))) % wordSize; n != 0 {
- n = wordSize - n
- for i := range b[:n] {
- b[i] ^= key[pos&3]
- pos++
- }
- b = b[n:]
- }
-
- // Create aligned word size key.
- var k [wordSize]byte
- for i := range k {
- k[i] = key[(pos+i)&3]
- }
- kw := *(*uintptr)(unsafe.Pointer(&k))
-
- // Mask one word at a time.
- n := (len(b) / wordSize) * wordSize
- for i := 0; i < n; i += wordSize {
- *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&b[0])) + uintptr(i))) ^= kw
- }
-
- // Mask one byte at a time for remaining bytes.
- b = b[n:]
- for i := range b {
- b[i] ^= key[pos&3]
- pos++
- }
-
- return pos & 3
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask_safe.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask_safe.go
deleted file mode 100644
index 2aac060e..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/mask_safe.go
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2016 The Gorilla WebSocket Authors. All rights reserved. Use of
-// this source code is governed by a BSD-style license that can be found in the
-// LICENSE file.
-
-// +build appengine
-
-package websocket
-
-func maskBytes(key [4]byte, pos int, b []byte) int {
- for i := range b {
- b[i] ^= key[pos&3]
- pos++
- }
- return pos & 3
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/prepared.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/prepared.go
deleted file mode 100644
index 1efffbd1..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/prepared.go
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright 2017 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "bytes"
- "net"
- "sync"
- "time"
-)
-
-// PreparedMessage caches on the wire representations of a message payload.
-// Use PreparedMessage to efficiently send a message payload to multiple
-// connections. PreparedMessage is especially useful when compression is used
-// because the CPU and memory expensive compression operation can be executed
-// once for a given set of compression options.
-type PreparedMessage struct {
- messageType int
- data []byte
- err error
- mu sync.Mutex
- frames map[prepareKey]*preparedFrame
-}
-
-// prepareKey defines a unique set of options to cache prepared frames in PreparedMessage.
-type prepareKey struct {
- isServer bool
- compress bool
- compressionLevel int
-}
-
-// preparedFrame contains data in wire representation.
-type preparedFrame struct {
- once sync.Once
- data []byte
-}
-
-// NewPreparedMessage returns an initialized PreparedMessage. You can then send
-// it to connection using WritePreparedMessage method. Valid wire
-// representation will be calculated lazily only once for a set of current
-// connection options.
-func NewPreparedMessage(messageType int, data []byte) (*PreparedMessage, error) {
- pm := &PreparedMessage{
- messageType: messageType,
- frames: make(map[prepareKey]*preparedFrame),
- data: data,
- }
-
- // Prepare a plain server frame.
- _, frameData, err := pm.frame(prepareKey{isServer: true, compress: false})
- if err != nil {
- return nil, err
- }
-
- // To protect against caller modifying the data argument, remember the data
- // copied to the plain server frame.
- pm.data = frameData[len(frameData)-len(data):]
- return pm, nil
-}
-
-func (pm *PreparedMessage) frame(key prepareKey) (int, []byte, error) {
- pm.mu.Lock()
- frame, ok := pm.frames[key]
- if !ok {
- frame = &preparedFrame{}
- pm.frames[key] = frame
- }
- pm.mu.Unlock()
-
- var err error
- frame.once.Do(func() {
- // Prepare a frame using a 'fake' connection.
- // TODO: Refactor code in conn.go to allow more direct construction of
- // the frame.
- mu := make(chan bool, 1)
- mu <- true
- var nc prepareConn
- c := &Conn{
- conn: &nc,
- mu: mu,
- isServer: key.isServer,
- compressionLevel: key.compressionLevel,
- enableWriteCompression: true,
- writeBuf: make([]byte, defaultWriteBufferSize+maxFrameHeaderSize),
- }
- if key.compress {
- c.newCompressionWriter = compressNoContextTakeover
- }
- err = c.WriteMessage(pm.messageType, pm.data)
- frame.data = nc.buf.Bytes()
- })
- return pm.messageType, frame.data, err
-}
-
-type prepareConn struct {
- buf bytes.Buffer
- net.Conn
-}
-
-func (pc *prepareConn) Write(p []byte) (int, error) { return pc.buf.Write(p) }
-func (pc *prepareConn) SetWriteDeadline(t time.Time) error { return nil }
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/server.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/server.go
deleted file mode 100644
index 3495e0f1..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/server.go
+++ /dev/null
@@ -1,291 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "bufio"
- "errors"
- "net"
- "net/http"
- "net/url"
- "strings"
- "time"
-)
-
-// HandshakeError describes an error with the handshake from the peer.
-type HandshakeError struct {
- message string
-}
-
-func (e HandshakeError) Error() string { return e.message }
-
-// Upgrader specifies parameters for upgrading an HTTP connection to a
-// WebSocket connection.
-type Upgrader struct {
- // HandshakeTimeout specifies the duration for the handshake to complete.
- HandshakeTimeout time.Duration
-
- // ReadBufferSize and WriteBufferSize specify I/O buffer sizes. If a buffer
- // size is zero, then buffers allocated by the HTTP server are used. The
- // I/O buffer sizes do not limit the size of the messages that can be sent
- // or received.
- ReadBufferSize, WriteBufferSize int
-
- // Subprotocols specifies the server's supported protocols in order of
- // preference. If this field is set, then the Upgrade method negotiates a
- // subprotocol by selecting the first match in this list with a protocol
- // requested by the client.
- Subprotocols []string
-
- // Error specifies the function for generating HTTP error responses. If Error
- // is nil, then http.Error is used to generate the HTTP response.
- Error func(w http.ResponseWriter, r *http.Request, status int, reason error)
-
- // CheckOrigin returns true if the request Origin header is acceptable. If
- // CheckOrigin is nil, the host in the Origin header must not be set or
- // must match the host of the request.
- CheckOrigin func(r *http.Request) bool
-
- // EnableCompression specify if the server should attempt to negotiate per
- // message compression (RFC 7692). Setting this value to true does not
- // guarantee that compression will be supported. Currently only "no context
- // takeover" modes are supported.
- EnableCompression bool
-}
-
-func (u *Upgrader) returnError(w http.ResponseWriter, r *http.Request, status int, reason string) (*Conn, error) {
- err := HandshakeError{reason}
- if u.Error != nil {
- u.Error(w, r, status, err)
- } else {
- w.Header().Set("Sec-Websocket-Version", "13")
- http.Error(w, http.StatusText(status), status)
- }
- return nil, err
-}
-
-// checkSameOrigin returns true if the origin is not set or is equal to the request host.
-func checkSameOrigin(r *http.Request) bool {
- origin := r.Header["Origin"]
- if len(origin) == 0 {
- return true
- }
- u, err := url.Parse(origin[0])
- if err != nil {
- return false
- }
- return u.Host == r.Host
-}
-
-func (u *Upgrader) selectSubprotocol(r *http.Request, responseHeader http.Header) string {
- if u.Subprotocols != nil {
- clientProtocols := Subprotocols(r)
- for _, serverProtocol := range u.Subprotocols {
- for _, clientProtocol := range clientProtocols {
- if clientProtocol == serverProtocol {
- return clientProtocol
- }
- }
- }
- } else if responseHeader != nil {
- return responseHeader.Get("Sec-Websocket-Protocol")
- }
- return ""
-}
-
-// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
-//
-// The responseHeader is included in the response to the client's upgrade
-// request. Use the responseHeader to specify cookies (Set-Cookie) and the
-// application negotiated subprotocol (Sec-Websocket-Protocol).
-//
-// If the upgrade fails, then Upgrade replies to the client with an HTTP error
-// response.
-func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header) (*Conn, error) {
- if r.Method != "GET" {
- return u.returnError(w, r, http.StatusMethodNotAllowed, "websocket: not a websocket handshake: request method is not GET")
- }
-
- if _, ok := responseHeader["Sec-Websocket-Extensions"]; ok {
- return u.returnError(w, r, http.StatusInternalServerError, "websocket: application specific 'Sec-Websocket-Extensions' headers are unsupported")
- }
-
- if !tokenListContainsValue(r.Header, "Connection", "upgrade") {
- return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'upgrade' token not found in 'Connection' header")
- }
-
- if !tokenListContainsValue(r.Header, "Upgrade", "websocket") {
- return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: 'websocket' token not found in 'Upgrade' header")
- }
-
- if !tokenListContainsValue(r.Header, "Sec-Websocket-Version", "13") {
- return u.returnError(w, r, http.StatusBadRequest, "websocket: unsupported version: 13 not found in 'Sec-Websocket-Version' header")
- }
-
- checkOrigin := u.CheckOrigin
- if checkOrigin == nil {
- checkOrigin = checkSameOrigin
- }
- if !checkOrigin(r) {
- return u.returnError(w, r, http.StatusForbidden, "websocket: 'Origin' header value not allowed")
- }
-
- challengeKey := r.Header.Get("Sec-Websocket-Key")
- if challengeKey == "" {
- return u.returnError(w, r, http.StatusBadRequest, "websocket: not a websocket handshake: `Sec-Websocket-Key' header is missing or blank")
- }
-
- subprotocol := u.selectSubprotocol(r, responseHeader)
-
- // Negotiate PMCE
- var compress bool
- if u.EnableCompression {
- for _, ext := range parseExtensions(r.Header) {
- if ext[""] != "permessage-deflate" {
- continue
- }
- compress = true
- break
- }
- }
-
- var (
- netConn net.Conn
- err error
- )
-
- h, ok := w.(http.Hijacker)
- if !ok {
- return u.returnError(w, r, http.StatusInternalServerError, "websocket: response does not implement http.Hijacker")
- }
- var brw *bufio.ReadWriter
- netConn, brw, err = h.Hijack()
- if err != nil {
- return u.returnError(w, r, http.StatusInternalServerError, err.Error())
- }
-
- if brw.Reader.Buffered() > 0 {
- netConn.Close()
- return nil, errors.New("websocket: client sent data before handshake is complete")
- }
-
- c := newConnBRW(netConn, true, u.ReadBufferSize, u.WriteBufferSize, brw)
- c.subprotocol = subprotocol
-
- if compress {
- c.newCompressionWriter = compressNoContextTakeover
- c.newDecompressionReader = decompressNoContextTakeover
- }
-
- p := c.writeBuf[:0]
- p = append(p, "HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: "...)
- p = append(p, computeAcceptKey(challengeKey)...)
- p = append(p, "\r\n"...)
- if c.subprotocol != "" {
- p = append(p, "Sec-Websocket-Protocol: "...)
- p = append(p, c.subprotocol...)
- p = append(p, "\r\n"...)
- }
- if compress {
- p = append(p, "Sec-Websocket-Extensions: permessage-deflate; server_no_context_takeover; client_no_context_takeover\r\n"...)
- }
- for k, vs := range responseHeader {
- if k == "Sec-Websocket-Protocol" {
- continue
- }
- for _, v := range vs {
- p = append(p, k...)
- p = append(p, ": "...)
- for i := 0; i < len(v); i++ {
- b := v[i]
- if b <= 31 {
- // prevent response splitting.
- b = ' '
- }
- p = append(p, b)
- }
- p = append(p, "\r\n"...)
- }
- }
- p = append(p, "\r\n"...)
-
- // Clear deadlines set by HTTP server.
- netConn.SetDeadline(time.Time{})
-
- if u.HandshakeTimeout > 0 {
- netConn.SetWriteDeadline(time.Now().Add(u.HandshakeTimeout))
- }
- if _, err = netConn.Write(p); err != nil {
- netConn.Close()
- return nil, err
- }
- if u.HandshakeTimeout > 0 {
- netConn.SetWriteDeadline(time.Time{})
- }
-
- return c, nil
-}
-
-// Upgrade upgrades the HTTP server connection to the WebSocket protocol.
-//
-// This function is deprecated, use websocket.Upgrader instead.
-//
-// The application is responsible for checking the request origin before
-// calling Upgrade. An example implementation of the same origin policy is:
-//
-// if req.Header.Get("Origin") != "http://"+req.Host {
-// http.Error(w, "Origin not allowed", 403)
-// return
-// }
-//
-// If the endpoint supports subprotocols, then the application is responsible
-// for negotiating the protocol used on the connection. Use the Subprotocols()
-// function to get the subprotocols requested by the client. Use the
-// Sec-Websocket-Protocol response header to specify the subprotocol selected
-// by the application.
-//
-// The responseHeader is included in the response to the client's upgrade
-// request. Use the responseHeader to specify cookies (Set-Cookie) and the
-// negotiated subprotocol (Sec-Websocket-Protocol).
-//
-// The connection buffers IO to the underlying network connection. The
-// readBufSize and writeBufSize parameters specify the size of the buffers to
-// use. Messages can be larger than the buffers.
-//
-// If the request is not a valid WebSocket handshake, then Upgrade returns an
-// error of type HandshakeError. Applications should handle this error by
-// replying to the client with an HTTP error response.
-func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) {
- u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize}
- u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) {
- // don't return errors to maintain backwards compatibility
- }
- u.CheckOrigin = func(r *http.Request) bool {
- // allow all connections by default
- return true
- }
- return u.Upgrade(w, r, responseHeader)
-}
-
-// Subprotocols returns the subprotocols requested by the client in the
-// Sec-Websocket-Protocol header.
-func Subprotocols(r *http.Request) []string {
- h := strings.TrimSpace(r.Header.Get("Sec-Websocket-Protocol"))
- if h == "" {
- return nil
- }
- protocols := strings.Split(h, ",")
- for i := range protocols {
- protocols[i] = strings.TrimSpace(protocols[i])
- }
- return protocols
-}
-
-// IsWebSocketUpgrade returns true if the client requested upgrade to the
-// WebSocket protocol.
-func IsWebSocketUpgrade(r *http.Request) bool {
- return tokenListContainsValue(r.Header, "Connection", "upgrade") &&
- tokenListContainsValue(r.Header, "Upgrade", "websocket")
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/util.go b/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/util.go
deleted file mode 100644
index 9a4908df..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/gorilla/websocket/util.go
+++ /dev/null
@@ -1,214 +0,0 @@
-// Copyright 2013 The Gorilla WebSocket Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package websocket
-
-import (
- "crypto/rand"
- "crypto/sha1"
- "encoding/base64"
- "io"
- "net/http"
- "strings"
-)
-
-var keyGUID = []byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11")
-
-func computeAcceptKey(challengeKey string) string {
- h := sha1.New()
- h.Write([]byte(challengeKey))
- h.Write(keyGUID)
- return base64.StdEncoding.EncodeToString(h.Sum(nil))
-}
-
-func generateChallengeKey() (string, error) {
- p := make([]byte, 16)
- if _, err := io.ReadFull(rand.Reader, p); err != nil {
- return "", err
- }
- return base64.StdEncoding.EncodeToString(p), nil
-}
-
-// Octet types from RFC 2616.
-var octetTypes [256]byte
-
-const (
- isTokenOctet = 1 << iota
- isSpaceOctet
-)
-
-func init() {
- // From RFC 2616
- //
- // OCTET = <any 8-bit sequence of data>
- // CHAR = <any US-ASCII character (octets 0 - 127)>
- // CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
- // CR = <US-ASCII CR, carriage return (13)>
- // LF = <US-ASCII LF, linefeed (10)>
- // SP = <US-ASCII SP, space (32)>
- // HT = <US-ASCII HT, horizontal-tab (9)>
- // <"> = <US-ASCII double-quote mark (34)>
- // CRLF = CR LF
- // LWS = [CRLF] 1*( SP | HT )
- // TEXT = <any OCTET except CTLs, but including LWS>
- // separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <">
- // | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT
- // token = 1*<any CHAR except CTLs or separators>
- // qdtext = <any TEXT except <">>
-
- for c := 0; c < 256; c++ {
- var t byte
- isCtl := c <= 31 || c == 127
- isChar := 0 <= c && c <= 127
- isSeparator := strings.IndexRune(" \t\"(),/:;<=>?@[]\\{}", rune(c)) >= 0
- if strings.IndexRune(" \t\r\n", rune(c)) >= 0 {
- t |= isSpaceOctet
- }
- if isChar && !isCtl && !isSeparator {
- t |= isTokenOctet
- }
- octetTypes[c] = t
- }
-}
-
-func skipSpace(s string) (rest string) {
- i := 0
- for ; i < len(s); i++ {
- if octetTypes[s[i]]&isSpaceOctet == 0 {
- break
- }
- }
- return s[i:]
-}
-
-func nextToken(s string) (token, rest string) {
- i := 0
- for ; i < len(s); i++ {
- if octetTypes[s[i]]&isTokenOctet == 0 {
- break
- }
- }
- return s[:i], s[i:]
-}
-
-func nextTokenOrQuoted(s string) (value string, rest string) {
- if !strings.HasPrefix(s, "\"") {
- return nextToken(s)
- }
- s = s[1:]
- for i := 0; i < len(s); i++ {
- switch s[i] {
- case '"':
- return s[:i], s[i+1:]
- case '\\':
- p := make([]byte, len(s)-1)
- j := copy(p, s[:i])
- escape := true
- for i = i + 1; i < len(s); i++ {
- b := s[i]
- switch {
- case escape:
- escape = false
- p[j] = b
- j += 1
- case b == '\\':
- escape = true
- case b == '"':
- return string(p[:j]), s[i+1:]
- default:
- p[j] = b
- j += 1
- }
- }
- return "", ""
- }
- }
- return "", ""
-}
-
-// tokenListContainsValue returns true if the 1#token header with the given
-// name contains token.
-func tokenListContainsValue(header http.Header, name string, value string) bool {
-headers:
- for _, s := range header[name] {
- for {
- var t string
- t, s = nextToken(skipSpace(s))
- if t == "" {
- continue headers
- }
- s = skipSpace(s)
- if s != "" && s[0] != ',' {
- continue headers
- }
- if strings.EqualFold(t, value) {
- return true
- }
- if s == "" {
- continue headers
- }
- s = s[1:]
- }
- }
- return false
-}
-
-// parseExtensiosn parses WebSocket extensions from a header.
-func parseExtensions(header http.Header) []map[string]string {
-
- // From RFC 6455:
- //
- // Sec-WebSocket-Extensions = extension-list
- // extension-list = 1#extension
- // extension = extension-token *( ";" extension-param )
- // extension-token = registered-token
- // registered-token = token
- // extension-param = token [ "=" (token | quoted-string) ]
- // ;When using the quoted-string syntax variant, the value
- // ;after quoted-string unescaping MUST conform to the
- // ;'token' ABNF.
-
- var result []map[string]string
-headers:
- for _, s := range header["Sec-Websocket-Extensions"] {
- for {
- var t string
- t, s = nextToken(skipSpace(s))
- if t == "" {
- continue headers
- }
- ext := map[string]string{"": t}
- for {
- s = skipSpace(s)
- if !strings.HasPrefix(s, ";") {
- break
- }
- var k string
- k, s = nextToken(skipSpace(s[1:]))
- if k == "" {
- continue headers
- }
- s = skipSpace(s)
- var v string
- if strings.HasPrefix(s, "=") {
- v, s = nextTokenOrQuoted(skipSpace(s[1:]))
- s = skipSpace(s)
- }
- if s != "" && s[0] != ',' && s[0] != ';' {
- continue headers
- }
- ext[k] = v
- }
- if s != "" && s[0] != ',' {
- continue headers
- }
- result = append(result, ext)
- if s == "" {
- continue headers
- }
- s = s[1:]
- }
- }
- return result
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go
index 5d6b6ad4..58971033 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/codegen/main.go
@@ -81,9 +81,9 @@ var codeTemplate = template.Must(template.New("spec").Parse(`package language
func init() {
{{range .PluralGroups}}
- registerPluralSpec({{printf "%#v" .SplitLocales}}, &PluralSpec{
+ RegisterPluralSpec({{printf "%#v" .SplitLocales}}, &PluralSpec{
Plurals: newPluralSet({{range $i, $e := .PluralRules}}{{if $i}}, {{end}}{{$e.CountTitle}}{{end}}),
- PluralFunc: func(ops *operands) Plural { {{range .PluralRules}}{{if .GoCondition}}
+ PluralFunc: func(ops *Operands) Plural { {{range .PluralRules}}{{if .GoCondition}}
// {{.Condition}}
if {{.GoCondition}} {
return {{.CountTitle}}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/language.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/language.go
index 9a155efc..b045a275 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/language.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/language.go
@@ -45,7 +45,7 @@ func Parse(src string) []*Language {
switch chr {
case ',', ';', '.':
tag := strings.TrimSpace(src[start:end])
- if spec := getPluralSpec(tag); spec != nil {
+ if spec := GetPluralSpec(tag); spec != nil {
langs = append(langs, &Language{NormalizeTag(tag), spec})
}
start = end + 1
@@ -53,12 +53,12 @@ func Parse(src string) []*Language {
}
if start > 0 {
tag := strings.TrimSpace(src[start:])
- if spec := getPluralSpec(tag); spec != nil {
+ if spec := GetPluralSpec(tag); spec != nil {
langs = append(langs, &Language{NormalizeTag(tag), spec})
}
return dedupe(langs)
}
- if spec := getPluralSpec(src); spec != nil {
+ if spec := GetPluralSpec(src); spec != nil {
langs = append(langs, &Language{NormalizeTag(src), spec})
}
return langs
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/operands.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/operands.go
index 877bcc89..49ee7dc7 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/operands.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/operands.go
@@ -7,7 +7,7 @@ import (
)
// http://unicode.org/reports/tr35/tr35-numbers.html#Operands
-type operands struct {
+type Operands struct {
N float64 // absolute value of the source number (integer and decimals)
I int64 // integer digits of n
V int64 // number of visible fraction digits in n, with trailing zeros
@@ -17,7 +17,7 @@ type operands struct {
}
// NmodEqualAny returns true if o represents an integer equal to any of the arguments.
-func (o *operands) NequalsAny(any ...int64) bool {
+func (o *Operands) NequalsAny(any ...int64) bool {
for _, i := range any {
if o.I == i && o.T == 0 {
return true
@@ -27,7 +27,7 @@ func (o *operands) NequalsAny(any ...int64) bool {
}
// NmodEqualAny returns true if o represents an integer equal to any of the arguments modulo mod.
-func (o *operands) NmodEqualsAny(mod int64, any ...int64) bool {
+func (o *Operands) NmodEqualsAny(mod int64, any ...int64) bool {
modI := o.I % mod
for _, i := range any {
if modI == i && o.T == 0 {
@@ -38,17 +38,17 @@ func (o *operands) NmodEqualsAny(mod int64, any ...int64) bool {
}
// NmodInRange returns true if o represents an integer in the closed interval [from, to].
-func (o *operands) NinRange(from, to int64) bool {
+func (o *Operands) NinRange(from, to int64) bool {
return o.T == 0 && from <= o.I && o.I <= to
}
// NmodInRange returns true if o represents an integer in the closed interval [from, to] modulo mod.
-func (o *operands) NmodInRange(mod, from, to int64) bool {
+func (o *Operands) NmodInRange(mod, from, to int64) bool {
modI := o.I % mod
return o.T == 0 && from <= modI && modI <= to
}
-func newOperands(v interface{}) (*operands, error) {
+func newOperands(v interface{}) (*Operands, error) {
switch v := v.(type) {
case int:
return newOperandsInt64(int64(v)), nil
@@ -69,14 +69,14 @@ func newOperands(v interface{}) (*operands, error) {
}
}
-func newOperandsInt64(i int64) *operands {
+func newOperandsInt64(i int64) *Operands {
if i < 0 {
i = -i
}
- return &operands{float64(i), i, 0, 0, 0, 0}
+ return &Operands{float64(i), i, 0, 0, 0, 0}
}
-func newOperandsString(s string) (*operands, error) {
+func newOperandsString(s string) (*Operands, error) {
if s[0] == '-' {
s = s[1:]
}
@@ -84,7 +84,7 @@ func newOperandsString(s string) (*operands, error) {
if err != nil {
return nil, err
}
- ops := &operands{N: n}
+ ops := &Operands{N: n}
parts := strings.SplitN(s, ".", 2)
ops.I, err = strconv.ParseInt(parts[0], 10, 64)
if err != nil {
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go
index fc352268..fc31e880 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec.go
@@ -7,7 +7,7 @@ import "strings"
// http://unicode.org/reports/tr35/tr35-numbers.html#Operands
type PluralSpec struct {
Plurals map[Plural]struct{}
- PluralFunc func(*operands) Plural
+ PluralFunc func(*Operands) Plural
}
var pluralSpecs = make(map[string]*PluralSpec)
@@ -18,7 +18,8 @@ func normalizePluralSpecID(id string) string {
return id
}
-func registerPluralSpec(ids []string, ps *PluralSpec) {
+// RegisterPluralSpec registers a new plural spec for the language ids.
+func RegisterPluralSpec(ids []string, ps *PluralSpec) {
for _, id := range ids {
id = normalizePluralSpecID(id)
pluralSpecs[id] = ps
@@ -35,9 +36,9 @@ func (ps *PluralSpec) Plural(number interface{}) (Plural, error) {
return ps.PluralFunc(ops), nil
}
-// getPluralSpec returns the PluralSpec that matches the longest prefix of tag.
+// GetPluralSpec returns the PluralSpec that matches the longest prefix of tag.
// It returns nil if no PluralSpec matches tag.
-func getPluralSpec(tag string) *PluralSpec {
+func GetPluralSpec(tag string) *PluralSpec {
tag = NormalizeTag(tag)
subtag := tag
for {
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go
index c9b4f266..0268bb92 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/language/pluralspec_gen.go
@@ -4,15 +4,15 @@ package language
func init() {
- registerPluralSpec([]string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "zh"}, &PluralSpec{
+ RegisterPluralSpec([]string{"bm", "bo", "dz", "id", "ig", "ii", "in", "ja", "jbo", "jv", "jw", "kde", "kea", "km", "ko", "lkt", "lo", "ms", "my", "nqo", "root", "sah", "ses", "sg", "th", "to", "vi", "wo", "yo", "yue", "zh"}, &PluralSpec{
Plurals: newPluralSet(Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
return Other
},
})
- registerPluralSpec([]string{"am", "as", "bn", "fa", "gu", "hi", "kn", "mr", "zu"}, &PluralSpec{
+ RegisterPluralSpec([]string{"am", "as", "bn", "fa", "gu", "hi", "kn", "mr", "zu"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 0 or n = 1
if intEqualsAny(ops.I, 0) ||
ops.NequalsAny(1) {
@@ -21,9 +21,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ff", "fr", "hy", "kab"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ff", "fr", "hy", "kab"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 0,1
if intEqualsAny(ops.I, 0, 1) {
return One
@@ -31,9 +31,19 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ast", "ca", "de", "en", "et", "fi", "fy", "gl", "it", "ji", "nl", "sv", "sw", "ur", "yi"}, &PluralSpec{
+ RegisterPluralSpec([]string{"pt"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
+ // i = 0..1
+ if intInRange(ops.I, 0, 1) {
+ return One
+ }
+ return Other
+ },
+ })
+ RegisterPluralSpec([]string{"ast", "ca", "de", "en", "et", "fi", "fy", "gl", "it", "ji", "nl", "sv", "sw", "ur", "yi"}, &PluralSpec{
+ Plurals: newPluralSet(One, Other),
+ PluralFunc: func(ops *Operands) Plural {
// i = 1 and v = 0
if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
return One
@@ -41,9 +51,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"si"}, &PluralSpec{
+ RegisterPluralSpec([]string{"si"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0,1 or i = 0 and f = 1
if ops.NequalsAny(0, 1) ||
intEqualsAny(ops.I, 0) && intEqualsAny(ops.F, 1) {
@@ -52,9 +62,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ak", "bh", "guw", "ln", "mg", "nso", "pa", "ti", "wa"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ak", "bh", "guw", "ln", "mg", "nso", "pa", "ti", "wa"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0..1
if ops.NinRange(0, 1) {
return One
@@ -62,9 +72,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"tzm"}, &PluralSpec{
+ RegisterPluralSpec([]string{"tzm"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0..1 or n = 11..99
if ops.NinRange(0, 1) ||
ops.NinRange(11, 99) {
@@ -73,19 +83,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"pt"}, &PluralSpec{
- Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
- // n = 0..2 and n != 2
- if ops.NinRange(0, 2) && !ops.NequalsAny(2) {
- return One
- }
- return Other
- },
- })
- registerPluralSpec([]string{"af", "asa", "az", "bem", "bez", "bg", "brx", "ce", "cgg", "chr", "ckb", "dv", "ee", "el", "eo", "es", "eu", "fo", "fur", "gsw", "ha", "haw", "hu", "jgo", "jmc", "ka", "kaj", "kcg", "kk", "kkj", "kl", "ks", "ksb", "ku", "ky", "lb", "lg", "mas", "mgo", "ml", "mn", "nah", "nb", "nd", "ne", "nn", "nnh", "no", "nr", "ny", "nyn", "om", "or", "os", "pap", "ps", "rm", "rof", "rwk", "saq", "sdh", "seh", "sn", "so", "sq", "ss", "ssy", "st", "syr", "ta", "te", "teo", "tig", "tk", "tn", "tr", "ts", "ug", "uz", "ve", "vo", "vun", "wae", "xh", "xog"}, &PluralSpec{
+ RegisterPluralSpec([]string{"af", "asa", "az", "bem", "bez", "bg", "brx", "ce", "cgg", "chr", "ckb", "dv", "ee", "el", "eo", "es", "eu", "fo", "fur", "gsw", "ha", "haw", "hu", "jgo", "jmc", "ka", "kaj", "kcg", "kk", "kkj", "kl", "ks", "ksb", "ku", "ky", "lb", "lg", "mas", "mgo", "ml", "mn", "nah", "nb", "nd", "ne", "nn", "nnh", "no", "nr", "ny", "nyn", "om", "or", "os", "pap", "ps", "rm", "rof", "rwk", "saq", "sdh", "seh", "sn", "so", "sq", "ss", "ssy", "st", "syr", "ta", "te", "teo", "tig", "tk", "tn", "tr", "ts", "ug", "uz", "ve", "vo", "vun", "wae", "xh", "xog"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1
if ops.NequalsAny(1) {
return One
@@ -93,19 +93,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"pt_PT"}, &PluralSpec{
- Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
- // n = 1 and v = 0
- if ops.NequalsAny(1) && intEqualsAny(ops.V, 0) {
- return One
- }
- return Other
- },
- })
- registerPluralSpec([]string{"da"}, &PluralSpec{
+ RegisterPluralSpec([]string{"da"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1 or t != 0 and i = 0,1
if ops.NequalsAny(1) ||
!intEqualsAny(ops.T, 0) && intEqualsAny(ops.I, 0, 1) {
@@ -114,9 +104,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"is"}, &PluralSpec{
+ RegisterPluralSpec([]string{"is"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// t = 0 and i % 10 = 1 and i % 100 != 11 or t != 0
if intEqualsAny(ops.T, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) ||
!intEqualsAny(ops.T, 0) {
@@ -125,9 +115,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"mk"}, &PluralSpec{
+ RegisterPluralSpec([]string{"mk"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 10 = 1 or f % 10 = 1
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) ||
intEqualsAny(ops.F%10, 1) {
@@ -136,9 +126,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"fil", "tl"}, &PluralSpec{
+ RegisterPluralSpec([]string{"fil", "tl"}, &PluralSpec{
Plurals: newPluralSet(One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i = 1,2,3 or v = 0 and i % 10 != 4,6,9 or v != 0 and f % 10 != 4,6,9
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I, 1, 2, 3) ||
intEqualsAny(ops.V, 0) && !intEqualsAny(ops.I%10, 4, 6, 9) ||
@@ -148,9 +138,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"lv", "prg"}, &PluralSpec{
+ RegisterPluralSpec([]string{"lv", "prg"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n % 10 = 0 or n % 100 = 11..19 or v = 2 and f % 100 = 11..19
if ops.NmodEqualsAny(10, 0) ||
ops.NmodInRange(100, 11, 19) ||
@@ -166,9 +156,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"lag"}, &PluralSpec{
+ RegisterPluralSpec([]string{"lag"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0
if ops.NequalsAny(0) {
return Zero
@@ -180,9 +170,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ksh"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ksh"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0
if ops.NequalsAny(0) {
return Zero
@@ -194,9 +184,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"iu", "kw", "naq", "se", "sma", "smi", "smj", "smn", "sms"}, &PluralSpec{
+ RegisterPluralSpec([]string{"iu", "kw", "naq", "se", "sma", "smi", "smj", "smn", "sms"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1
if ops.NequalsAny(1) {
return One
@@ -208,9 +198,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"shi"}, &PluralSpec{
+ RegisterPluralSpec([]string{"shi"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 0 or n = 1
if intEqualsAny(ops.I, 0) ||
ops.NequalsAny(1) {
@@ -223,9 +213,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"mo", "ro"}, &PluralSpec{
+ RegisterPluralSpec([]string{"mo", "ro"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 1 and v = 0
if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
return One
@@ -239,9 +229,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"bs", "hr", "sh", "sr"}, &PluralSpec{
+ RegisterPluralSpec([]string{"bs", "hr", "sh", "sr"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 10 = 1 and i % 100 != 11 or f % 10 = 1 and f % 100 != 11
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) ||
intEqualsAny(ops.F%10, 1) && !intEqualsAny(ops.F%100, 11) {
@@ -255,9 +245,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"gd"}, &PluralSpec{
+ RegisterPluralSpec([]string{"gd"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1,11
if ops.NequalsAny(1, 11) {
return One
@@ -273,9 +263,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"sl"}, &PluralSpec{
+ RegisterPluralSpec([]string{"sl"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 100 = 1
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 1) {
return One
@@ -292,9 +282,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"dsb", "hsb"}, &PluralSpec{
+ RegisterPluralSpec([]string{"dsb", "hsb"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 100 = 1 or f % 100 = 1
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%100, 1) ||
intEqualsAny(ops.F%100, 1) {
@@ -313,9 +303,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"he", "iw"}, &PluralSpec{
+ RegisterPluralSpec([]string{"he", "iw"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 1 and v = 0
if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
return One
@@ -331,9 +321,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"cs", "sk"}, &PluralSpec{
+ RegisterPluralSpec([]string{"cs", "sk"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 1 and v = 0
if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
return One
@@ -349,9 +339,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"pl"}, &PluralSpec{
+ RegisterPluralSpec([]string{"pl"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// i = 1 and v = 0
if intEqualsAny(ops.I, 1) && intEqualsAny(ops.V, 0) {
return One
@@ -369,9 +359,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"be"}, &PluralSpec{
+ RegisterPluralSpec([]string{"be"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n % 10 = 1 and n % 100 != 11
if ops.NmodEqualsAny(10, 1) && !ops.NmodEqualsAny(100, 11) {
return One
@@ -389,9 +379,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"lt"}, &PluralSpec{
+ RegisterPluralSpec([]string{"lt"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n % 10 = 1 and n % 100 != 11..19
if ops.NmodEqualsAny(10, 1) && !ops.NmodInRange(100, 11, 19) {
return One
@@ -407,9 +397,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"mt"}, &PluralSpec{
+ RegisterPluralSpec([]string{"mt"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1
if ops.NequalsAny(1) {
return One
@@ -426,9 +416,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ru", "uk"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ru", "uk"}, &PluralSpec{
Plurals: newPluralSet(One, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 10 = 1 and i % 100 != 11
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) && !intEqualsAny(ops.I%100, 11) {
return One
@@ -446,9 +436,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"br"}, &PluralSpec{
+ RegisterPluralSpec([]string{"br"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n % 10 = 1 and n % 100 != 11,71,91
if ops.NmodEqualsAny(10, 1) && !ops.NmodEqualsAny(100, 11, 71, 91) {
return One
@@ -468,9 +458,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ga"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ga"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 1
if ops.NequalsAny(1) {
return One
@@ -490,9 +480,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"gv"}, &PluralSpec{
+ RegisterPluralSpec([]string{"gv"}, &PluralSpec{
Plurals: newPluralSet(One, Two, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// v = 0 and i % 10 = 1
if intEqualsAny(ops.V, 0) && intEqualsAny(ops.I%10, 1) {
return One
@@ -512,9 +502,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"ar"}, &PluralSpec{
+ RegisterPluralSpec([]string{"ar", "ars"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Two, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0
if ops.NequalsAny(0) {
return Zero
@@ -538,9 +528,9 @@ func init() {
return Other
},
})
- registerPluralSpec([]string{"cy"}, &PluralSpec{
+ RegisterPluralSpec([]string{"cy"}, &PluralSpec{
Plurals: newPluralSet(Zero, One, Two, Few, Many, Other),
- PluralFunc: func(ops *operands) Plural {
+ PluralFunc: func(ops *Operands) Plural {
// n = 0
if ops.NequalsAny(0) {
return Zero
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
index 5dd74b2f..17c32609 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/plural_translation.go
@@ -50,7 +50,7 @@ func (pt *pluralTranslation) Normalize(l *language.Language) Translation {
func (pt *pluralTranslation) Backfill(src Translation) Translation {
for pc, t := range pt.templates {
- if t == nil || t.src == "" {
+ if (t == nil || t.src == "") && src != nil {
pt.templates[pc] = src.Template(language.Other)
}
}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
index 9fcba5a1..a76c8c94 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/nicksnyder/go-i18n/i18n/translation/single_translation.go
@@ -37,7 +37,7 @@ func (st *singleTranslation) Normalize(language *language.Language) Translation
}
func (st *singleTranslation) Backfill(src Translation) Translation {
- if st.template == nil || st.template.src == "" {
+ if (st.template == nil || st.template.src == "") && src != nil {
st.template = src.Template(language.Other)
}
return st
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/LICENSE.txt b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/LICENSE.txt
deleted file mode 100644
index ead98cf0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/dce.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/dce.go
deleted file mode 100644
index 50a0f2d0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/dce.go
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "encoding/binary"
- "fmt"
- "os"
-)
-
-// A Domain represents a Version 2 domain
-type Domain byte
-
-// Domain constants for DCE Security (Version 2) UUIDs.
-const (
- Person = Domain(0)
- Group = Domain(1)
- Org = Domain(2)
-)
-
-// NewDCESecurity returns a DCE Security (Version 2) UUID.
-//
-// The domain should be one of Person, Group or Org.
-// On a POSIX system the id should be the users UID for the Person
-// domain and the users GID for the Group. The meaning of id for
-// the domain Org or on non-POSIX systems is site defined.
-//
-// For a given domain/id pair the same token may be returned for up to
-// 7 minutes and 10 seconds.
-func NewDCESecurity(domain Domain, id uint32) UUID {
- uuid := NewUUID()
- if uuid != nil {
- uuid[6] = (uuid[6] & 0x0f) | 0x20 // Version 2
- uuid[9] = byte(domain)
- binary.BigEndian.PutUint32(uuid[0:], id)
- }
- return uuid
-}
-
-// NewDCEPerson returns a DCE Security (Version 2) UUID in the person
-// domain with the id returned by os.Getuid.
-//
-// NewDCEPerson(Person, uint32(os.Getuid()))
-func NewDCEPerson() UUID {
- return NewDCESecurity(Person, uint32(os.Getuid()))
-}
-
-// NewDCEGroup returns a DCE Security (Version 2) UUID in the group
-// domain with the id returned by os.Getgid.
-//
-// NewDCEGroup(Group, uint32(os.Getgid()))
-func NewDCEGroup() UUID {
- return NewDCESecurity(Group, uint32(os.Getgid()))
-}
-
-// Domain returns the domain for a Version 2 UUID or false.
-func (uuid UUID) Domain() (Domain, bool) {
- if v, _ := uuid.Version(); v != 2 {
- return 0, false
- }
- return Domain(uuid[9]), true
-}
-
-// Id returns the id for a Version 2 UUID or false.
-func (uuid UUID) Id() (uint32, bool) {
- if v, _ := uuid.Version(); v != 2 {
- return 0, false
- }
- return binary.BigEndian.Uint32(uuid[0:4]), true
-}
-
-func (d Domain) String() string {
- switch d {
- case Person:
- return "Person"
- case Group:
- return "Group"
- case Org:
- return "Org"
- }
- return fmt.Sprintf("Domain%d", int(d))
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/doc.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/doc.go
deleted file mode 100644
index d8bd013e..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/doc.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The uuid package generates and inspects UUIDs.
-//
-// UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security Services.
-package uuid
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/hash.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/hash.go
deleted file mode 100644
index a0420c1e..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/hash.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "crypto/md5"
- "crypto/sha1"
- "hash"
-)
-
-// Well known Name Space IDs and UUIDs
-var (
- NameSpace_DNS = Parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
- NameSpace_URL = Parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
- NameSpace_OID = Parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
- NameSpace_X500 = Parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
- NIL = Parse("00000000-0000-0000-0000-000000000000")
-)
-
-// NewHash returns a new UUID derived from the hash of space concatenated with
-// data generated by h. The hash should be at least 16 byte in length. The
-// first 16 bytes of the hash are used to form the UUID. The version of the
-// UUID will be the lower 4 bits of version. NewHash is used to implement
-// NewMD5 and NewSHA1.
-func NewHash(h hash.Hash, space UUID, data []byte, version int) UUID {
- h.Reset()
- h.Write(space)
- h.Write([]byte(data))
- s := h.Sum(nil)
- uuid := make([]byte, 16)
- copy(uuid, s)
- uuid[6] = (uuid[6] & 0x0f) | uint8((version&0xf)<<4)
- uuid[8] = (uuid[8] & 0x3f) | 0x80 // RFC 4122 variant
- return uuid
-}
-
-// NewMD5 returns a new MD5 (Version 3) UUID based on the
-// supplied name space and data.
-//
-// NewHash(md5.New(), space, data, 3)
-func NewMD5(space UUID, data []byte) UUID {
- return NewHash(md5.New(), space, data, 3)
-}
-
-// NewSHA1 returns a new SHA1 (Version 5) UUID based on the
-// supplied name space and data.
-//
-// NewHash(sha1.New(), space, data, 5)
-func NewSHA1(space UUID, data []byte) UUID {
- return NewHash(sha1.New(), space, data, 5)
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/marshal.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/marshal.go
deleted file mode 100644
index 6621dd54..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/marshal.go
+++ /dev/null
@@ -1,83 +0,0 @@
-// Copyright 2016 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "errors"
- "fmt"
-)
-
-// MarshalText implements encoding.TextMarshaler.
-func (u UUID) MarshalText() ([]byte, error) {
- if len(u) != 16 {
- return nil, nil
- }
- var js [36]byte
- encodeHex(js[:], u)
- return js[:], nil
-}
-
-// UnmarshalText implements encoding.TextUnmarshaler.
-func (u *UUID) UnmarshalText(data []byte) error {
- if len(data) == 0 {
- return nil
- }
- id := Parse(string(data))
- if id == nil {
- return errors.New("invalid UUID")
- }
- *u = id
- return nil
-}
-
-// MarshalBinary implements encoding.BinaryMarshaler.
-func (u UUID) MarshalBinary() ([]byte, error) {
- return u[:], nil
-}
-
-// UnmarshalBinary implements encoding.BinaryUnmarshaler.
-func (u *UUID) UnmarshalBinary(data []byte) error {
- if len(data) == 0 {
- return nil
- }
- if len(data) != 16 {
- return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
- }
- var id [16]byte
- copy(id[:], data)
- *u = id[:]
- return nil
-}
-
-// MarshalText implements encoding.TextMarshaler.
-func (u Array) MarshalText() ([]byte, error) {
- var js [36]byte
- encodeHex(js[:], u[:])
- return js[:], nil
-}
-
-// UnmarshalText implements encoding.TextUnmarshaler.
-func (u *Array) UnmarshalText(data []byte) error {
- id := Parse(string(data))
- if id == nil {
- return errors.New("invalid UUID")
- }
- *u = id.Array()
- return nil
-}
-
-// MarshalBinary implements encoding.BinaryMarshaler.
-func (u Array) MarshalBinary() ([]byte, error) {
- return u[:], nil
-}
-
-// UnmarshalBinary implements encoding.BinaryUnmarshaler.
-func (u *Array) UnmarshalBinary(data []byte) error {
- if len(data) != 16 {
- return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
- }
- copy(u[:], data)
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/node.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/node.go
deleted file mode 100644
index 42d60da8..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/node.go
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "net"
- "sync"
-)
-
-var (
- nodeMu sync.Mutex
- interfaces []net.Interface // cached list of interfaces
- ifname string // name of interface being used
- nodeID []byte // hardware for version 1 UUIDs
-)
-
-// NodeInterface returns the name of the interface from which the NodeID was
-// derived. The interface "user" is returned if the NodeID was set by
-// SetNodeID.
-func NodeInterface() string {
- defer nodeMu.Unlock()
- nodeMu.Lock()
- return ifname
-}
-
-// SetNodeInterface selects the hardware address to be used for Version 1 UUIDs.
-// If name is "" then the first usable interface found will be used or a random
-// Node ID will be generated. If a named interface cannot be found then false
-// is returned.
-//
-// SetNodeInterface never fails when name is "".
-func SetNodeInterface(name string) bool {
- defer nodeMu.Unlock()
- nodeMu.Lock()
- return setNodeInterface(name)
-}
-
-func setNodeInterface(name string) bool {
- if interfaces == nil {
- var err error
- interfaces, err = net.Interfaces()
- if err != nil && name != "" {
- return false
- }
- }
-
- for _, ifs := range interfaces {
- if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) {
- if setNodeID(ifs.HardwareAddr) {
- ifname = ifs.Name
- return true
- }
- }
- }
-
- // We found no interfaces with a valid hardware address. If name
- // does not specify a specific interface generate a random Node ID
- // (section 4.1.6)
- if name == "" {
- if nodeID == nil {
- nodeID = make([]byte, 6)
- }
- randomBits(nodeID)
- return true
- }
- return false
-}
-
-// NodeID returns a slice of a copy of the current Node ID, setting the Node ID
-// if not already set.
-func NodeID() []byte {
- defer nodeMu.Unlock()
- nodeMu.Lock()
- if nodeID == nil {
- setNodeInterface("")
- }
- nid := make([]byte, 6)
- copy(nid, nodeID)
- return nid
-}
-
-// SetNodeID sets the Node ID to be used for Version 1 UUIDs. The first 6 bytes
-// of id are used. If id is less than 6 bytes then false is returned and the
-// Node ID is not set.
-func SetNodeID(id []byte) bool {
- defer nodeMu.Unlock()
- nodeMu.Lock()
- if setNodeID(id) {
- ifname = "user"
- return true
- }
- return false
-}
-
-func setNodeID(id []byte) bool {
- if len(id) < 6 {
- return false
- }
- if nodeID == nil {
- nodeID = make([]byte, 6)
- }
- copy(nodeID, id)
- return true
-}
-
-// NodeID returns the 6 byte node id encoded in uuid. It returns nil if uuid is
-// not valid. The NodeID is only well defined for version 1 and 2 UUIDs.
-func (uuid UUID) NodeID() []byte {
- if len(uuid) != 16 {
- return nil
- }
- node := make([]byte, 6)
- copy(node, uuid[10:])
- return node
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/sql.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/sql.go
deleted file mode 100644
index d015bfd1..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/sql.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2015 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "database/sql/driver"
- "errors"
- "fmt"
-)
-
-// Scan implements sql.Scanner so UUIDs can be read from databases transparently
-// Currently, database types that map to string and []byte are supported. Please
-// consult database-specific driver documentation for matching types.
-func (uuid *UUID) Scan(src interface{}) error {
- switch src.(type) {
- case string:
- // if an empty UUID comes from a table, we return a null UUID
- if src.(string) == "" {
- return nil
- }
-
- // see uuid.Parse for required string format
- parsed := Parse(src.(string))
-
- if parsed == nil {
- return errors.New("Scan: invalid UUID format")
- }
-
- *uuid = parsed
- case []byte:
- b := src.([]byte)
-
- // if an empty UUID comes from a table, we return a null UUID
- if len(b) == 0 {
- return nil
- }
-
- // assumes a simple slice of bytes if 16 bytes
- // otherwise attempts to parse
- if len(b) == 16 {
- *uuid = UUID(b)
- } else {
- u := Parse(string(b))
-
- if u == nil {
- return errors.New("Scan: invalid UUID format")
- }
-
- *uuid = u
- }
-
- default:
- return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
- }
-
- return nil
-}
-
-// Value implements sql.Valuer so that UUIDs can be written to databases
-// transparently. Currently, UUIDs map to strings. Please consult
-// database-specific driver documentation for matching types.
-func (uuid UUID) Value() (driver.Value, error) {
- return uuid.String(), nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/time.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/time.go
deleted file mode 100644
index eedf2421..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/time.go
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright 2014 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "encoding/binary"
- "sync"
- "time"
-)
-
-// A Time represents a time as the number of 100's of nanoseconds since 15 Oct
-// 1582.
-type Time int64
-
-const (
- lillian = 2299160 // Julian day of 15 Oct 1582
- unix = 2440587 // Julian day of 1 Jan 1970
- epoch = unix - lillian // Days between epochs
- g1582 = epoch * 86400 // seconds between epochs
- g1582ns100 = g1582 * 10000000 // 100s of a nanoseconds between epochs
-)
-
-var (
- timeMu sync.Mutex
- lasttime uint64 // last time we returned
- clock_seq uint16 // clock sequence for this run
-
- timeNow = time.Now // for testing
-)
-
-// UnixTime converts t the number of seconds and nanoseconds using the Unix
-// epoch of 1 Jan 1970.
-func (t Time) UnixTime() (sec, nsec int64) {
- sec = int64(t - g1582ns100)
- nsec = (sec % 10000000) * 100
- sec /= 10000000
- return sec, nsec
-}
-
-// GetTime returns the current Time (100s of nanoseconds since 15 Oct 1582) and
-// clock sequence as well as adjusting the clock sequence as needed. An error
-// is returned if the current time cannot be determined.
-func GetTime() (Time, uint16, error) {
- defer timeMu.Unlock()
- timeMu.Lock()
- return getTime()
-}
-
-func getTime() (Time, uint16, error) {
- t := timeNow()
-
- // If we don't have a clock sequence already, set one.
- if clock_seq == 0 {
- setClockSequence(-1)
- }
- now := uint64(t.UnixNano()/100) + g1582ns100
-
- // If time has gone backwards with this clock sequence then we
- // increment the clock sequence
- if now <= lasttime {
- clock_seq = ((clock_seq + 1) & 0x3fff) | 0x8000
- }
- lasttime = now
- return Time(now), clock_seq, nil
-}
-
-// ClockSequence returns the current clock sequence, generating one if not
-// already set. The clock sequence is only used for Version 1 UUIDs.
-//
-// The uuid package does not use global static storage for the clock sequence or
-// the last time a UUID was generated. Unless SetClockSequence a new random
-// clock sequence is generated the first time a clock sequence is requested by
-// ClockSequence, GetTime, or NewUUID. (section 4.2.1.1) sequence is generated
-// for
-func ClockSequence() int {
- defer timeMu.Unlock()
- timeMu.Lock()
- return clockSequence()
-}
-
-func clockSequence() int {
- if clock_seq == 0 {
- setClockSequence(-1)
- }
- return int(clock_seq & 0x3fff)
-}
-
-// SetClockSeq sets the clock sequence to the lower 14 bits of seq. Setting to
-// -1 causes a new sequence to be generated.
-func SetClockSequence(seq int) {
- defer timeMu.Unlock()
- timeMu.Lock()
- setClockSequence(seq)
-}
-
-func setClockSequence(seq int) {
- if seq == -1 {
- var b [2]byte
- randomBits(b[:]) // clock sequence
- seq = int(b[0])<<8 | int(b[1])
- }
- old_seq := clock_seq
- clock_seq = uint16(seq&0x3fff) | 0x8000 // Set our variant
- if old_seq != clock_seq {
- lasttime = 0
- }
-}
-
-// Time returns the time in 100s of nanoseconds since 15 Oct 1582 encoded in
-// uuid. It returns false if uuid is not valid. The time is only well defined
-// for version 1 and 2 UUIDs.
-func (uuid UUID) Time() (Time, bool) {
- if len(uuid) != 16 {
- return 0, false
- }
- time := int64(binary.BigEndian.Uint32(uuid[0:4]))
- time |= int64(binary.BigEndian.Uint16(uuid[4:6])) << 32
- time |= int64(binary.BigEndian.Uint16(uuid[6:8])&0xfff) << 48
- return Time(time), true
-}
-
-// ClockSequence returns the clock sequence encoded in uuid. It returns false
-// if uuid is not valid. The clock sequence is only well defined for version 1
-// and 2 UUIDs.
-func (uuid UUID) ClockSequence() (int, bool) {
- if len(uuid) != 16 {
- return 0, false
- }
- return int(binary.BigEndian.Uint16(uuid[8:10])) & 0x3fff, true
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/util.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/util.go
deleted file mode 100644
index fc8e052c..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/util.go
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "io"
-)
-
-// randomBits completely fills slice b with random data.
-func randomBits(b []byte) {
- if _, err := io.ReadFull(rander, b); err != nil {
- panic(err.Error()) // rand should never fail
- }
-}
-
-// xvalues returns the value of a byte as a hexadecimal digit or 255.
-var xvalues = [256]byte{
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255,
- 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
-}
-
-// xtob converts the the first two hex bytes of x into a byte.
-func xtob(x string) (byte, bool) {
- b1 := xvalues[x[0]]
- b2 := xvalues[x[1]]
- return (b1 << 4) | b2, b1 != 255 && b2 != 255
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/uuid.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/uuid.go
deleted file mode 100644
index 7c643cf0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/uuid.go
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "bytes"
- "crypto/rand"
- "encoding/hex"
- "fmt"
- "io"
- "strings"
-)
-
-// Array is a pass-by-value UUID that can be used as an effecient key in a map.
-type Array [16]byte
-
-// UUID converts uuid into a slice.
-func (uuid Array) UUID() UUID {
- return uuid[:]
-}
-
-// String returns the string representation of uuid,
-// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
-func (uuid Array) String() string {
- return uuid.UUID().String()
-}
-
-// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC
-// 4122.
-type UUID []byte
-
-// A Version represents a UUIDs version.
-type Version byte
-
-// A Variant represents a UUIDs variant.
-type Variant byte
-
-// Constants returned by Variant.
-const (
- Invalid = Variant(iota) // Invalid UUID
- RFC4122 // The variant specified in RFC4122
- Reserved // Reserved, NCS backward compatibility.
- Microsoft // Reserved, Microsoft Corporation backward compatibility.
- Future // Reserved for future definition.
-)
-
-var rander = rand.Reader // random function
-
-// New returns a new random (version 4) UUID as a string. It is a convenience
-// function for NewRandom().String().
-func New() string {
- return NewRandom().String()
-}
-
-// Parse decodes s into a UUID or returns nil. Both the UUID form of
-// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
-// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded.
-func Parse(s string) UUID {
- if len(s) == 36+9 {
- if strings.ToLower(s[:9]) != "urn:uuid:" {
- return nil
- }
- s = s[9:]
- } else if len(s) != 36 {
- return nil
- }
- if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
- return nil
- }
- var uuid [16]byte
- for i, x := range [16]int{
- 0, 2, 4, 6,
- 9, 11,
- 14, 16,
- 19, 21,
- 24, 26, 28, 30, 32, 34} {
- if v, ok := xtob(s[x:]); !ok {
- return nil
- } else {
- uuid[i] = v
- }
- }
- return uuid[:]
-}
-
-// Equal returns true if uuid1 and uuid2 are equal.
-func Equal(uuid1, uuid2 UUID) bool {
- return bytes.Equal(uuid1, uuid2)
-}
-
-// Array returns an array representation of uuid that can be used as a map key.
-// Array panics if uuid is not valid.
-func (uuid UUID) Array() Array {
- if len(uuid) != 16 {
- panic("invalid uuid")
- }
- var a Array
- copy(a[:], uuid)
- return a
-}
-
-// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
-// , or "" if uuid is invalid.
-func (uuid UUID) String() string {
- if len(uuid) != 16 {
- return ""
- }
- var buf [36]byte
- encodeHex(buf[:], uuid)
- return string(buf[:])
-}
-
-// URN returns the RFC 2141 URN form of uuid,
-// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, or "" if uuid is invalid.
-func (uuid UUID) URN() string {
- if len(uuid) != 16 {
- return ""
- }
- var buf [36 + 9]byte
- copy(buf[:], "urn:uuid:")
- encodeHex(buf[9:], uuid)
- return string(buf[:])
-}
-
-func encodeHex(dst []byte, uuid UUID) {
- hex.Encode(dst[:], uuid[:4])
- dst[8] = '-'
- hex.Encode(dst[9:13], uuid[4:6])
- dst[13] = '-'
- hex.Encode(dst[14:18], uuid[6:8])
- dst[18] = '-'
- hex.Encode(dst[19:23], uuid[8:10])
- dst[23] = '-'
- hex.Encode(dst[24:], uuid[10:])
-}
-
-// Variant returns the variant encoded in uuid. It returns Invalid if
-// uuid is invalid.
-func (uuid UUID) Variant() Variant {
- if len(uuid) != 16 {
- return Invalid
- }
- switch {
- case (uuid[8] & 0xc0) == 0x80:
- return RFC4122
- case (uuid[8] & 0xe0) == 0xc0:
- return Microsoft
- case (uuid[8] & 0xe0) == 0xe0:
- return Future
- default:
- return Reserved
- }
-}
-
-// Version returns the version of uuid. It returns false if uuid is not
-// valid.
-func (uuid UUID) Version() (Version, bool) {
- if len(uuid) != 16 {
- return 0, false
- }
- return Version(uuid[6] >> 4), true
-}
-
-func (v Version) String() string {
- if v > 15 {
- return fmt.Sprintf("BAD_VERSION_%d", v)
- }
- return fmt.Sprintf("VERSION_%d", v)
-}
-
-func (v Variant) String() string {
- switch v {
- case RFC4122:
- return "RFC4122"
- case Reserved:
- return "Reserved"
- case Microsoft:
- return "Microsoft"
- case Future:
- return "Future"
- case Invalid:
- return "Invalid"
- }
- return fmt.Sprintf("BadVariant%d", int(v))
-}
-
-// SetRand sets the random number generator to r, which implements io.Reader.
-// If r.Read returns an error when the package requests random data then
-// a panic will be issued.
-//
-// Calling SetRand with nil sets the random number generator to the default
-// generator.
-func SetRand(r io.Reader) {
- if r == nil {
- rander = rand.Reader
- return
- }
- rander = r
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version1.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version1.go
deleted file mode 100644
index 0127eacf..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version1.go
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "encoding/binary"
-)
-
-// NewUUID returns a Version 1 UUID based on the current NodeID and clock
-// sequence, and the current time. If the NodeID has not been set by SetNodeID
-// or SetNodeInterface then it will be set automatically. If the NodeID cannot
-// be set NewUUID returns nil. If clock sequence has not been set by
-// SetClockSequence then it will be set automatically. If GetTime fails to
-// return the current NewUUID returns nil.
-func NewUUID() UUID {
- if nodeID == nil {
- SetNodeInterface("")
- }
-
- now, seq, err := GetTime()
- if err != nil {
- return nil
- }
-
- uuid := make([]byte, 16)
-
- time_low := uint32(now & 0xffffffff)
- time_mid := uint16((now >> 32) & 0xffff)
- time_hi := uint16((now >> 48) & 0x0fff)
- time_hi |= 0x1000 // Version 1
-
- binary.BigEndian.PutUint32(uuid[0:], time_low)
- binary.BigEndian.PutUint16(uuid[4:], time_mid)
- binary.BigEndian.PutUint16(uuid[6:], time_hi)
- binary.BigEndian.PutUint16(uuid[8:], seq)
- copy(uuid[10:], nodeID)
-
- return uuid
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version4.go b/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version4.go
deleted file mode 100644
index b3d4a368..00000000
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pborman/uuid/version4.go
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2011 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-// Random returns a Random (Version 4) UUID or panics.
-//
-// The strength of the UUIDs is based on the strength of the crypto/rand
-// package.
-//
-// A note about uniqueness derived from from the UUID Wikipedia entry:
-//
-// Randomly generated UUIDs have 122 random bits. One's annual risk of being
-// hit by a meteorite is estimated to be one chance in 17 billion, that
-// means the probability is about 0.00000000006 (6 × 10−11),
-// equivalent to the odds of creating a few tens of trillions of UUIDs in a
-// year and having one duplicate.
-func NewRandom() UUID {
- uuid := make([]byte, 16)
- randomBits([]byte(uuid))
- uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4
- uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10
- return uuid
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/doc.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/doc.go
index 3c89619e..d5fd98c0 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/doc.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/doc.go
@@ -17,7 +17,7 @@
// JSONPath-like queries
//
// The package github.com/pelletier/go-toml/query implements a system
-// similar to JSONPath to quickly retrive elements of a TOML document using a
+// similar to JSONPath to quickly retrieve elements of a TOML document using a
// single expression. See the package documentation for more information.
//
package toml
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/fuzz.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/fuzz.go
new file mode 100644
index 00000000..14570c8d
--- /dev/null
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/fuzz.go
@@ -0,0 +1,31 @@
+// +build gofuzz
+
+package toml
+
+func Fuzz(data []byte) int {
+ tree, err := LoadBytes(data)
+ if err != nil {
+ if tree != nil {
+ panic("tree must be nil if there is an error")
+ }
+ return 0
+ }
+
+ str, err := tree.ToTomlString()
+ if err != nil {
+ if str != "" {
+ panic(`str must be "" if there is an error`)
+ }
+ panic(err)
+ }
+
+ tree, err = Load(str)
+ if err != nil {
+ if tree != nil {
+ panic("tree must be nil if there is an error")
+ }
+ return 0
+ }
+
+ return 1
+}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/keysparsing.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/keysparsing.go
index d62ca5fd..9707c688 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/keysparsing.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/keysparsing.go
@@ -6,15 +6,37 @@ import (
"bytes"
"errors"
"fmt"
+ "strconv"
"unicode"
)
+var escapeSequenceMap = map[rune]rune{
+ 'b': '\b',
+ 't': '\t',
+ 'n': '\n',
+ 'f': '\f',
+ 'r': '\r',
+ '"': '"',
+ '\\': '\\',
+}
+
+type parseKeyState int
+
+const (
+ BARE parseKeyState = iota
+ BASIC
+ LITERAL
+ ESC
+ UNICODE_4
+ UNICODE_8
+)
+
func parseKey(key string) ([]string, error) {
groups := []string{}
var buffer bytes.Buffer
- inQuotes := false
+ var hex bytes.Buffer
+ state := BARE
wasInQuotes := false
- escapeNext := false
ignoreSpace := true
expectDot := false
@@ -25,25 +47,67 @@ func parseKey(key string) ([]string, error) {
}
ignoreSpace = false
}
- if escapeNext {
- buffer.WriteRune(char)
- escapeNext = false
+
+ if state == ESC {
+ if char == 'u' {
+ state = UNICODE_4
+ hex.Reset()
+ } else if char == 'U' {
+ state = UNICODE_8
+ hex.Reset()
+ } else if newChar, ok := escapeSequenceMap[char]; ok {
+ buffer.WriteRune(newChar)
+ state = BASIC
+ } else {
+ return nil, fmt.Errorf(`invalid escape sequence \%c`, char)
+ }
+ continue
+ }
+
+ if state == UNICODE_4 || state == UNICODE_8 {
+ if isHexDigit(char) {
+ hex.WriteRune(char)
+ }
+ if (state == UNICODE_4 && hex.Len() == 4) || (state == UNICODE_8 && hex.Len() == 8) {
+ if value, err := strconv.ParseInt(hex.String(), 16, 32); err == nil {
+ buffer.WriteRune(rune(value))
+ } else {
+ return nil, err
+ }
+ state = BASIC
+ }
continue
}
+
switch char {
case '\\':
- escapeNext = true
- continue
+ if state == BASIC {
+ state = ESC
+ } else if state == LITERAL {
+ buffer.WriteRune(char)
+ }
+ case '\'':
+ if state == BARE {
+ state = LITERAL
+ } else if state == LITERAL {
+ groups = append(groups, buffer.String())
+ buffer.Reset()
+ wasInQuotes = true
+ state = BARE
+ }
+ expectDot = false
case '"':
- if inQuotes {
+ if state == BARE {
+ state = BASIC
+ } else if state == BASIC {
groups = append(groups, buffer.String())
buffer.Reset()
+ state = BARE
wasInQuotes = true
}
- inQuotes = !inQuotes
expectDot = false
case '.':
- if inQuotes {
+ if state != BARE {
buffer.WriteRune(char)
} else {
if !wasInQuotes {
@@ -58,28 +122,31 @@ func parseKey(key string) ([]string, error) {
wasInQuotes = false
}
case ' ':
- if inQuotes {
+ if state == BASIC {
buffer.WriteRune(char)
} else {
expectDot = true
}
default:
- if !inQuotes && !isValidBareChar(char) {
- return nil, fmt.Errorf("invalid bare character: %c", char)
- }
- if !inQuotes && expectDot {
- return nil, errors.New("what?")
+ if state == BARE {
+ if !isValidBareChar(char) {
+ return nil, fmt.Errorf("invalid bare character: %c", char)
+ } else if expectDot {
+ return nil, errors.New("what?")
+ }
}
buffer.WriteRune(char)
expectDot = false
}
}
- if inQuotes {
- return nil, errors.New("mismatched quotes")
- }
- if escapeNext {
+
+ // state must be BARE at the end
+ if state == ESC {
return nil, errors.New("unfinished escape sequence")
+ } else if state != BARE {
+ return nil, errors.New("mismatched quotes")
}
+
if buffer.Len() > 0 {
groups = append(groups, buffer.String())
}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/marshal.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/marshal.go
index 1a3176f9..1bbdfa1d 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/marshal.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/marshal.go
@@ -4,17 +4,29 @@ import (
"bytes"
"errors"
"fmt"
+ "io"
"reflect"
+ "strconv"
"strings"
"time"
)
type tomlOpts struct {
name string
+ comment string
+ commented bool
include bool
omitempty bool
}
+type encOpts struct {
+ quoteMapKeys bool
+}
+
+var encOptsDefaults = encOpts{
+ quoteMapKeys: false,
+}
+
var timeType = reflect.TypeOf(time.Time{})
var marshalerType = reflect.TypeOf(new(Marshaler)).Elem()
@@ -94,8 +106,15 @@ encoder, except that there is no concept of a Marshaler interface or MarshalTOML
function for sub-structs, and currently only definite types can be marshaled
(i.e. no `interface{}`).
+The following struct annotations are supported:
+
+ toml:"Field" Overrides the field's name to output.
+ omitempty When set, empty values and groups are not emitted.
+ comment:"comment" Emits a # comment on the same line. This supports new lines.
+ commented:"true" Emits the value as commented.
+
Note that pointers are automatically assigned the "omitempty" option, as TOML
-explicity does not handle null values (saying instead the label should be
+explicitly does not handle null values (saying instead the label should be
dropped).
Tree structural types and corresponding marshal types:
@@ -115,6 +134,47 @@ Tree primitive types and corresponding marshal types:
time.Time time.Time{}, pointers to same
*/
func Marshal(v interface{}) ([]byte, error) {
+ return NewEncoder(nil).marshal(v)
+}
+
+// Encoder writes TOML values to an output stream.
+type Encoder struct {
+ w io.Writer
+ encOpts
+}
+
+// NewEncoder returns a new encoder that writes to w.
+func NewEncoder(w io.Writer) *Encoder {
+ return &Encoder{
+ w: w,
+ encOpts: encOptsDefaults,
+ }
+}
+
+// Encode writes the TOML encoding of v to the stream.
+//
+// See the documentation for Marshal for details.
+func (e *Encoder) Encode(v interface{}) error {
+ b, err := e.marshal(v)
+ if err != nil {
+ return err
+ }
+ if _, err := e.w.Write(b); err != nil {
+ return err
+ }
+ return nil
+}
+
+// QuoteMapKeys sets up the encoder to encode
+// maps with string type keys with quoted TOML keys.
+//
+// This relieves the character limitations on map keys.
+func (e *Encoder) QuoteMapKeys(v bool) *Encoder {
+ e.quoteMapKeys = v
+ return e
+}
+
+func (e *Encoder) marshal(v interface{}) ([]byte, error) {
mtype := reflect.TypeOf(v)
if mtype.Kind() != reflect.Struct {
return []byte{}, errors.New("Only a struct can be marshaled to TOML")
@@ -123,7 +183,7 @@ func Marshal(v interface{}) ([]byte, error) {
if isCustomMarshaler(mtype) {
return callCustomMarshaler(sval)
}
- t, err := valueToTree(mtype, sval)
+ t, err := e.valueToTree(mtype, sval)
if err != nil {
return []byte{}, err
}
@@ -132,9 +192,9 @@ func Marshal(v interface{}) ([]byte, error) {
}
// Convert given marshal struct or map value to toml tree
-func valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) {
+func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) {
if mtype.Kind() == reflect.Ptr {
- return valueToTree(mtype.Elem(), mval.Elem())
+ return e.valueToTree(mtype.Elem(), mval.Elem())
}
tval := newTree()
switch mtype.Kind() {
@@ -143,31 +203,39 @@ func valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) {
mtypef, mvalf := mtype.Field(i), mval.Field(i)
opts := tomlOptions(mtypef)
if opts.include && (!opts.omitempty || !isZero(mvalf)) {
- val, err := valueToToml(mtypef.Type, mvalf)
+ val, err := e.valueToToml(mtypef.Type, mvalf)
if err != nil {
return nil, err
}
- tval.Set(opts.name, val)
+ tval.Set(opts.name, opts.comment, opts.commented, val)
}
}
case reflect.Map:
for _, key := range mval.MapKeys() {
mvalf := mval.MapIndex(key)
- val, err := valueToToml(mtype.Elem(), mvalf)
+ val, err := e.valueToToml(mtype.Elem(), mvalf)
if err != nil {
return nil, err
}
- tval.Set(key.String(), val)
+ if e.quoteMapKeys {
+ keyStr, err := tomlValueStringRepresentation(key.String())
+ if err != nil {
+ return nil, err
+ }
+ tval.SetPath([]string{keyStr}, "", false, val)
+ } else {
+ tval.Set(key.String(), "", false, val)
+ }
}
}
return tval, nil
}
// Convert given marshal slice to slice of Toml trees
-func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) {
+func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) {
tval := make([]*Tree, mval.Len(), mval.Len())
for i := 0; i < mval.Len(); i++ {
- val, err := valueToTree(mtype.Elem(), mval.Index(i))
+ val, err := e.valueToTree(mtype.Elem(), mval.Index(i))
if err != nil {
return nil, err
}
@@ -177,10 +245,10 @@ func valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) {
}
// Convert given marshal slice to slice of toml values
-func valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
+func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
tval := make([]interface{}, mval.Len(), mval.Len())
for i := 0; i < mval.Len(); i++ {
- val, err := valueToToml(mtype.Elem(), mval.Index(i))
+ val, err := e.valueToToml(mtype.Elem(), mval.Index(i))
if err != nil {
return nil, err
}
@@ -190,19 +258,19 @@ func valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, err
}
// Convert given marshal value to toml value
-func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
+func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
if mtype.Kind() == reflect.Ptr {
- return valueToToml(mtype.Elem(), mval.Elem())
+ return e.valueToToml(mtype.Elem(), mval.Elem())
}
switch {
case isCustomMarshaler(mtype):
return callCustomMarshaler(mval)
case isTree(mtype):
- return valueToTree(mtype, mval)
+ return e.valueToTree(mtype, mval)
case isTreeSlice(mtype):
- return valueToTreeSlice(mtype, mval)
+ return e.valueToTreeSlice(mtype, mval)
case isOtherSlice(mtype):
- return valueToOtherSlice(mtype, mval)
+ return e.valueToOtherSlice(mtype, mval)
default:
switch mtype.Kind() {
case reflect.Bool:
@@ -227,17 +295,16 @@ func valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) {
// Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for
// sub-structs, and only definite types can be unmarshaled.
func (t *Tree) Unmarshal(v interface{}) error {
- mtype := reflect.TypeOf(v)
- if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct {
- return errors.New("Only a pointer to struct can be unmarshaled from TOML")
- }
+ d := Decoder{tval: t}
+ return d.unmarshal(v)
+}
- sval, err := valueFromTree(mtype.Elem(), t)
- if err != nil {
- return err
- }
- reflect.ValueOf(v).Elem().Set(sval)
- return nil
+// Marshal returns the TOML encoding of Tree.
+// See Marshal() documentation for types mapping table.
+func (t *Tree) Marshal() ([]byte, error) {
+ var buf bytes.Buffer
+ err := NewEncoder(&buf).Encode(t)
+ return buf.Bytes(), err
}
// Unmarshal parses the TOML-encoded data and stores the result in the value
@@ -246,6 +313,10 @@ func (t *Tree) Unmarshal(v interface{}) error {
// sub-structs, and currently only definite types can be unmarshaled to (i.e. no
// `interface{}`).
//
+// The following struct annotations are supported:
+//
+// toml:"Field" Overrides the field's name to map to.
+//
// See Marshal() documentation for types mapping table.
func Unmarshal(data []byte, v interface{}) error {
t, err := LoadReader(bytes.NewReader(data))
@@ -255,10 +326,52 @@ func Unmarshal(data []byte, v interface{}) error {
return t.Unmarshal(v)
}
+// Decoder reads and decodes TOML values from an input stream.
+type Decoder struct {
+ r io.Reader
+ tval *Tree
+ encOpts
+}
+
+// NewDecoder returns a new decoder that reads from r.
+func NewDecoder(r io.Reader) *Decoder {
+ return &Decoder{
+ r: r,
+ encOpts: encOptsDefaults,
+ }
+}
+
+// Decode reads a TOML-encoded value from it's input
+// and unmarshals it in the value pointed at by v.
+//
+// See the documentation for Marshal for details.
+func (d *Decoder) Decode(v interface{}) error {
+ var err error
+ d.tval, err = LoadReader(d.r)
+ if err != nil {
+ return err
+ }
+ return d.unmarshal(v)
+}
+
+func (d *Decoder) unmarshal(v interface{}) error {
+ mtype := reflect.TypeOf(v)
+ if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct {
+ return errors.New("Only a pointer to struct can be unmarshaled from TOML")
+ }
+
+ sval, err := d.valueFromTree(mtype.Elem(), d.tval)
+ if err != nil {
+ return err
+ }
+ reflect.ValueOf(v).Elem().Set(sval)
+ return nil
+}
+
// Convert toml tree to marshal struct or map, using marshal type
-func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
+func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
if mtype.Kind() == reflect.Ptr {
- return unwrapPointer(mtype, tval)
+ return d.unwrapPointer(mtype, tval)
}
var mval reflect.Value
switch mtype.Kind() {
@@ -276,7 +389,7 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
continue
}
val := tval.Get(key)
- mvalf, err := valueFromToml(mtypef.Type, val)
+ mvalf, err := d.valueFromToml(mtypef.Type, val)
if err != nil {
return mval, formatError(err, tval.GetPosition(key))
}
@@ -288,8 +401,9 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
case reflect.Map:
mval = reflect.MakeMap(mtype)
for _, key := range tval.Keys() {
- val := tval.Get(key)
- mvalf, err := valueFromToml(mtype.Elem(), val)
+ // TODO: path splits key
+ val := tval.GetPath([]string{key})
+ mvalf, err := d.valueFromToml(mtype.Elem(), val)
if err != nil {
return mval, formatError(err, tval.GetPosition(key))
}
@@ -300,10 +414,10 @@ func valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) {
}
// Convert toml value to marshal struct/map slice, using marshal type
-func valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) {
+func (d *Decoder) valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) {
mval := reflect.MakeSlice(mtype, len(tval), len(tval))
for i := 0; i < len(tval); i++ {
- val, err := valueFromTree(mtype.Elem(), tval[i])
+ val, err := d.valueFromTree(mtype.Elem(), tval[i])
if err != nil {
return mval, err
}
@@ -313,10 +427,10 @@ func valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error)
}
// Convert toml value to marshal primitive slice, using marshal type
-func valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) {
+func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) {
mval := reflect.MakeSlice(mtype, len(tval), len(tval))
for i := 0; i < len(tval); i++ {
- val, err := valueFromToml(mtype.Elem(), tval[i])
+ val, err := d.valueFromToml(mtype.Elem(), tval[i])
if err != nil {
return mval, err
}
@@ -326,17 +440,30 @@ func valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value,
}
// Convert toml value to marshal value, using marshal type
-func valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) {
+func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) {
if mtype.Kind() == reflect.Ptr {
- return unwrapPointer(mtype, tval)
+ return d.unwrapPointer(mtype, tval)
}
- switch {
- case isTree(mtype):
- return valueFromTree(mtype, tval.(*Tree))
- case isTreeSlice(mtype):
- return valueFromTreeSlice(mtype, tval.([]*Tree))
- case isOtherSlice(mtype):
- return valueFromOtherSlice(mtype, tval.([]interface{}))
+
+ switch tval.(type) {
+ case *Tree:
+ if isTree(mtype) {
+ return d.valueFromTree(mtype, tval.(*Tree))
+ } else {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval)
+ }
+ case []*Tree:
+ if isTreeSlice(mtype) {
+ return d.valueFromTreeSlice(mtype, tval.([]*Tree))
+ } else {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to trees", tval, tval)
+ }
+ case []interface{}:
+ if isOtherSlice(mtype) {
+ return d.valueFromOtherSlice(mtype, tval.([]interface{}))
+ } else {
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval)
+ }
default:
switch mtype.Kind() {
case reflect.Bool:
@@ -430,13 +557,13 @@ func valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error)
}
return reflect.ValueOf(val), nil
default:
- return reflect.ValueOf(nil), fmt.Errorf("Unmarshal can't handle %v(%v)", mtype, mtype.Kind())
+ return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind())
}
}
}
-func unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) {
- val, err := valueFromToml(mtype.Elem(), tval)
+func (d *Decoder) unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) {
+ val, err := d.valueFromToml(mtype.Elem(), tval)
if err != nil {
return reflect.ValueOf(nil), err
}
@@ -448,7 +575,12 @@ func unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error)
func tomlOptions(vf reflect.StructField) tomlOpts {
tag := vf.Tag.Get("toml")
parse := strings.Split(tag, ",")
- result := tomlOpts{vf.Name, true, false}
+ var comment string
+ if c := vf.Tag.Get("comment"); c != "" {
+ comment = c
+ }
+ commented, _ := strconv.ParseBool(vf.Tag.Get("commented"))
+ result := tomlOpts{name: vf.Name, comment: comment, commented: commented, include: true, omitempty: false}
if parse[0] != "" {
if parse[0] == "-" && len(parse) == 1 {
result.include = false
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/parser.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/parser.go
index 8ee49cb5..d492a1e6 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/parser.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/parser.go
@@ -110,7 +110,7 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
newTree := newTree()
newTree.position = startToken.Position
array = append(array, newTree)
- p.tree.SetPath(p.currentTable, array)
+ p.tree.SetPath(p.currentTable, "", false, array)
// remove all keys that were children of this table array
prefix := key.val + "."
@@ -205,7 +205,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
case *Tree, []*Tree:
toInsert = value
default:
- toInsert = &tomlValue{value, key.Position}
+ toInsert = &tomlValue{value: value, position: key.Position}
}
targetNode.values[keyVal] = toInsert
return p.parseStart
@@ -299,7 +299,7 @@ Loop:
key := p.getToken()
p.assume(tokenEqual)
value := p.parseRvalue()
- tree.Set(key.val, value)
+ tree.Set(key.val, "", false, value)
case tokenComma:
if previous == nil {
p.raiseError(follow, "inline table cannot start with a comma")
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/doc.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/doc.go
index f999fc96..ed63c110 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/doc.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/doc.go
@@ -139,7 +139,7 @@
// Compiled Queries
//
// Queries may be executed directly on a Tree object, or compiled ahead
-// of time and executed discretely. The former is more convienent, but has the
+// of time and executed discretely. The former is more convenient, but has the
// penalty of having to recompile the query expression each time.
//
// // basic query
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/parser.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/parser.go
index e4f91b97..5f69b70d 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/parser.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/query/parser.go
@@ -253,7 +253,7 @@ func (p *queryParser) parseFilterExpr() queryParserStateFn {
}
tok = p.getToken()
if tok.typ != tokenKey && tok.typ != tokenString {
- return p.parseError(tok, "expected key or string for filter funciton name")
+ return p.parseError(tok, "expected key or string for filter function name")
}
name := tok.val
tok = p.getToken()
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/toml.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/toml.go
index 64f19ed3..c3e32437 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/toml.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/toml.go
@@ -11,14 +11,18 @@ import (
)
type tomlValue struct {
- value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list
- position Position
+ value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list
+ comment string
+ commented bool
+ position Position
}
// Tree is the result of the parsing of a TOML file.
type Tree struct {
- values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree
- position Position
+ values map[string]interface{} // string -> *tomlValue, *Tree, []*Tree
+ comment string
+ commented bool
+ position Position
}
func newTree() *Tree {
@@ -177,14 +181,14 @@ func (t *Tree) GetDefault(key string, def interface{}) interface{} {
// Set an element in the tree.
// Key is a dot-separated path (e.g. a.b.c).
// Creates all necessary intermediate trees, if needed.
-func (t *Tree) Set(key string, value interface{}) {
- t.SetPath(strings.Split(key, "."), value)
+func (t *Tree) Set(key string, comment string, commented bool, value interface{}) {
+ t.SetPath(strings.Split(key, "."), comment, commented, value)
}
// SetPath sets an element in the tree.
// Keys is an array of path elements (e.g. {"a","b","c"}).
// Creates all necessary intermediate trees, if needed.
-func (t *Tree) SetPath(keys []string, value interface{}) {
+func (t *Tree) SetPath(keys []string, comment string, commented bool, value interface{}) {
subtree := t
for _, intermediateKey := range keys[:len(keys)-1] {
nextTree, exists := subtree.values[intermediateKey]
@@ -209,13 +213,17 @@ func (t *Tree) SetPath(keys []string, value interface{}) {
switch value.(type) {
case *Tree:
+ tt := value.(*Tree)
+ tt.comment = comment
toInsert = value
case []*Tree:
toInsert = value
case *tomlValue:
- toInsert = value
+ tt := value.(*tomlValue)
+ tt.comment = comment
+ toInsert = tt
default:
- toInsert = &tomlValue{value: value}
+ toInsert = &tomlValue{value: value, comment: comment, commented: commented}
}
subtree.values[keys[len(keys)-1]] = toInsert
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_create.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_create.go
index 19d1c0dc..79610e9b 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_create.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_create.go
@@ -104,7 +104,7 @@ func sliceToTree(object interface{}) (interface{}, error) {
}
arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue))
}
- return &tomlValue{arrayValue.Interface(), Position{}}, nil
+ return &tomlValue{value: arrayValue.Interface(), position: Position{}}, nil
}
func toTree(object interface{}) (interface{}, error) {
@@ -127,7 +127,7 @@ func toTree(object interface{}) (interface{}, error) {
}
values[key.String()] = newValue
}
- return &Tree{values, Position{}}, nil
+ return &Tree{values: values, position: Position{}}, nil
}
if value.Kind() == reflect.Array || value.Kind() == reflect.Slice {
@@ -138,5 +138,5 @@ func toTree(object interface{}) (interface{}, error) {
if err != nil {
return nil, err
}
- return &tomlValue{simpleValue, Position{}}, nil
+ return &tomlValue{value: simpleValue, position: Position{}}, nil
}
diff --git a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_write.go b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_write.go
index ca763ed5..449f35a4 100644
--- a/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_write.go
+++ b/vendor/github.com/mattermost/platform/vendor/github.com/pelletier/go-toml/tomltree_write.go
@@ -118,7 +118,24 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (
return bytesCount, err
}
- writtenBytesCount, err := writeStrings(w, indent, k, " = ", repr, "\n")
+ if v.comment != "" {
+ comment := strings.Replace(v.comment, "\n", "\n"+indent+"#", -1)
+ start := "# "
+ if strings.HasPrefix(comment, "#") {
+ start = ""
+ }
+ writtenBytesCountComment, errc := writeStrings(w, "\n", indent, start, comment, "\n")
+ bytesCount += int64(writtenBytesCountComment)
+ if errc != nil {
+ return bytesCount, errc
+ }
+ }
+
+ var commented string
+ if v.commented {
+ commented = "# "
+ }
+ writtenBytesCount, err := writeStrings(w, indent, commented, k, " = ", repr, "\n")
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
@@ -132,11 +149,31 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (
if keyspace != "" {
combinedKey = keyspace + "." + combinedKey
}
+ var commented string
+ if t.commented {
+ commented = "# "
+ }
switch node := v.(type) {
// node has to be of those two types given how keys are sorted above
case *Tree:
- writtenBytesCount, err := writeStrings(w, "\n", indent, "[", combinedKey, "]\n")
+ tv, ok := t.values[k].(*Tree)
+ if !ok {
+ return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k])
+ }
+ if tv.comment != "" {
+ comment := strings.Replace(tv.comment, "\n", "\n"+indent+"#", -1)
+ start := "# "
+ if strings.HasPrefix(comment, "#") {
+ start = ""
+ }
+ writtenBytesCountComment, errc := writeStrings(w, "\n", indent, start, comment)
+ bytesCount += int64(writtenBytesCountComment)
+ if errc != nil {
+ return bytesCount, errc
+ }
+ }
+ writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[", combinedKey, "]\n")
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
@@ -147,7 +184,7 @@ func (t *Tree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (
}
case []*Tree:
for _, subTree := range node {
- writtenBytesCount, err := writeStrings(w, "\n", indent, "[[", combinedKey, "]]\n")
+ writtenBytesCount, err := writeStrings(w, "\n", indent, commented, "[[", combinedKey, "]]\n")
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/LICENSE.txt b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/LICENSE.txt
deleted file mode 100644
index ead98cf0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/base64.go b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/base64.go
deleted file mode 100644
index fc311609..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/base64.go
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package bcrypt
-
-import "encoding/base64"
-
-const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
-
-var bcEncoding = base64.NewEncoding(alphabet)
-
-func base64Encode(src []byte) []byte {
- n := bcEncoding.EncodedLen(len(src))
- dst := make([]byte, n)
- bcEncoding.Encode(dst, src)
- for dst[n-1] == '=' {
- n--
- }
- return dst[:n]
-}
-
-func base64Decode(src []byte) ([]byte, error) {
- numOfEquals := 4 - (len(src) % 4)
- for i := 0; i < numOfEquals; i++ {
- src = append(src, '=')
- }
-
- dst := make([]byte, bcEncoding.DecodedLen(len(src)))
- n, err := bcEncoding.Decode(dst, src)
- if err != nil {
- return nil, err
- }
- return dst[:n], nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/bcrypt.go b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
deleted file mode 100644
index 202fa8af..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/bcrypt/bcrypt.go
+++ /dev/null
@@ -1,295 +0,0 @@
-// Copyright 2011 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package bcrypt implements Provos and Mazières's bcrypt adaptive hashing
-// algorithm. See http://www.usenix.org/event/usenix99/provos/provos.pdf
-package bcrypt // import "golang.org/x/crypto/bcrypt"
-
-// The code is a port of Provos and Mazières's C implementation.
-import (
- "crypto/rand"
- "crypto/subtle"
- "errors"
- "fmt"
- "io"
- "strconv"
-
- "golang.org/x/crypto/blowfish"
-)
-
-const (
- MinCost int = 4 // the minimum allowable cost as passed in to GenerateFromPassword
- MaxCost int = 31 // the maximum allowable cost as passed in to GenerateFromPassword
- DefaultCost int = 10 // the cost that will actually be set if a cost below MinCost is passed into GenerateFromPassword
-)
-
-// The error returned from CompareHashAndPassword when a password and hash do
-// not match.
-var ErrMismatchedHashAndPassword = errors.New("crypto/bcrypt: hashedPassword is not the hash of the given password")
-
-// The error returned from CompareHashAndPassword when a hash is too short to
-// be a bcrypt hash.
-var ErrHashTooShort = errors.New("crypto/bcrypt: hashedSecret too short to be a bcrypted password")
-
-// The error returned from CompareHashAndPassword when a hash was created with
-// a bcrypt algorithm newer than this implementation.
-type HashVersionTooNewError byte
-
-func (hv HashVersionTooNewError) Error() string {
- return fmt.Sprintf("crypto/bcrypt: bcrypt algorithm version '%c' requested is newer than current version '%c'", byte(hv), majorVersion)
-}
-
-// The error returned from CompareHashAndPassword when a hash starts with something other than '$'
-type InvalidHashPrefixError byte
-
-func (ih InvalidHashPrefixError) Error() string {
- return fmt.Sprintf("crypto/bcrypt: bcrypt hashes must start with '$', but hashedSecret started with '%c'", byte(ih))
-}
-
-type InvalidCostError int
-
-func (ic InvalidCostError) Error() string {
- return fmt.Sprintf("crypto/bcrypt: cost %d is outside allowed range (%d,%d)", int(ic), int(MinCost), int(MaxCost))
-}
-
-const (
- majorVersion = '2'
- minorVersion = 'a'
- maxSaltSize = 16
- maxCryptedHashSize = 23
- encodedSaltSize = 22
- encodedHashSize = 31
- minHashSize = 59
-)
-
-// magicCipherData is an IV for the 64 Blowfish encryption calls in
-// bcrypt(). It's the string "OrpheanBeholderScryDoubt" in big-endian bytes.
-var magicCipherData = []byte{
- 0x4f, 0x72, 0x70, 0x68,
- 0x65, 0x61, 0x6e, 0x42,
- 0x65, 0x68, 0x6f, 0x6c,
- 0x64, 0x65, 0x72, 0x53,
- 0x63, 0x72, 0x79, 0x44,
- 0x6f, 0x75, 0x62, 0x74,
-}
-
-type hashed struct {
- hash []byte
- salt []byte
- cost int // allowed range is MinCost to MaxCost
- major byte
- minor byte
-}
-
-// GenerateFromPassword returns the bcrypt hash of the password at the given
-// cost. If the cost given is less than MinCost, the cost will be set to
-// DefaultCost, instead. Use CompareHashAndPassword, as defined in this package,
-// to compare the returned hashed password with its cleartext version.
-func GenerateFromPassword(password []byte, cost int) ([]byte, error) {
- p, err := newFromPassword(password, cost)
- if err != nil {
- return nil, err
- }
- return p.Hash(), nil
-}
-
-// CompareHashAndPassword compares a bcrypt hashed password with its possible
-// plaintext equivalent. Returns nil on success, or an error on failure.
-func CompareHashAndPassword(hashedPassword, password []byte) error {
- p, err := newFromHash(hashedPassword)
- if err != nil {
- return err
- }
-
- otherHash, err := bcrypt(password, p.cost, p.salt)
- if err != nil {
- return err
- }
-
- otherP := &hashed{otherHash, p.salt, p.cost, p.major, p.minor}
- if subtle.ConstantTimeCompare(p.Hash(), otherP.Hash()) == 1 {
- return nil
- }
-
- return ErrMismatchedHashAndPassword
-}
-
-// Cost returns the hashing cost used to create the given hashed
-// password. When, in the future, the hashing cost of a password system needs
-// to be increased in order to adjust for greater computational power, this
-// function allows one to establish which passwords need to be updated.
-func Cost(hashedPassword []byte) (int, error) {
- p, err := newFromHash(hashedPassword)
- if err != nil {
- return 0, err
- }
- return p.cost, nil
-}
-
-func newFromPassword(password []byte, cost int) (*hashed, error) {
- if cost < MinCost {
- cost = DefaultCost
- }
- p := new(hashed)
- p.major = majorVersion
- p.minor = minorVersion
-
- err := checkCost(cost)
- if err != nil {
- return nil, err
- }
- p.cost = cost
-
- unencodedSalt := make([]byte, maxSaltSize)
- _, err = io.ReadFull(rand.Reader, unencodedSalt)
- if err != nil {
- return nil, err
- }
-
- p.salt = base64Encode(unencodedSalt)
- hash, err := bcrypt(password, p.cost, p.salt)
- if err != nil {
- return nil, err
- }
- p.hash = hash
- return p, err
-}
-
-func newFromHash(hashedSecret []byte) (*hashed, error) {
- if len(hashedSecret) < minHashSize {
- return nil, ErrHashTooShort
- }
- p := new(hashed)
- n, err := p.decodeVersion(hashedSecret)
- if err != nil {
- return nil, err
- }
- hashedSecret = hashedSecret[n:]
- n, err = p.decodeCost(hashedSecret)
- if err != nil {
- return nil, err
- }
- hashedSecret = hashedSecret[n:]
-
- // The "+2" is here because we'll have to append at most 2 '=' to the salt
- // when base64 decoding it in expensiveBlowfishSetup().
- p.salt = make([]byte, encodedSaltSize, encodedSaltSize+2)
- copy(p.salt, hashedSecret[:encodedSaltSize])
-
- hashedSecret = hashedSecret[encodedSaltSize:]
- p.hash = make([]byte, len(hashedSecret))
- copy(p.hash, hashedSecret)
-
- return p, nil
-}
-
-func bcrypt(password []byte, cost int, salt []byte) ([]byte, error) {
- cipherData := make([]byte, len(magicCipherData))
- copy(cipherData, magicCipherData)
-
- c, err := expensiveBlowfishSetup(password, uint32(cost), salt)
- if err != nil {
- return nil, err
- }
-
- for i := 0; i < 24; i += 8 {
- for j := 0; j < 64; j++ {
- c.Encrypt(cipherData[i:i+8], cipherData[i:i+8])
- }
- }
-
- // Bug compatibility with C bcrypt implementations. We only encode 23 of
- // the 24 bytes encrypted.
- hsh := base64Encode(cipherData[:maxCryptedHashSize])
- return hsh, nil
-}
-
-func expensiveBlowfishSetup(key []byte, cost uint32, salt []byte) (*blowfish.Cipher, error) {
- csalt, err := base64Decode(salt)
- if err != nil {
- return nil, err
- }
-
- // Bug compatibility with C bcrypt implementations. They use the trailing
- // NULL in the key string during expansion.
- // We copy the key to prevent changing the underlying array.
- ckey := append(key[:len(key):len(key)], 0)
-
- c, err := blowfish.NewSaltedCipher(ckey, csalt)
- if err != nil {
- return nil, err
- }
-
- var i, rounds uint64
- rounds = 1 << cost
- for i = 0; i < rounds; i++ {
- blowfish.ExpandKey(ckey, c)
- blowfish.ExpandKey(csalt, c)
- }
-
- return c, nil
-}
-
-func (p *hashed) Hash() []byte {
- arr := make([]byte, 60)
- arr[0] = '$'
- arr[1] = p.major
- n := 2
- if p.minor != 0 {
- arr[2] = p.minor
- n = 3
- }
- arr[n] = '$'
- n += 1
- copy(arr[n:], []byte(fmt.Sprintf("%02d", p.cost)))
- n += 2
- arr[n] = '$'
- n += 1
- copy(arr[n:], p.salt)
- n += encodedSaltSize
- copy(arr[n:], p.hash)
- n += encodedHashSize
- return arr[:n]
-}
-
-func (p *hashed) decodeVersion(sbytes []byte) (int, error) {
- if sbytes[0] != '$' {
- return -1, InvalidHashPrefixError(sbytes[0])
- }
- if sbytes[1] > majorVersion {
- return -1, HashVersionTooNewError(sbytes[1])
- }
- p.major = sbytes[1]
- n := 3
- if sbytes[2] != '$' {
- p.minor = sbytes[2]
- n++
- }
- return n, nil
-}
-
-// sbytes should begin where decodeVersion left off.
-func (p *hashed) decodeCost(sbytes []byte) (int, error) {
- cost, err := strconv.Atoi(string(sbytes[0:2]))
- if err != nil {
- return -1, err
- }
- err = checkCost(cost)
- if err != nil {
- return -1, err
- }
- p.cost = cost
- return 3, nil
-}
-
-func (p *hashed) String() string {
- return fmt.Sprintf("&{hash: %#v, salt: %#v, cost: %d, major: %c, minor: %c}", string(p.hash), p.salt, p.cost, p.major, p.minor)
-}
-
-func checkCost(cost int) error {
- if cost < MinCost || cost > MaxCost {
- return InvalidCostError(cost)
- }
- return nil
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/LICENSE.txt b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/LICENSE.txt
deleted file mode 100644
index ead98cf0..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/LICENSE.txt
+++ /dev/null
@@ -1,897 +0,0 @@
-Mattermost Licensing
-
-SOFTWARE LICENSING
-
-You are licensed to use compiled versions of the Mattermost platform produced by Mattermost, Inc. under an MIT LICENSE
-
-- See MIT-COMPILED-LICENSE.md included in compiled versions for details
-
-You may be licensed to use source code to create compiled versions not produced by Mattermost, Inc. in one of two ways:
-
-1. Under the Free Software Foundation’s GNU AGPL v.3.0, subject to the exceptions outlined in this policy; or
-2. Under a commercial license available from Mattermost, Inc. by contacting commercial@mattermost.com
-
-You are licensed to use the source code in Admin Tools and Configuration Files (templates/, config/, model/,
-webapp/client, webapp/fonts, webapp/i18n, webapp/images and all subdirectories thereof) under the Apache License v2.0.
-
-We promise that we will not enforce the copyleft provisions in AGPL v3.0 against you if your application (a) does not
-link to the Mattermost Platform directly, but exclusively uses the Mattermost Admin Tools and Configuration Files, and
-(b) you have not modified, added to or adapted the source code of Mattermost in a way that results in the creation of
-a “modified version” or “work based on” Mattermost as these terms are defined in the AGPL v3.0 license.
-
-MATTERMOST TRADEMARK GUIDELINES
-
-Your use of the mark Mattermost is subject to Mattermost, Inc's prior written approval and our organization’s Trademark
-Standards of Use at http://www.mattermost.org/trademark-standards-of-use/. For trademark approval or any questions
-you have about using these trademarks, please email trademark@mattermost.com
-
-------------------------------------------------------------------------------------------------------------------------------
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-------------------------------------------------------------------------------
-
-The software is released under the terms of the GNU Affero General Public
-License, version 3.
-
- GNU AFFERO GENERAL PUBLIC LICENSE
- Version 3, 19 November 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
- Preamble
-
- The GNU Affero General Public License is a free, copyleft license for
-software and other kinds of works, specifically designed to ensure
-cooperation with the community in the case of network server software.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-our General Public Licenses are intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- Developers that use our General Public Licenses protect your rights
-with two steps: (1) assert copyright on the software, and (2) offer
-you this License which gives you legal permission to copy, distribute
-and/or modify the software.
-
- A secondary benefit of defending all users' freedom is that
-improvements made in alternate versions of the program, if they
-receive widespread use, become available for other developers to
-incorporate. Many developers of free software are heartened and
-encouraged by the resulting cooperation. However, in the case of
-software used on network servers, this result may fail to come about.
-The GNU General Public License permits making a modified version and
-letting the public access it on a server without ever releasing its
-source code to the public.
-
- The GNU Affero General Public License is designed specifically to
-ensure that, in such cases, the modified source code becomes available
-to the community. It requires the operator of a network server to
-provide the source code of the modified version running there to the
-users of that server. Therefore, public use of a modified version, on
-a publicly accessible server, gives the public access to the source
-code of the modified version.
-
- An older license, called the Affero General Public License and
-published by Affero, was designed to accomplish similar goals. This is
-a different license, not a version of the Affero GPL, but Affero has
-released a new version of the Affero GPL which permits relicensing under
-this license.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU Affero General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Remote Network Interaction; Use with the GNU General Public License.
-
- Notwithstanding any other provision of this License, if you modify the
-Program, your modified version must prominently offer all users
-interacting with it remotely through a computer network (if your version
-supports such interaction) an opportunity to receive the Corresponding
-Source of your version by providing access to the Corresponding Source
-from a network server at no charge, through some standard or customary
-means of facilitating copying of software. This Corresponding Source
-shall include the Corresponding Source for any work covered by version 3
-of the GNU General Public License that is incorporated pursuant to the
-following paragraph.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the work with which it is combined will remain governed by version
-3 of the GNU General Public License.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU Affero General Public License from time to time. Such new versions
-will be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU Affero General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU Affero General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU Affero General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
-
- How to Apply These Terms to Your New Programs
-
- If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
- To do so, attach the following notices to the program. It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
- <one line to give the program's name and a brief idea of what it does.>
- Copyright (C) <year> <name of author>
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
- If your software can interact with users remotely through a computer
-network, you should also make sure that it provides a way for users to
-get its source. For example, if your program is a web application, its
-interface could display a "Source" link that leads users to an archive
-of the code. There are many ways you could offer source, and different
-solutions will be better for different programs; see section 13 for the
-specific requirements.
-
- You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU AGPL, see
-<http://www.gnu.org/licenses/>.
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/block.go b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/block.go
deleted file mode 100644
index 9d80f195..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/block.go
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package blowfish
-
-// getNextWord returns the next big-endian uint32 value from the byte slice
-// at the given position in a circular manner, updating the position.
-func getNextWord(b []byte, pos *int) uint32 {
- var w uint32
- j := *pos
- for i := 0; i < 4; i++ {
- w = w<<8 | uint32(b[j])
- j++
- if j >= len(b) {
- j = 0
- }
- }
- *pos = j
- return w
-}
-
-// ExpandKey performs a key expansion on the given *Cipher. Specifically, it
-// performs the Blowfish algorithm's key schedule which sets up the *Cipher's
-// pi and substitution tables for calls to Encrypt. This is used, primarily,
-// by the bcrypt package to reuse the Blowfish key schedule during its
-// set up. It's unlikely that you need to use this directly.
-func ExpandKey(key []byte, c *Cipher) {
- j := 0
- for i := 0; i < 18; i++ {
- // Using inlined getNextWord for performance.
- var d uint32
- for k := 0; k < 4; k++ {
- d = d<<8 | uint32(key[j])
- j++
- if j >= len(key) {
- j = 0
- }
- }
- c.p[i] ^= d
- }
-
- var l, r uint32
- for i := 0; i < 18; i += 2 {
- l, r = encryptBlock(l, r, c)
- c.p[i], c.p[i+1] = l, r
- }
-
- for i := 0; i < 256; i += 2 {
- l, r = encryptBlock(l, r, c)
- c.s0[i], c.s0[i+1] = l, r
- }
- for i := 0; i < 256; i += 2 {
- l, r = encryptBlock(l, r, c)
- c.s1[i], c.s1[i+1] = l, r
- }
- for i := 0; i < 256; i += 2 {
- l, r = encryptBlock(l, r, c)
- c.s2[i], c.s2[i+1] = l, r
- }
- for i := 0; i < 256; i += 2 {
- l, r = encryptBlock(l, r, c)
- c.s3[i], c.s3[i+1] = l, r
- }
-}
-
-// This is similar to ExpandKey, but folds the salt during the key
-// schedule. While ExpandKey is essentially expandKeyWithSalt with an all-zero
-// salt passed in, reusing ExpandKey turns out to be a place of inefficiency
-// and specializing it here is useful.
-func expandKeyWithSalt(key []byte, salt []byte, c *Cipher) {
- j := 0
- for i := 0; i < 18; i++ {
- c.p[i] ^= getNextWord(key, &j)
- }
-
- j = 0
- var l, r uint32
- for i := 0; i < 18; i += 2 {
- l ^= getNextWord(salt, &j)
- r ^= getNextWord(salt, &j)
- l, r = encryptBlock(l, r, c)
- c.p[i], c.p[i+1] = l, r
- }
-
- for i := 0; i < 256; i += 2 {
- l ^= getNextWord(salt, &j)
- r ^= getNextWord(salt, &j)
- l, r = encryptBlock(l, r, c)
- c.s0[i], c.s0[i+1] = l, r
- }
-
- for i := 0; i < 256; i += 2 {
- l ^= getNextWord(salt, &j)
- r ^= getNextWord(salt, &j)
- l, r = encryptBlock(l, r, c)
- c.s1[i], c.s1[i+1] = l, r
- }
-
- for i := 0; i < 256; i += 2 {
- l ^= getNextWord(salt, &j)
- r ^= getNextWord(salt, &j)
- l, r = encryptBlock(l, r, c)
- c.s2[i], c.s2[i+1] = l, r
- }
-
- for i := 0; i < 256; i += 2 {
- l ^= getNextWord(salt, &j)
- r ^= getNextWord(salt, &j)
- l, r = encryptBlock(l, r, c)
- c.s3[i], c.s3[i+1] = l, r
- }
-}
-
-func encryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
- xl, xr := l, r
- xl ^= c.p[0]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[1]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[2]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[3]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[4]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[5]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[6]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[7]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[8]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[9]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[10]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[11]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[12]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[13]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[14]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[15]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[16]
- xr ^= c.p[17]
- return xr, xl
-}
-
-func decryptBlock(l, r uint32, c *Cipher) (uint32, uint32) {
- xl, xr := l, r
- xl ^= c.p[17]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[16]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[15]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[14]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[13]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[12]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[11]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[10]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[9]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[8]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[7]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[6]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[5]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[4]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[3]
- xr ^= ((c.s0[byte(xl>>24)] + c.s1[byte(xl>>16)]) ^ c.s2[byte(xl>>8)]) + c.s3[byte(xl)] ^ c.p[2]
- xl ^= ((c.s0[byte(xr>>24)] + c.s1[byte(xr>>16)]) ^ c.s2[byte(xr>>8)]) + c.s3[byte(xr)] ^ c.p[1]
- xr ^= c.p[0]
- return xr, xl
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/cipher.go b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/cipher.go
deleted file mode 100644
index 2641dadd..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/cipher.go
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package blowfish implements Bruce Schneier's Blowfish encryption algorithm.
-package blowfish // import "golang.org/x/crypto/blowfish"
-
-// The code is a port of Bruce Schneier's C implementation.
-// See https://www.schneier.com/blowfish.html.
-
-import "strconv"
-
-// The Blowfish block size in bytes.
-const BlockSize = 8
-
-// A Cipher is an instance of Blowfish encryption using a particular key.
-type Cipher struct {
- p [18]uint32
- s0, s1, s2, s3 [256]uint32
-}
-
-type KeySizeError int
-
-func (k KeySizeError) Error() string {
- return "crypto/blowfish: invalid key size " + strconv.Itoa(int(k))
-}
-
-// NewCipher creates and returns a Cipher.
-// The key argument should be the Blowfish key, from 1 to 56 bytes.
-func NewCipher(key []byte) (*Cipher, error) {
- var result Cipher
- if k := len(key); k < 1 || k > 56 {
- return nil, KeySizeError(k)
- }
- initCipher(&result)
- ExpandKey(key, &result)
- return &result, nil
-}
-
-// NewSaltedCipher creates a returns a Cipher that folds a salt into its key
-// schedule. For most purposes, NewCipher, instead of NewSaltedCipher, is
-// sufficient and desirable. For bcrypt compatibility, the key can be over 56
-// bytes.
-func NewSaltedCipher(key, salt []byte) (*Cipher, error) {
- if len(salt) == 0 {
- return NewCipher(key)
- }
- var result Cipher
- if k := len(key); k < 1 {
- return nil, KeySizeError(k)
- }
- initCipher(&result)
- expandKeyWithSalt(key, salt, &result)
- return &result, nil
-}
-
-// BlockSize returns the Blowfish block size, 8 bytes.
-// It is necessary to satisfy the Block interface in the
-// package "crypto/cipher".
-func (c *Cipher) BlockSize() int { return BlockSize }
-
-// Encrypt encrypts the 8-byte buffer src using the key k
-// and stores the result in dst.
-// Note that for amounts of data larger than a block,
-// it is not safe to just call Encrypt on successive blocks;
-// instead, use an encryption mode like CBC (see crypto/cipher/cbc.go).
-func (c *Cipher) Encrypt(dst, src []byte) {
- l := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3])
- r := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7])
- l, r = encryptBlock(l, r, c)
- dst[0], dst[1], dst[2], dst[3] = byte(l>>24), byte(l>>16), byte(l>>8), byte(l)
- dst[4], dst[5], dst[6], dst[7] = byte(r>>24), byte(r>>16), byte(r>>8), byte(r)
-}
-
-// Decrypt decrypts the 8-byte buffer src using the key k
-// and stores the result in dst.
-func (c *Cipher) Decrypt(dst, src []byte) {
- l := uint32(src[0])<<24 | uint32(src[1])<<16 | uint32(src[2])<<8 | uint32(src[3])
- r := uint32(src[4])<<24 | uint32(src[5])<<16 | uint32(src[6])<<8 | uint32(src[7])
- l, r = decryptBlock(l, r, c)
- dst[0], dst[1], dst[2], dst[3] = byte(l>>24), byte(l>>16), byte(l>>8), byte(l)
- dst[4], dst[5], dst[6], dst[7] = byte(r>>24), byte(r>>16), byte(r>>8), byte(r)
-}
-
-func initCipher(c *Cipher) {
- copy(c.p[0:], p[0:])
- copy(c.s0[0:], s0[0:])
- copy(c.s1[0:], s1[0:])
- copy(c.s2[0:], s2[0:])
- copy(c.s3[0:], s3[0:])
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/const.go b/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/const.go
deleted file mode 100644
index d0407759..00000000
--- a/vendor/github.com/mattermost/platform/vendor/golang.org/x/crypto/blowfish/const.go
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright 2010 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The startup permutation array and substitution boxes.
-// They are the hexadecimal digits of PI; see:
-// https://www.schneier.com/code/constants.txt.
-
-package blowfish
-
-var s0 = [256]uint32{
- 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xb8e1afed, 0x6a267e96,
- 0xba7c9045, 0xf12c7f99, 0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
- 0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e, 0x0d95748f, 0x728eb658,
- 0x718bcd58, 0x82154aee, 0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
- 0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef, 0x8e79dcb0, 0x603a180e,
- 0x6c9e0e8b, 0xb01e8a3e, 0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
- 0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440, 0x55ca396a, 0x2aab10b6,
- 0xb4cc5c34, 0x1141e8ce, 0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
- 0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e, 0xafd6ba33, 0x6c24cf5c,
- 0x7a325381, 0x28958677, 0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
- 0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032, 0xef845d5d, 0xe98575b1,
- 0xdc262302, 0xeb651b88, 0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
- 0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e, 0x21c66842, 0xf6e96c9a,
- 0x670c9c61, 0xabd388f0, 0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
- 0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98, 0xa1f1651d, 0x39af0176,
- 0x66ca593e, 0x82430e88, 0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
- 0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6, 0x4ed3aa62, 0x363f7706,
- 0x1bfedf72, 0x429b023d, 0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
- 0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7, 0xe3fe501a, 0xb6794c3b,
- 0x976ce0bd, 0x04c006ba, 0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
- 0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f, 0x6dfc511f, 0x9b30952c,
- 0xcc814544, 0xaf5ebd09, 0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
- 0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb, 0x5579c0bd, 0x1a60320a,
- 0xd6a100c6, 0x402c7279, 0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
- 0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab, 0x323db5fa, 0xfd238760,
- 0x53317b48, 0x3e00df82, 0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
- 0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573, 0x695b27b0, 0xbbca58c8,
- 0xe1ffa35d, 0xb8f011a0, 0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
- 0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790, 0xe1ddf2da, 0xa4cb7e33,
- 0x62fb1341, 0xcee4c6e8, 0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
- 0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0, 0xd08ed1d0, 0xafc725e0,
- 0x8e3c5b2f, 0x8e7594b7, 0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
- 0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad, 0x2f2f2218, 0xbe0e1777,
- 0xea752dfe, 0x8b021fa1, 0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
- 0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9, 0x165fa266, 0x80957705,
- 0x93cc7314, 0x211a1477, 0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
- 0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49, 0x00250e2d, 0x2071b35e,
- 0x226800bb, 0x57b8e0af, 0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
- 0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5, 0x83260376, 0x6295cfa9,
- 0x11c81968, 0x4e734a41, 0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
- 0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400, 0x08ba6fb5, 0x571be91f,
- 0xf296ec6b, 0x2a0dd915, 0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
- 0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a,
-}
-
-var s1 = [256]uint32{
- 0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623, 0xad6ea6b0, 0x49a7df7d,
- 0x9cee60b8, 0x8fedb266, 0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
- 0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e, 0x3f54989a, 0x5b429d65,
- 0x6b8fe4d6, 0x99f73fd6, 0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
- 0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e, 0x09686b3f, 0x3ebaefc9,
- 0x3c971814, 0x6b6a70a1, 0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
- 0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8, 0xb03ada37, 0xf0500c0d,
- 0xf01c1f04, 0x0200b3ff, 0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
- 0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701, 0x3ae5e581, 0x37c2dadc,
- 0xc8b57634, 0x9af3dda7, 0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
- 0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331, 0x4e548b38, 0x4f6db908,
- 0x6f420d03, 0xf60a04bf, 0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
- 0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e, 0x5512721f, 0x2e6b7124,
- 0x501adde6, 0x9f84cd87, 0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
- 0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2, 0xef1c1847, 0x3215d908,
- 0xdd433b37, 0x24c2ba16, 0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
- 0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b, 0x043556f1, 0xd7a3c76b,
- 0x3c11183b, 0x5924a509, 0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
- 0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3, 0x771fe71c, 0x4e3d06fa,
- 0x2965dcb9, 0x99e71d0f, 0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
- 0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4, 0xf2f74ea7, 0x361d2b3d,
- 0x1939260f, 0x19c27960, 0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
- 0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28, 0xc332ddef, 0xbe6c5aa5,
- 0x65582185, 0x68ab9802, 0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
- 0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510, 0x13cca830, 0xeb61bd96,
- 0x0334fe1e, 0xaa0363cf, 0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
- 0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e, 0x648b1eaf, 0x19bdf0ca,
- 0xa02369b9, 0x655abb50, 0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
- 0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8, 0xf837889a, 0x97e32d77,
- 0x11ed935f, 0x16681281, 0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
- 0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696, 0xcdb30aeb, 0x532e3054,
- 0x8fd948e4, 0x6dbc3128, 0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
- 0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0, 0x45eee2b6, 0xa3aaabea,
- 0xdb6c4f15, 0xfacb4fd0, 0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
- 0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250, 0xcf62a1f2, 0x5b8d2646,
- 0xfc8883a0, 0xc1c7b6a3, 0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
- 0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00, 0x58428d2a, 0x0c55f5ea,
- 0x1dadf43e, 0x233f7061, 0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
- 0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e, 0xa6078084, 0x19f8509e,
- 0xe8efd855, 0x61d99735, 0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
- 0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9, 0xdb73dbd3, 0x105588cd,
- 0x675fda79, 0xe3674340, 0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
- 0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7,
-}
-
-var s2 = [256]uint32{
- 0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934, 0x411520f7, 0x7602d4f7,
- 0xbcf46b2e, 0xd4a20068, 0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
- 0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840, 0x4d95fc1d, 0x96b591af,
- 0x70f4ddd3, 0x66a02f45, 0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
- 0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a, 0x28507825, 0x530429f4,
- 0x0a2c86da, 0xe9b66dfb, 0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
- 0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6, 0xaace1e7c, 0xd3375fec,
- 0xce78a399, 0x406b2a42, 0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
- 0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2, 0x3a6efa74, 0xdd5b4332,
- 0x6841e7f7, 0xca7820fb, 0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
- 0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b, 0x55a867bc, 0xa1159a58,
- 0xcca92963, 0x99e1db33, 0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
- 0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3, 0x95c11548, 0xe4c66d22,
- 0x48c1133f, 0xc70f86dc, 0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
- 0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564, 0x257b7834, 0x602a9c60,
- 0xdff8e8a3, 0x1f636c1b, 0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
- 0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922, 0x85b2a20e, 0xe6ba0d99,
- 0xde720c8c, 0x2da2f728, 0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
- 0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e, 0x0a476341, 0x992eff74,
- 0x3a6f6eab, 0xf4f8fd37, 0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
- 0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804, 0xf1290dc7, 0xcc00ffa3,
- 0xb5390f92, 0x690fed0b, 0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
- 0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb, 0x37392eb3, 0xcc115979,
- 0x8026e297, 0xf42e312d, 0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
- 0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350, 0x1a6b1018, 0x11caedfa,
- 0x3d25bdd8, 0xe2e1c3c9, 0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
- 0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe, 0x9dbc8057, 0xf0f7c086,
- 0x60787bf8, 0x6003604d, 0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
- 0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f, 0x77a057be, 0xbde8ae24,
- 0x55464299, 0xbf582e61, 0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
- 0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9, 0x7aeb2661, 0x8b1ddf84,
- 0x846a0e79, 0x915f95e2, 0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
- 0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e, 0xb77f19b6, 0xe0a9dc09,
- 0x662d09a1, 0xc4324633, 0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
- 0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169, 0xdcb7da83, 0x573906fe,
- 0xa1e2ce9b, 0x4fcd7f52, 0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
- 0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5, 0xf0177a28, 0xc0f586e0,
- 0x006058aa, 0x30dc7d62, 0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
- 0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76, 0x6f05e409, 0x4b7c0188,
- 0x39720a3d, 0x7c927c24, 0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
- 0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4, 0x1e50ef5e, 0xb161e6f8,
- 0xa28514d9, 0x6c51133c, 0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
- 0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0,
-}
-
-var s3 = [256]uint32{
- 0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b, 0x5cb0679e, 0x4fa33742,
- 0xd3822740, 0x99bc9bbe, 0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
- 0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4, 0x5748ab2f, 0xbc946e79,
- 0xc6a376d2, 0x6549c2c8, 0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
- 0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304, 0xa1fad5f0, 0x6a2d519a,
- 0x63ef8ce2, 0x9a86ee22, 0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
- 0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6, 0x2826a2f9, 0xa73a3ae1,
- 0x4ba99586, 0xef5562e9, 0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
- 0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593, 0xe990fd5a, 0x9e34d797,
- 0x2cf0b7d9, 0x022b8b51, 0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
- 0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c, 0xe029ac71, 0xe019a5e6,
- 0x47b0acfd, 0xed93fa9b, 0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
- 0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c, 0x15056dd4, 0x88f46dba,
- 0x03a16125, 0x0564f0bd, 0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
- 0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319, 0x7533d928, 0xb155fdf5,
- 0x03563482, 0x8aba3cbb, 0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
- 0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991, 0xea7a90c2, 0xfb3e7bce,
- 0x5121ce64, 0x774fbe32, 0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
- 0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166, 0xb39a460a, 0x6445c0dd,
- 0x586cdecf, 0x1c20c8ae, 0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
- 0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5, 0x72eacea8, 0xfa6484bb,
- 0x8d6612ae, 0xbf3c6f47, 0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
- 0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d, 0x4040cb08, 0x4eb4e2cc,
- 0x34d2466a, 0x0115af84, 0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
- 0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8, 0x611560b1, 0xe7933fdc,
- 0xbb3a792b, 0x344525bd, 0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
- 0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7, 0x1a908749, 0xd44fbd9a,
- 0xd0dadecb, 0xd50ada38, 0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
- 0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c, 0xbf97222c, 0x15e6fc2a,
- 0x0f91fc71, 0x9b941525, 0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
- 0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442, 0xe0ec6e0e, 0x1698db3b,
- 0x4c98a0be, 0x3278e964, 0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
- 0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8, 0xdf359f8d, 0x9b992f2e,
- 0xe60b6f47, 0x0fe3f11d, 0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
- 0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299, 0xf523f357, 0xa6327623,
- 0x93a83531, 0x56cccd02, 0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
- 0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614, 0xe6c6c7bd, 0x327a140a,
- 0x45e1d006, 0xc3f27b9a, 0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
- 0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b, 0x53113ec0, 0x1640e3d3,
- 0x38abbd60, 0x2547adf0, 0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
- 0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e, 0x1948c25c, 0x02fb8a8c,
- 0x01c36ae4, 0xd6ebe1f9, 0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
- 0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6,
-}
-
-var p = [18]uint32{
- 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0xa4093822, 0x299f31d0,
- 0x082efa98, 0xec4e6c89, 0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
- 0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917, 0x9216d5d9, 0x8979fb1b,
-}
diff --git a/vendor/github.com/mattermost/platform/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/github.com/mattermost/platform/vendor/gopkg.in/yaml.v2/scannerc.go
index 2c9d5111..07448445 100644
--- a/vendor/github.com/mattermost/platform/vendor/gopkg.in/yaml.v2/scannerc.go
+++ b/vendor/github.com/mattermost/platform/vendor/gopkg.in/yaml.v2/scannerc.go
@@ -611,7 +611,7 @@ func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, co
if directive {
context = "while parsing a %TAG directive"
}
- return yaml_parser_set_scanner_error(parser, context, context_mark, "did not find URI escaped octet")
+ return yaml_parser_set_scanner_error(parser, context, context_mark, problem)
}
func trace(args ...interface{}) func() {
@@ -1944,7 +1944,7 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
} else {
// It's either the '!' tag or not really a tag handle. If it's a %TAG
// directive, it's an error. If it's a tag token, it must be a part of URI.
- if directive && !(s[0] == '!' && s[1] == 0) {
+ if directive && string(s) != "!" {
yaml_parser_set_scanner_tag_error(parser, directive,
start_mark, "did not find expected '!'")
return false
@@ -1959,6 +1959,7 @@ func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_ma
func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool {
//size_t length = head ? strlen((char *)head) : 0
var s []byte
+ hasTag := len(head) > 0
// Copy the head if needed.
//
@@ -2000,10 +2001,10 @@ func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte
if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
return false
}
+ hasTag = true
}
- // Check if the tag is non-empty.
- if len(s) == 0 {
+ if !hasTag {
yaml_parser_set_scanner_tag_error(parser, directive,
start_mark, "did not find expected tag URI")
return false