4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-03 04:57:44 +00:00

Update vendor for next release (#1343)

This commit is contained in:
Wim
2020-12-31 14:48:12 +01:00
committed by GitHub
parent a9f89dbc64
commit 4f20ebead3
220 changed files with 11469 additions and 2195 deletions

View File

@ -864,7 +864,7 @@ Mozilla Public License Version 2.0
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
@ -1387,7 +1387,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This product contains 'durafmt' by Wesley Hill.
:clock8: Better time duration formatting in Go!
:clock8: Better time duration formatting in Go!
* HOMEPAGE:
* https://github.com/hako/durafmt
@ -3657,7 +3657,7 @@ lumberjack is a log rolling package for Go
The MIT License (MIT)
Copyright (c) 2014 Nate Finch
Copyright (c) 2014 Nate Finch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -4206,6 +4206,220 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## AWS SDK for Go
This product contains 'aws-sdk' by Amazon.
AWS-SDK support for the Go language.
* HOMEPAGE:
* https://github.com/aws/aws-sdk-go
* LICENSE:
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.
---
## semver
@ -4274,3 +4488,328 @@ 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.
---
## Archiver
This product contains 'archiver' by Matthew Holt
A library to handle direferen archive files (zip, rar, tar.gz...)
* HOMEPAGE:
* https://github.com/mholt/archiver
* LICENSE:
MIT License
Copyright (c) 2016 Matthew Holt
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.
---
## PDF Reader library
This product contains 'pdf' by the Go team and modified by Thuc Le
A library to provide pdf reading support
* HOMEPAGE:
* https://github.com/ledongthuc/pdf
* LICENSE:
Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---
## GoOse
This product contains 'GoOse' by Antonio Linari
A library to provide html text extraction support
* HOMEPAGE:
* https://github.com/advancedlogic/GoOse
* LICENSE:
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.
---
## Docconv
This product contains 'docconv' by Sajari Pty Ltd
A library to provide text extraction support for different documents
* HOMEPAGE:
* https://github.com/sajari/docconv
* LICENSE:
The MIT License (MIT)
Copyright (c) 2014 Sajari Pty Ltd
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.

View File

@ -164,6 +164,18 @@ func (o *ChannelMember) GetRoles() []string {
return strings.Fields(o.Roles)
}
func (o *ChannelMember) SetChannelMuted(muted bool) {
if o.IsChannelMuted() {
o.NotifyProps[MARK_UNREAD_NOTIFY_PROP] = CHANNEL_MARK_UNREAD_ALL
} else {
o.NotifyProps[MARK_UNREAD_NOTIFY_PROP] = CHANNEL_MARK_UNREAD_MENTION
}
}
func (o *ChannelMember) IsChannelMuted() bool {
return o.NotifyProps[MARK_UNREAD_NOTIFY_PROP] == CHANNEL_MARK_UNREAD_MENTION
}
func IsChannelNotifyLevelValid(notifyLevel string) bool {
return notifyLevel == CHANNEL_NOTIFY_DEFAULT ||
notifyLevel == CHANNEL_NOTIFY_ALL ||

View File

@ -46,6 +46,7 @@ type SidebarCategory struct {
Sorting SidebarCategorySorting `json:"sorting"`
Type SidebarCategoryType `json:"type"`
DisplayName string `json:"display_name"`
Muted bool `json:"muted"`
}
// SidebarCategoryWithChannels combines data from SidebarCategory table with the Channel IDs that belong to that category

View File

@ -189,6 +189,14 @@ func (c *Client4) GetUserRoute(userId string) string {
return fmt.Sprintf(c.GetUsersRoute()+"/%v", userId)
}
func (c *Client4) GetUserThreadsRoute(userId string) string {
return fmt.Sprintf(c.GetUsersRoute()+"/%v/threads", userId)
}
func (c *Client4) GetUserThreadRoute(userId, threadId string) string {
return fmt.Sprintf(c.GetUserThreadsRoute(userId)+"/%v", threadId)
}
func (c *Client4) GetUserCategoryRoute(userID, teamID string) string {
return c.GetUserRoute(userID) + c.GetTeamRoute(teamID) + "/channels/categories"
}
@ -334,6 +342,10 @@ func (c *Client4) GetSystemRoute() string {
return "/system"
}
func (c *Client4) GetCloudRoute() string {
return "/cloud"
}
func (c *Client4) GetTestEmailRoute() string {
return "/email/test"
}
@ -3268,6 +3280,21 @@ func (c *Client4) GetPingWithServerStatus() (string, *Response) {
return MapFromJson(r.Body)["status"], BuildResponse(r)
}
// GetPingWithFullServerStatus will return the full status if several basic server
// health checks all pass successfully.
func (c *Client4) GetPingWithFullServerStatus() (map[string]string, *Response) {
r, err := c.DoApiGet(c.GetSystemRoute()+"/ping?get_server_status="+c.boolString(true), "")
if r != nil && r.StatusCode == 500 {
defer r.Body.Close()
return map[string]string{"status": STATUS_UNHEALTHY}, BuildErrorResponse(r, err)
}
if err != nil {
return nil, BuildErrorResponse(r, err)
}
defer closeBody(r)
return MapFromJson(r.Body), BuildResponse(r)
}
// TestEmail will attempt to connect to the configured SMTP server.
func (c *Client4) TestEmail(config *Config) (bool, *Response) {
r, err := c.DoApiPost(c.GetTestEmailRoute(), config.ToJson())
@ -4090,7 +4117,7 @@ func (c *Client4) MigrateAuthToSaml(fromAuthService string, usersMap map[string]
// UploadLdapPublicCertificate will upload a public certificate for LDAP and set the config to use it.
func (c *Client4) UploadLdapPublicCertificate(data []byte) (bool, *Response) {
body, writer, err := fileToMultipart(data, LDAP_PUBIC_CERTIFICATE_NAME)
body, writer, err := fileToMultipart(data, LDAP_PUBLIC_CERTIFICATE_NAME)
if err != nil {
return false, &Response{Error: NewAppError("UploadLdapPublicCertificate", "model.client.upload_ldap_cert.app_error", nil, err.Error(), http.StatusBadRequest)}
}
@ -5616,3 +5643,183 @@ func (c *Client4) UpdatePassword(userId, currentPassword, newPassword string) *R
defer closeBody(r)
return BuildResponse(r)
}
// Cloud Section
func (c *Client4) GetCloudProducts() ([]*Product, *Response) {
r, appErr := c.DoApiGet(c.GetCloudRoute()+"/products", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var cloudProducts []*Product
json.NewDecoder(r.Body).Decode(&cloudProducts)
return cloudProducts, BuildResponse(r)
}
func (c *Client4) CreateCustomerPayment() (*StripeSetupIntent, *Response) {
r, appErr := c.DoApiPost(c.GetCloudRoute()+"/payment", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var setupIntent *StripeSetupIntent
json.NewDecoder(r.Body).Decode(&setupIntent)
return setupIntent, BuildResponse(r)
}
func (c *Client4) ConfirmCustomerPayment(confirmRequest *ConfirmPaymentMethodRequest) *Response {
json, _ := json.Marshal(confirmRequest)
r, appErr := c.doApiPostBytes(c.GetCloudRoute()+"/payment/confirm", json)
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return BuildResponse(r)
}
func (c *Client4) GetCloudCustomer() (*CloudCustomer, *Response) {
r, appErr := c.DoApiGet(c.GetCloudRoute()+"/customer", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var cloudCustomer *CloudCustomer
json.NewDecoder(r.Body).Decode(&cloudCustomer)
return cloudCustomer, BuildResponse(r)
}
func (c *Client4) GetSubscription() (*Subscription, *Response) {
r, appErr := c.DoApiGet(c.GetCloudRoute()+"/subscription", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var subscription *Subscription
json.NewDecoder(r.Body).Decode(&subscription)
return subscription, BuildResponse(r)
}
func (c *Client4) GetInvoicesForSubscription() ([]*Invoice, *Response) {
r, appErr := c.DoApiGet(c.GetCloudRoute()+"/subscription/invoices", "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var invoices []*Invoice
json.NewDecoder(r.Body).Decode(&invoices)
return invoices, BuildResponse(r)
}
func (c *Client4) UpdateCloudCustomer(customerInfo *CloudCustomerInfo) (*CloudCustomer, *Response) {
customerBytes, _ := json.Marshal(customerInfo)
r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer", customerBytes)
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var customer *CloudCustomer
json.NewDecoder(r.Body).Decode(&customer)
return customer, BuildResponse(r)
}
func (c *Client4) UpdateCloudCustomerAddress(address *Address) (*CloudCustomer, *Response) {
addressBytes, _ := json.Marshal(address)
r, appErr := c.doApiPutBytes(c.GetCloudRoute()+"/customer/address", addressBytes)
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var customer *CloudCustomer
json.NewDecoder(r.Body).Decode(&customer)
return customer, BuildResponse(r)
}
func (c *Client4) GetUserThreads(userId string, options GetUserThreadsOpts) (*Threads, *Response) {
v := url.Values{}
if options.Since != 0 {
v.Set("since", fmt.Sprintf("%d", options.Since))
}
if options.Page != 0 {
v.Set("page", fmt.Sprintf("%d", options.Page))
}
if options.PageSize != 0 {
v.Set("pageSize", fmt.Sprintf("%d", options.PageSize))
}
if options.Extended {
v.Set("extended", "true")
}
if options.Deleted {
v.Set("deleted", "true")
}
url := c.GetUserThreadsRoute(userId)
if len(v) > 0 {
url += "?" + v.Encode()
}
r, appErr := c.DoApiGet(url, "")
if appErr != nil {
return nil, BuildErrorResponse(r, appErr)
}
defer closeBody(r)
var threads Threads
json.NewDecoder(r.Body).Decode(&threads)
return &threads, BuildResponse(r)
}
func (c *Client4) UpdateThreadsReadForUser(userId string, timestamp int64) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadsRoute(userId), timestamp), "")
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return BuildResponse(r)
}
func (c *Client4) UpdateThreadReadForUser(userId, threadId string, timestamp int64) *Response {
r, appErr := c.DoApiPut(fmt.Sprintf("%s/read/%d", c.GetUserThreadRoute(userId, threadId), timestamp), "")
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return BuildResponse(r)
}
func (c *Client4) UpdateThreadFollowForUser(userId, threadId string, state bool) *Response {
var appErr *AppError
var r *http.Response
if state {
r, appErr = c.DoApiPut(c.GetUserThreadRoute(userId, threadId)+"/following", "")
} else {
r, appErr = c.DoApiDelete(c.GetUserThreadRoute(userId, threadId) + "/following")
}
if appErr != nil {
return BuildErrorResponse(r, appErr)
}
defer closeBody(r)
return BuildResponse(r)
}

View File

@ -0,0 +1,114 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
// Product model represents a product on the cloud system.
type Product struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
PricePerSeat float64 `json:"price_per_seat"`
AddOns []*AddOn `json:"add_ons"`
}
// AddOn represents an addon to a product.
type AddOn struct {
ID string `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
PricePerSeat float64 `json:"price_per_seat"`
}
// StripeSetupIntent represents the SetupIntent model from Stripe for updating payment methods.
type StripeSetupIntent struct {
ID string `json:"id"`
ClientSecret string `json:"client_secret"`
}
// ConfirmPaymentMethodRequest contains the fields for the customer payment update API.
type ConfirmPaymentMethodRequest struct {
StripeSetupIntentID string `json:"stripe_setup_intent_id"`
}
// Customer model represents a customer on the system.
type CloudCustomer struct {
CloudCustomerInfo
ID string `json:"id"`
CreatorID string `json:"creator_id"`
CreateAt int64 `json:"create_at"`
BillingAddress *Address `json:"billing_address"`
CompanyAddress *Address `json:"company_address"`
PaymentMethod *PaymentMethod `json:"payment_method"`
}
// CloudCustomerInfo represents editable info of a customer.
type CloudCustomerInfo struct {
Name string `json:"name"`
Email string `json:"email,omitempty"`
ContactFirstName string `json:"contact_first_name,omitempty"`
ContactLastName string `json:"contact_last_name,omitempty"`
NumEmployees int `json:"num_employees"`
}
// Address model represents a customer's address.
type Address struct {
City string `json:"city"`
Country string `json:"country"`
Line1 string `json:"line1"`
Line2 string `json:"line2"`
PostalCode string `json:"postal_code"`
State string `json:"state"`
}
// PaymentMethod represents methods of payment for a customer.
type PaymentMethod struct {
Type string `json:"type"`
LastFour int `json:"last_four"`
ExpMonth int `json:"exp_month"`
ExpYear int `json:"exp_year"`
CardBrand string `json:"card_brand"`
Name string `json:"name"`
}
// Subscription model represents a subscription on the system.
type Subscription struct {
ID string `json:"id"`
CustomerID string `json:"customer_id"`
ProductID string `json:"product_id"`
AddOns []string `json:"add_ons"`
StartAt int64 `json:"start_at"`
EndAt int64 `json:"end_at"`
CreateAt int64 `json:"create_at"`
Seats int `json:"seats"`
Status string `json:"status"`
DNS string `json:"dns"`
IsPaidTier string `json:"is_paid_tier"`
LastInvoice *Invoice `json:"last_invoice"`
}
// Invoice model represents a cloud invoice
type Invoice struct {
ID string `json:"id"`
Number string `json:"number"`
CreateAt int64 `json:"create_at"`
Total int64 `json:"total"`
Tax int64 `json:"tax"`
Status string `json:"status"`
Description string `json:"description"`
PeriodStart int64 `json:"period_start"`
PeriodEnd int64 `json:"period_end"`
SubscriptionID string `json:"subscription_id"`
Items []*InvoiceLineItem `json:"line_items"`
}
// InvoiceLineItem model represents a cloud invoice lineitem tied to an invoice.
type InvoiceLineItem struct {
PriceID string `json:"price_id"`
Total int64 `json:"total"`
Quantity int64 `json:"quantity"`
PricePerUnit int64 `json:"price_per_unit"`
Description string `json:"description"`
Type string `json:"type"`
Metadata map[string]interface{} `json:"metadata"`
}

View File

@ -12,12 +12,14 @@ import (
"net/http"
"net/url"
"os"
"reflect"
"regexp"
"strconv"
"strings"
"time"
"github.com/mattermost/ldap"
"github.com/mattermost/mattermost-server/v5/mlog"
)
const (
@ -107,7 +109,7 @@ const (
TEAM_SETTINGS_DEFAULT_CUSTOM_DESCRIPTION_TEXT = ""
TEAM_SETTINGS_DEFAULT_USER_STATUS_AWAY_TIMEOUT = 300
SQL_SETTINGS_DEFAULT_DATA_SOURCE = "mmuser:mostest@tcp(localhost:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"
SQL_SETTINGS_DEFAULT_DATA_SOURCE = "postgres://mmuser:mostest@localhost/mattermost_test?sslmode=disable&connect_timeout=10"
FILE_SETTINGS_DEFAULT_DIRECTORY = "./data/"
@ -220,6 +222,8 @@ const (
OFFICE365_SETTINGS_DEFAULT_TOKEN_ENDPOINT = "https://login.microsoftonline.com/common/oauth2/v2.0/token"
OFFICE365_SETTINGS_DEFAULT_USER_API_ENDPOINT = "https://graph.microsoft.com/v1.0/me"
CLOUD_SETTINGS_DEFAULT_CWS_URL = "https://customers.mattermost.com"
LOCAL_MODE_SOCKET_PATH = "/var/tmp/mattermost_local.socket"
)
@ -250,26 +254,26 @@ var ServerTLSSupportedCiphers = map[string]uint16{
type ServiceSettings struct {
SiteURL *string `access:"environment,authentication,write_restrictable"`
WebsocketURL *string `access:"write_restrictable"`
LicenseFileLocation *string `access:"write_restrictable"`
ListenAddress *string `access:"environment,write_restrictable"`
ConnectionSecurity *string `access:"environment,write_restrictable"`
TLSCertFile *string `access:"environment,write_restrictable"`
TLSKeyFile *string `access:"environment,write_restrictable"`
TLSMinVer *string `access:"write_restrictable"`
TLSStrictTransport *bool `access:"write_restrictable"`
TLSStrictTransportMaxAge *int64 `access:"write_restrictable"`
TLSOverwriteCiphers []string `access:"write_restrictable"`
UseLetsEncrypt *bool `access:"environment,write_restrictable"`
LetsEncryptCertificateCacheFile *string `access:"environment,write_restrictable"`
Forward80To443 *bool `access:"environment,write_restrictable"`
TrustedProxyIPHeader []string `access:"write_restrictable"`
ReadTimeout *int `access:"environment,write_restrictable"`
WriteTimeout *int `access:"environment,write_restrictable"`
IdleTimeout *int `access:"write_restrictable"`
MaximumLoginAttempts *int `access:"authentication,write_restrictable"`
GoroutineHealthThreshold *int `access:"write_restrictable"`
GoogleDeveloperKey *string `access:"site,write_restrictable"`
WebsocketURL *string `access:"write_restrictable,cloud_restrictable"`
LicenseFileLocation *string `access:"write_restrictable,cloud_restrictable"`
ListenAddress *string `access:"environment,write_restrictable,cloud_restrictable"`
ConnectionSecurity *string `access:"environment,write_restrictable,cloud_restrictable"`
TLSCertFile *string `access:"environment,write_restrictable,cloud_restrictable"`
TLSKeyFile *string `access:"environment,write_restrictable,cloud_restrictable"`
TLSMinVer *string `access:"write_restrictable,cloud_restrictable"`
TLSStrictTransport *bool `access:"write_restrictable,cloud_restrictable"`
TLSStrictTransportMaxAge *int64 `access:"write_restrictable,cloud_restrictable"`
TLSOverwriteCiphers []string `access:"write_restrictable,cloud_restrictable"`
UseLetsEncrypt *bool `access:"environment,write_restrictable,cloud_restrictable"`
LetsEncryptCertificateCacheFile *string `access:"environment,write_restrictable,cloud_restrictable"`
Forward80To443 *bool `access:"environment,write_restrictable,cloud_restrictable"`
TrustedProxyIPHeader []string `access:"write_restrictable,cloud_restrictable"`
ReadTimeout *int `access:"environment,write_restrictable,cloud_restrictable"`
WriteTimeout *int `access:"environment,write_restrictable,cloud_restrictable"`
IdleTimeout *int `access:"write_restrictable,cloud_restrictable"`
MaximumLoginAttempts *int `access:"authentication,write_restrictable,cloud_restrictable"`
GoroutineHealthThreshold *int `access:"write_restrictable,cloud_restrictable"`
GoogleDeveloperKey *string `access:"site,write_restrictable,cloud_restrictable"`
EnableOAuthServiceProvider *bool `access:"integrations"`
EnableIncomingWebhooks *bool `access:"integrations"`
EnableOutgoingWebhooks *bool `access:"integrations"`
@ -278,29 +282,29 @@ type ServiceSettings struct {
EnablePostUsernameOverride *bool `access:"integrations"`
EnablePostIconOverride *bool `access:"integrations"`
EnableLinkPreviews *bool `access:"site"`
EnableTesting *bool `access:"environment,write_restrictable"`
EnableDeveloper *bool `access:"environment,write_restrictable"`
EnableOpenTracing *bool `access:"write_restrictable"`
EnableSecurityFixAlert *bool `access:"environment,write_restrictable"`
EnableInsecureOutgoingConnections *bool `access:"environment,write_restrictable"`
AllowedUntrustedInternalConnections *string `access:"environment,write_restrictable"`
EnableTesting *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableDeveloper *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableOpenTracing *bool `access:"write_restrictable,cloud_restrictable"`
EnableSecurityFixAlert *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableInsecureOutgoingConnections *bool `access:"environment,write_restrictable,cloud_restrictable"`
AllowedUntrustedInternalConnections *string `access:"environment,write_restrictable,cloud_restrictable"`
EnableMultifactorAuthentication *bool `access:"authentication"`
EnforceMultifactorAuthentication *bool `access:"authentication"`
EnableUserAccessTokens *bool `access:"integrations"`
AllowCorsFrom *string `access:"integrations,write_restrictable"`
CorsExposedHeaders *string `access:"integrations,write_restrictable"`
CorsAllowCredentials *bool `access:"integrations,write_restrictable"`
CorsDebug *bool `access:"integrations,write_restrictable"`
AllowCookiesForSubdomains *bool `access:"write_restrictable"`
ExtendSessionLengthWithActivity *bool `access:"environment,write_restrictable"`
SessionLengthWebInDays *int `access:"environment,write_restrictable"`
SessionLengthMobileInDays *int `access:"environment,write_restrictable"`
SessionLengthSSOInDays *int `access:"environment,write_restrictable"`
SessionCacheInMinutes *int `access:"environment,write_restrictable"`
SessionIdleTimeoutInMinutes *int `access:"environment,write_restrictable"`
WebsocketSecurePort *int `access:"write_restrictable"`
WebsocketPort *int `access:"write_restrictable"`
WebserverMode *string `access:"environment,write_restrictable"`
AllowCorsFrom *string `access:"integrations,write_restrictable,cloud_restrictable"`
CorsExposedHeaders *string `access:"integrations,write_restrictable,cloud_restrictable"`
CorsAllowCredentials *bool `access:"integrations,write_restrictable,cloud_restrictable"`
CorsDebug *bool `access:"integrations,write_restrictable,cloud_restrictable"`
AllowCookiesForSubdomains *bool `access:"write_restrictable,cloud_restrictable"`
ExtendSessionLengthWithActivity *bool `access:"environment,write_restrictable,cloud_restrictable"`
SessionLengthWebInDays *int `access:"environment,write_restrictable,cloud_restrictable"`
SessionLengthMobileInDays *int `access:"environment,write_restrictable,cloud_restrictable"`
SessionLengthSSOInDays *int `access:"environment,write_restrictable,cloud_restrictable"`
SessionCacheInMinutes *int `access:"environment,write_restrictable,cloud_restrictable"`
SessionIdleTimeoutInMinutes *int `access:"environment,write_restrictable,cloud_restrictable"`
WebsocketSecurePort *int `access:"write_restrictable,cloud_restrictable"`
WebsocketPort *int `access:"write_restrictable,cloud_restrictable"`
WebserverMode *string `access:"environment,write_restrictable,cloud_restrictable"`
EnableCustomEmoji *bool `access:"site"`
EnableEmojiPicker *bool `access:"site"`
EnableGifPicker *bool `access:"integrations"`
@ -310,14 +314,14 @@ type ServiceSettings struct {
DEPRECATED_DO_NOT_USE_RestrictPostDelete *string `json:"RestrictPostDelete" mapstructure:"RestrictPostDelete"` // This field is deprecated and must not be used.
DEPRECATED_DO_NOT_USE_AllowEditPost *string `json:"AllowEditPost" mapstructure:"AllowEditPost"` // This field is deprecated and must not be used.
PostEditTimeLimit *int `access:"user_management_permissions"`
TimeBetweenUserTypingUpdatesMilliseconds *int64 `access:"experimental,write_restrictable"`
EnablePostSearch *bool `access:"write_restrictable"`
MinimumHashtagLength *int `access:"environment,write_restrictable"`
EnableUserTypingMessages *bool `access:"experimental,write_restrictable"`
EnableChannelViewedMessages *bool `access:"experimental,write_restrictable"`
EnableUserStatuses *bool `access:"write_restrictable"`
ExperimentalEnableAuthenticationTransfer *bool `access:"experimental,write_restrictable"`
ClusterLogTimeoutMilliseconds *int `access:"write_restrictable"`
TimeBetweenUserTypingUpdatesMilliseconds *int64 `access:"experimental,write_restrictable,cloud_restrictable"`
EnablePostSearch *bool `access:"write_restrictable,cloud_restrictable"`
MinimumHashtagLength *int `access:"environment,write_restrictable,cloud_restrictable"`
EnableUserTypingMessages *bool `access:"experimental,write_restrictable,cloud_restrictable"`
EnableChannelViewedMessages *bool `access:"experimental,write_restrictable,cloud_restrictable"`
EnableUserStatuses *bool `access:"write_restrictable,cloud_restrictable"`
ExperimentalEnableAuthenticationTransfer *bool `access:"experimental,write_restrictable,cloud_restrictable"`
ClusterLogTimeoutMilliseconds *int `access:"write_restrictable,cloud_restrictable"`
CloseUnusedDirectMessages *bool `access:"experimental"`
EnablePreviewFeatures *bool `access:"experimental"`
EnableTutorial *bool `access:"experimental"`
@ -332,10 +336,10 @@ type ServiceSettings struct {
EnableAPITeamDeletion *bool
EnableAPIUserDeletion *bool
ExperimentalEnableHardenedMode *bool `access:"experimental"`
DisableLegacyMFA *bool `access:"write_restrictable"`
ExperimentalStrictCSRFEnforcement *bool `access:"experimental,write_restrictable"`
DisableLegacyMFA *bool `access:"write_restrictable,cloud_restrictable"`
ExperimentalStrictCSRFEnforcement *bool `access:"experimental,write_restrictable,cloud_restrictable"`
EnableEmailInvitations *bool `access:"authentication"`
DisableBotsWhenOwnerIsDeactivated *bool `access:"integrations,write_restrictable"`
DisableBotsWhenOwnerIsDeactivated *bool `access:"integrations,write_restrictable,cloud_restrictable"`
EnableBotAccountCreation *bool `access:"integrations"`
EnableSVGs *bool `access:"site"`
EnableLatex *bool `access:"site"`
@ -343,6 +347,9 @@ type ServiceSettings struct {
EnableLocalMode *bool
LocalModeSocketLocation *string
EnableAWSMetering *bool
SplitKey *string `access:"environment,write_restrictable"`
FeatureFlagSyncIntervalSeconds *int `access:"environment,write_restrictable"`
DebugSplit *bool `access:"environment,write_restrictable"`
ThreadAutoFollow *bool `access:"experimental"`
ManagedResourcePaths *string `access:"environment,write_restrictable,cloud_restrictable"`
}
@ -763,6 +770,18 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
s.EnableAWSMetering = NewBool(false)
}
if s.SplitKey == nil {
s.SplitKey = NewString("")
}
if s.FeatureFlagSyncIntervalSeconds == nil {
s.FeatureFlagSyncIntervalSeconds = NewInt(30)
}
if s.DebugSplit == nil {
s.DebugSplit = NewBool(false)
}
if s.ThreadAutoFollow == nil {
s.ThreadAutoFollow = NewBool(true)
}
@ -774,20 +793,20 @@ func (s *ServiceSettings) SetDefaults(isUpdate bool) {
type ClusterSettings struct {
Enable *bool `access:"environment,write_restrictable"`
ClusterName *string `access:"environment,write_restrictable"`
OverrideHostname *string `access:"environment,write_restrictable"`
NetworkInterface *string `access:"environment,write_restrictable"`
BindAddress *string `access:"environment,write_restrictable"`
AdvertiseAddress *string `access:"environment,write_restrictable"`
UseIpAddress *bool `access:"environment,write_restrictable"`
UseExperimentalGossip *bool `access:"environment,write_restrictable"`
EnableExperimentalGossipEncryption *bool `access:"environment,write_restrictable"`
ReadOnlyConfig *bool `access:"environment,write_restrictable"`
GossipPort *int `access:"environment,write_restrictable"`
StreamingPort *int `access:"environment,write_restrictable"`
MaxIdleConns *int `access:"environment,write_restrictable"`
MaxIdleConnsPerHost *int `access:"environment,write_restrictable"`
IdleConnTimeoutMilliseconds *int `access:"environment,write_restrictable"`
ClusterName *string `access:"environment,write_restrictable,cloud_restrictable"`
OverrideHostname *string `access:"environment,write_restrictable,cloud_restrictable"`
NetworkInterface *string `access:"environment,write_restrictable,cloud_restrictable"`
BindAddress *string `access:"environment,write_restrictable,cloud_restrictable"`
AdvertiseAddress *string `access:"environment,write_restrictable,cloud_restrictable"`
UseIpAddress *bool `access:"environment,write_restrictable,cloud_restrictable"`
UseExperimentalGossip *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableExperimentalGossipEncryption *bool `access:"environment,write_restrictable,cloud_restrictable"`
ReadOnlyConfig *bool `access:"environment,write_restrictable,cloud_restrictable"`
GossipPort *int `access:"environment,write_restrictable,cloud_restrictable"`
StreamingPort *int `access:"environment,write_restrictable,cloud_restrictable"`
MaxIdleConns *int `access:"environment,write_restrictable,cloud_restrictable"`
MaxIdleConnsPerHost *int `access:"environment,write_restrictable,cloud_restrictable"`
IdleConnTimeoutMilliseconds *int `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *ClusterSettings) SetDefaults() {
@ -853,9 +872,9 @@ func (s *ClusterSettings) SetDefaults() {
}
type MetricsSettings struct {
Enable *bool `access:"environment,write_restrictable"`
BlockProfileRate *int `access:"environment,write_restrictable"`
ListenAddress *string `access:"environment,write_restrictable"`
Enable *bool `access:"environment,write_restrictable,cloud_restrictable"`
BlockProfileRate *int `access:"environment,write_restrictable,cloud_restrictable"`
ListenAddress *string `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *MetricsSettings) SetDefaults() {
@ -873,14 +892,15 @@ func (s *MetricsSettings) SetDefaults() {
}
type ExperimentalSettings struct {
ClientSideCertEnable *bool `access:"experimental"`
ClientSideCertCheck *string `access:"experimental"`
EnableClickToReply *bool `access:"experimental,write_restrictable"`
LinkMetadataTimeoutMilliseconds *int64 `access:"experimental,write_restrictable"`
ClientSideCertEnable *bool `access:"experimental,cloud_restrictable"`
ClientSideCertCheck *string `access:"experimental,cloud_restrictable"`
EnableClickToReply *bool `access:"experimental,write_restrictable,cloud_restrictable"`
LinkMetadataTimeoutMilliseconds *int64 `access:"experimental,write_restrictable,cloud_restrictable"`
RestrictSystemAdmin *bool `access:"experimental,write_restrictable"`
UseNewSAMLLibrary *bool `access:"experimental"`
UseNewSAMLLibrary *bool `access:"experimental,cloud_restrictable"`
CloudUserLimit *int64 `access:"experimental,write_restrictable"`
CloudBilling *bool `access:"experimental,write_restrictable"`
EnableSharedChannels *bool `access:"experimental"`
}
func (s *ExperimentalSettings) SetDefaults() {
@ -916,10 +936,14 @@ func (s *ExperimentalSettings) SetDefaults() {
if s.UseNewSAMLLibrary == nil {
s.UseNewSAMLLibrary = NewBool(false)
}
if s.EnableSharedChannels == nil {
s.EnableSharedChannels = NewBool(false)
}
}
type AnalyticsSettings struct {
MaxUsersForStatistics *int `access:"write_restrictable"`
MaxUsersForStatistics *int `access:"write_restrictable,cloud_restrictable"`
}
func (s *AnalyticsSettings) SetDefaults() {
@ -1026,22 +1050,22 @@ func (s *Office365Settings) SSOSettings() *SSOSettings {
}
type SqlSettings struct {
DriverName *string `access:"environment,write_restrictable"`
DataSource *string `access:"environment,write_restrictable"`
DataSourceReplicas []string `access:"environment,write_restrictable"`
DataSourceSearchReplicas []string `access:"environment,write_restrictable"`
MaxIdleConns *int `access:"environment,write_restrictable"`
ConnMaxLifetimeMilliseconds *int `access:"environment,write_restrictable"`
MaxOpenConns *int `access:"environment,write_restrictable"`
Trace *bool `access:"environment,write_restrictable"`
AtRestEncryptKey *string `access:"environment,write_restrictable"`
QueryTimeout *int `access:"environment,write_restrictable"`
DisableDatabaseSearch *bool `access:"environment,write_restrictable"`
DriverName *string `access:"environment,write_restrictable,cloud_restrictable"`
DataSource *string `access:"environment,write_restrictable,cloud_restrictable"`
DataSourceReplicas []string `access:"environment,write_restrictable,cloud_restrictable"`
DataSourceSearchReplicas []string `access:"environment,write_restrictable,cloud_restrictable"`
MaxIdleConns *int `access:"environment,write_restrictable,cloud_restrictable"`
ConnMaxLifetimeMilliseconds *int `access:"environment,write_restrictable,cloud_restrictable"`
MaxOpenConns *int `access:"environment,write_restrictable,cloud_restrictable"`
Trace *bool `access:"environment,write_restrictable,cloud_restrictable"`
AtRestEncryptKey *string `access:"environment,write_restrictable,cloud_restrictable"`
QueryTimeout *int `access:"environment,write_restrictable,cloud_restrictable"`
DisableDatabaseSearch *bool `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *SqlSettings) SetDefaults(isUpdate bool) {
if s.DriverName == nil {
s.DriverName = NewString(DATABASE_DRIVER_MYSQL)
s.DriverName = NewString(DATABASE_DRIVER_POSTGRES)
}
if s.DataSource == nil {
@ -1092,17 +1116,17 @@ func (s *SqlSettings) SetDefaults(isUpdate bool) {
}
type LogSettings struct {
EnableConsole *bool `access:"environment,write_restrictable"`
ConsoleLevel *string `access:"environment,write_restrictable"`
ConsoleJson *bool `access:"environment,write_restrictable"`
EnableFile *bool `access:"environment,write_restrictable"`
FileLevel *string `access:"environment,write_restrictable"`
FileJson *bool `access:"environment,write_restrictable"`
FileLocation *string `access:"environment,write_restrictable"`
EnableWebhookDebugging *bool `access:"environment,write_restrictable"`
EnableDiagnostics *bool `access:"environment,write_restrictable"`
EnableSentry *bool `access:"environment,write_restrictable"`
AdvancedLoggingConfig *string `access:"environment,write_restrictable"`
EnableConsole *bool `access:"environment,write_restrictable,cloud_restrictable"`
ConsoleLevel *string `access:"environment,write_restrictable,cloud_restrictable"`
ConsoleJson *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableFile *bool `access:"environment,write_restrictable,cloud_restrictable"`
FileLevel *string `access:"environment,write_restrictable,cloud_restrictable"`
FileJson *bool `access:"environment,write_restrictable,cloud_restrictable"`
FileLocation *string `access:"environment,write_restrictable,cloud_restrictable"`
EnableWebhookDebugging *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableDiagnostics *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableSentry *bool `access:"environment,write_restrictable,cloud_restrictable"`
AdvancedLoggingConfig *string `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *LogSettings) SetDefaults() {
@ -1152,14 +1176,14 @@ func (s *LogSettings) SetDefaults() {
}
type ExperimentalAuditSettings struct {
FileEnabled *bool `access:"experimental,write_restrictable"`
FileName *string `access:"experimental,write_restrictable"`
FileMaxSizeMB *int `access:"experimental,write_restrictable"`
FileMaxAgeDays *int `access:"experimental,write_restrictable"`
FileMaxBackups *int `access:"experimental,write_restrictable"`
FileCompress *bool `access:"experimental,write_restrictable"`
FileMaxQueueSize *int `access:"experimental,write_restrictable"`
AdvancedLoggingConfig *string `access:"experimental,write_restrictable"`
FileEnabled *bool `access:"experimental,write_restrictable,cloud_restrictable"`
FileName *string `access:"experimental,write_restrictable,cloud_restrictable"`
FileMaxSizeMB *int `access:"experimental,write_restrictable,cloud_restrictable"`
FileMaxAgeDays *int `access:"experimental,write_restrictable,cloud_restrictable"`
FileMaxBackups *int `access:"experimental,write_restrictable,cloud_restrictable"`
FileCompress *bool `access:"experimental,write_restrictable,cloud_restrictable"`
FileMaxQueueSize *int `access:"experimental,write_restrictable,cloud_restrictable"`
AdvancedLoggingConfig *string `access:"experimental,write_restrictable,cloud_restrictable"`
}
func (s *ExperimentalAuditSettings) SetDefaults() {
@ -1197,14 +1221,14 @@ func (s *ExperimentalAuditSettings) SetDefaults() {
}
type NotificationLogSettings struct {
EnableConsole *bool `access:"write_restrictable"`
ConsoleLevel *string `access:"write_restrictable"`
ConsoleJson *bool `access:"write_restrictable"`
EnableFile *bool `access:"write_restrictable"`
FileLevel *string `access:"write_restrictable"`
FileJson *bool `access:"write_restrictable"`
FileLocation *string `access:"write_restrictable"`
AdvancedLoggingConfig *string `access:"write_restrictable"`
EnableConsole *bool `access:"write_restrictable,cloud_restrictable"`
ConsoleLevel *string `access:"write_restrictable,cloud_restrictable"`
ConsoleJson *bool `access:"write_restrictable,cloud_restrictable"`
EnableFile *bool `access:"write_restrictable,cloud_restrictable"`
FileLevel *string `access:"write_restrictable,cloud_restrictable"`
FileJson *bool `access:"write_restrictable,cloud_restrictable"`
FileLocation *string `access:"write_restrictable,cloud_restrictable"`
AdvancedLoggingConfig *string `access:"write_restrictable,cloud_restrictable"`
}
func (s *NotificationLogSettings) SetDefaults() {
@ -1272,25 +1296,25 @@ func (s *PasswordSettings) SetDefaults() {
}
type FileSettings struct {
EnableFileAttachments *bool `access:"site"`
EnableMobileUpload *bool `access:"site"`
EnableMobileDownload *bool `access:"site"`
MaxFileSize *int64 `access:"environment"`
DriverName *string `access:"environment,write_restrictable"`
Directory *string `access:"environment,write_restrictable"`
EnablePublicLink *bool `access:"site"`
PublicLinkSalt *string `access:"site"`
InitialFont *string `access:"environment"`
AmazonS3AccessKeyId *string `access:"environment,write_restrictable"`
AmazonS3SecretAccessKey *string `access:"environment,write_restrictable"`
AmazonS3Bucket *string `access:"environment,write_restrictable"`
AmazonS3PathPrefix *string `access:"environment,write_restrictable"`
AmazonS3Region *string `access:"environment,write_restrictable"`
AmazonS3Endpoint *string `access:"environment,write_restrictable"`
AmazonS3SSL *bool `access:"environment,write_restrictable"`
AmazonS3SignV2 *bool `access:"environment,write_restrictable"`
AmazonS3SSE *bool `access:"environment,write_restrictable"`
AmazonS3Trace *bool `access:"environment,write_restrictable"`
EnableFileAttachments *bool `access:"site,cloud_restrictable"`
EnableMobileUpload *bool `access:"site,cloud_restrictable"`
EnableMobileDownload *bool `access:"site,cloud_restrictable"`
MaxFileSize *int64 `access:"environment,cloud_restrictable"`
DriverName *string `access:"environment,write_restrictable,cloud_restrictable"`
Directory *string `access:"environment,write_restrictable,cloud_restrictable"`
EnablePublicLink *bool `access:"site,cloud_restrictable"`
PublicLinkSalt *string `access:"site,cloud_restrictable"`
InitialFont *string `access:"environment,cloud_restrictable"`
AmazonS3AccessKeyId *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3SecretAccessKey *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3Bucket *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3PathPrefix *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3Region *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3Endpoint *string `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3SSL *bool `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3SignV2 *bool `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3SSE *bool `access:"environment,write_restrictable,cloud_restrictable"`
AmazonS3Trace *bool `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *FileSettings) SetDefaults(isUpdate bool) {
@ -1388,16 +1412,16 @@ type EmailSettings struct {
UseChannelInEmailNotifications *bool `access:"experimental"`
RequireEmailVerification *bool `access:"authentication"`
FeedbackName *string `access:"site"`
FeedbackEmail *string `access:"site"`
ReplyToAddress *string `access:"site"`
FeedbackEmail *string `access:"site,cloud_restrictable"`
ReplyToAddress *string `access:"site,cloud_restrictable"`
FeedbackOrganization *string `access:"site"`
EnableSMTPAuth *bool `access:"environment,write_restrictable"`
SMTPUsername *string `access:"environment,write_restrictable"`
SMTPPassword *string `access:"environment,write_restrictable"`
SMTPServer *string `access:"environment,write_restrictable"`
SMTPPort *string `access:"environment,write_restrictable"`
SMTPServerTimeout *int
ConnectionSecurity *string `access:"environment,write_restrictable"`
EnableSMTPAuth *bool `access:"environment,write_restrictable,cloud_restrictable"`
SMTPUsername *string `access:"environment,write_restrictable,cloud_restrictable"`
SMTPPassword *string `access:"environment,write_restrictable,cloud_restrictable"`
SMTPServer *string `access:"environment,write_restrictable,cloud_restrictable"`
SMTPPort *string `access:"environment,write_restrictable,cloud_restrictable"`
SMTPServerTimeout *int `access:"cloud_restrictable"`
ConnectionSecurity *string `access:"environment,write_restrictable,cloud_restrictable"`
SendPushNotifications *bool `access:"environment"`
PushNotificationServer *string `access:"environment"`
PushNotificationContents *string `access:"site"`
@ -1406,7 +1430,7 @@ type EmailSettings struct {
EmailBatchingBufferSize *int `access:"experimental"`
EmailBatchingInterval *int `access:"experimental"`
EnablePreviewModeBanner *bool `access:"site"`
SkipServerCertificateVerification *bool `access:"environment,write_restrictable"`
SkipServerCertificateVerification *bool `access:"environment,write_restrictable,cloud_restrictable"`
EmailNotificationContentsType *string `access:"site"`
LoginButtonColor *string `access:"experimental"`
LoginButtonBorderColor *string `access:"experimental"`
@ -1556,13 +1580,13 @@ func (s *EmailSettings) SetDefaults(isUpdate bool) {
}
type RateLimitSettings struct {
Enable *bool `access:"environment,write_restrictable"`
PerSec *int `access:"environment,write_restrictable"`
MaxBurst *int `access:"environment,write_restrictable"`
MemoryStoreSize *int `access:"environment,write_restrictable"`
VaryByRemoteAddr *bool `access:"environment,write_restrictable"`
VaryByUser *bool `access:"environment,write_restrictable"`
VaryByHeader string `access:"environment,write_restrictable"`
Enable *bool `access:"environment,write_restrictable,cloud_restrictable"`
PerSec *int `access:"environment,write_restrictable,cloud_restrictable"`
MaxBurst *int `access:"environment,write_restrictable,cloud_restrictable"`
MemoryStoreSize *int `access:"environment,write_restrictable,cloud_restrictable"`
VaryByRemoteAddr *bool `access:"environment,write_restrictable,cloud_restrictable"`
VaryByUser *bool `access:"environment,write_restrictable,cloud_restrictable"`
VaryByHeader string `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *RateLimitSettings) SetDefaults() {
@ -1607,11 +1631,11 @@ func (s *PrivacySettings) setDefaults() {
}
type SupportSettings struct {
TermsOfServiceLink *string `access:"site,write_restrictable"`
PrivacyPolicyLink *string `access:"site,write_restrictable"`
AboutLink *string `access:"site,write_restrictable"`
HelpLink *string `access:"site,write_restrictable"`
ReportAProblemLink *string `access:"site,write_restrictable"`
TermsOfServiceLink *string `access:"site,write_restrictable,cloud_restrictable"`
PrivacyPolicyLink *string `access:"site,write_restrictable,cloud_restrictable"`
AboutLink *string `access:"site,write_restrictable,cloud_restrictable"`
HelpLink *string `access:"site,write_restrictable,cloud_restrictable"`
ReportAProblemLink *string `access:"site,write_restrictable,cloud_restrictable"`
SupportEmail *string `access:"site"`
CustomTermsOfServiceEnabled *bool `access:"compliance"`
CustomTermsOfServiceReAcceptancePeriod *int `access:"compliance"`
@ -1938,12 +1962,12 @@ func (s *TeamSettings) SetDefaults() {
}
type ClientRequirements struct {
AndroidLatestVersion string `access:"write_restrictable"`
AndroidMinVersion string `access:"write_restrictable"`
DesktopLatestVersion string `access:"write_restrictable"`
DesktopMinVersion string `access:"write_restrictable"`
IosLatestVersion string `access:"write_restrictable"`
IosMinVersion string `access:"write_restrictable"`
AndroidLatestVersion string `access:"write_restrictable,cloud_restrictable"`
AndroidMinVersion string `access:"write_restrictable,cloud_restrictable"`
DesktopLatestVersion string `access:"write_restrictable,cloud_restrictable"`
DesktopMinVersion string `access:"write_restrictable,cloud_restrictable"`
IosLatestVersion string `access:"write_restrictable,cloud_restrictable"`
IosMinVersion string `access:"write_restrictable,cloud_restrictable"`
}
type LdapSettings struct {
@ -2189,6 +2213,7 @@ type SamlSettings struct {
Enable *bool `access:"authentication"`
EnableSyncWithLdap *bool `access:"authentication"`
EnableSyncWithLdapIncludeAuth *bool `access:"authentication"`
IgnoreGuestsLdapSync *bool `access:"authentication"`
Verify *bool `access:"authentication"`
Encrypt *bool `access:"authentication"`
@ -2243,6 +2268,10 @@ func (s *SamlSettings) SetDefaults() {
s.EnableSyncWithLdapIncludeAuth = NewBool(false)
}
if s.IgnoreGuestsLdapSync == nil {
s.IgnoreGuestsLdapSync = NewBool(false)
}
if s.EnableAdminAttribute == nil {
s.EnableAdminAttribute = NewBool(false)
}
@ -2367,9 +2396,9 @@ func (s *SamlSettings) SetDefaults() {
}
type NativeAppSettings struct {
AppDownloadLink *string `access:"site,write_restrictable"`
AndroidAppDownloadLink *string `access:"site,write_restrictable"`
IosAppDownloadLink *string `access:"site,write_restrictable"`
AppDownloadLink *string `access:"site,write_restrictable,cloud_restrictable"`
AndroidAppDownloadLink *string `access:"site,write_restrictable,cloud_restrictable"`
IosAppDownloadLink *string `access:"site,write_restrictable,cloud_restrictable"`
}
func (s *NativeAppSettings) SetDefaults() {
@ -2387,27 +2416,27 @@ func (s *NativeAppSettings) SetDefaults() {
}
type ElasticsearchSettings struct {
ConnectionUrl *string `access:"environment,write_restrictable"`
Username *string `access:"environment,write_restrictable"`
Password *string `access:"environment,write_restrictable"`
EnableIndexing *bool `access:"environment,write_restrictable"`
EnableSearching *bool `access:"environment,write_restrictable"`
EnableAutocomplete *bool `access:"environment,write_restrictable"`
Sniff *bool `access:"environment,write_restrictable"`
PostIndexReplicas *int `access:"environment,write_restrictable"`
PostIndexShards *int `access:"environment,write_restrictable"`
ChannelIndexReplicas *int `access:"environment,write_restrictable"`
ChannelIndexShards *int `access:"environment,write_restrictable"`
UserIndexReplicas *int `access:"environment,write_restrictable"`
UserIndexShards *int `access:"environment,write_restrictable"`
AggregatePostsAfterDays *int `access:"environment,write_restrictable"`
PostsAggregatorJobStartTime *string `access:"environment,write_restrictable"`
IndexPrefix *string `access:"environment,write_restrictable"`
LiveIndexingBatchSize *int `access:"environment,write_restrictable"`
BulkIndexingTimeWindowSeconds *int `access:"environment,write_restrictable"`
RequestTimeoutSeconds *int `access:"environment,write_restrictable"`
SkipTLSVerification *bool `access:"environment,write_restrictable"`
Trace *string `access:"environment,write_restrictable"`
ConnectionUrl *string `access:"environment,write_restrictable,cloud_restrictable"`
Username *string `access:"environment,write_restrictable,cloud_restrictable"`
Password *string `access:"environment,write_restrictable,cloud_restrictable"`
EnableIndexing *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableSearching *bool `access:"environment,write_restrictable,cloud_restrictable"`
EnableAutocomplete *bool `access:"environment,write_restrictable,cloud_restrictable"`
Sniff *bool `access:"environment,write_restrictable,cloud_restrictable"`
PostIndexReplicas *int `access:"environment,write_restrictable,cloud_restrictable"`
PostIndexShards *int `access:"environment,write_restrictable,cloud_restrictable"`
ChannelIndexReplicas *int `access:"environment,write_restrictable,cloud_restrictable"`
ChannelIndexShards *int `access:"environment,write_restrictable,cloud_restrictable"`
UserIndexReplicas *int `access:"environment,write_restrictable,cloud_restrictable"`
UserIndexShards *int `access:"environment,write_restrictable,cloud_restrictable"`
AggregatePostsAfterDays *int `access:"environment,write_restrictable,cloud_restrictable"`
PostsAggregatorJobStartTime *string `access:"environment,write_restrictable,cloud_restrictable"`
IndexPrefix *string `access:"environment,write_restrictable,cloud_restrictable"`
LiveIndexingBatchSize *int `access:"environment,write_restrictable,cloud_restrictable"`
BulkIndexingTimeWindowSeconds *int `access:"environment,write_restrictable,cloud_restrictable"`
RequestTimeoutSeconds *int `access:"environment,write_restrictable,cloud_restrictable"`
SkipTLSVerification *bool `access:"environment,write_restrictable,cloud_restrictable"`
Trace *string `access:"environment,write_restrictable,cloud_restrictable"`
}
func (s *ElasticsearchSettings) SetDefaults() {
@ -2557,8 +2586,8 @@ func (s *DataRetentionSettings) SetDefaults() {
}
type JobSettings struct {
RunJobs *bool `access:"write_restrictable"`
RunScheduler *bool `access:"write_restrictable"`
RunJobs *bool `access:"write_restrictable,cloud_restrictable"`
RunScheduler *bool `access:"write_restrictable,cloud_restrictable"`
}
func (s *JobSettings) SetDefaults() {
@ -2571,25 +2600,35 @@ func (s *JobSettings) SetDefaults() {
}
}
type CloudSettings struct {
CWSUrl *string `access:"environment,write_restrictable"`
}
func (s *CloudSettings) SetDefaults() {
if s.CWSUrl == nil {
s.CWSUrl = NewString(CLOUD_SETTINGS_DEFAULT_CWS_URL)
}
}
type PluginState struct {
Enable bool
}
type PluginSettings struct {
Enable *bool `access:"plugins"`
EnableUploads *bool `access:"plugins,write_restrictable"`
AllowInsecureDownloadUrl *bool `access:"plugins,write_restrictable"`
EnableHealthCheck *bool `access:"plugins,write_restrictable"`
Directory *string `access:"plugins,write_restrictable"`
ClientDirectory *string `access:"plugins,write_restrictable"`
Enable *bool `access:"plugins,write_restrictable"`
EnableUploads *bool `access:"plugins,write_restrictable,cloud_restrictable"`
AllowInsecureDownloadUrl *bool `access:"plugins,write_restrictable,cloud_restrictable"`
EnableHealthCheck *bool `access:"plugins,write_restrictable,cloud_restrictable"`
Directory *string `access:"plugins,write_restrictable,cloud_restrictable"`
ClientDirectory *string `access:"plugins,write_restrictable,cloud_restrictable"`
Plugins map[string]map[string]interface{} `access:"plugins"`
PluginStates map[string]*PluginState `access:"plugins"`
EnableMarketplace *bool `access:"plugins"`
EnableRemoteMarketplace *bool `access:"plugins"`
AutomaticPrepackagedPlugins *bool `access:"plugins"`
RequirePluginSignature *bool `access:"plugins"`
MarketplaceUrl *string `access:"plugins"`
SignaturePublicKeyFiles []string `access:"plugins"`
EnableMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
EnableRemoteMarketplace *bool `access:"plugins,write_restrictable,cloud_restrictable"`
AutomaticPrepackagedPlugins *bool `access:"plugins,write_restrictable,cloud_restrictable"`
RequirePluginSignature *bool `access:"plugins,write_restrictable,cloud_restrictable"`
MarketplaceUrl *string `access:"plugins,write_restrictable,cloud_restrictable"`
SignaturePublicKeyFiles []string `access:"plugins,write_restrictable,cloud_restrictable"`
}
func (s *PluginSettings) SetDefaults(ls LogSettings) {
@ -2630,6 +2669,16 @@ func (s *PluginSettings) SetDefaults(ls LogSettings) {
s.PluginStates["com.mattermost.nps"] = &PluginState{Enable: ls.EnableDiagnostics == nil || *ls.EnableDiagnostics}
}
if s.PluginStates["com.mattermost.plugin-incident-management"] == nil && BuildEnterpriseReady == "true" {
// Enable the incident management plugin by default
s.PluginStates["com.mattermost.plugin-incident-management"] = &PluginState{Enable: true}
}
if s.PluginStates["com.mattermost.plugin-channel-export"] == nil && BuildEnterpriseReady == "true" {
// Enable the channel export plugin by default
s.PluginStates["com.mattermost.plugin-channel-export"] = &PluginState{Enable: true}
}
if s.EnableMarketplace == nil {
s.EnableMarketplace = NewBool(PLUGIN_SETTINGS_DEFAULT_ENABLE_MARKETPLACE)
}
@ -2808,7 +2857,9 @@ func (s *ImageProxySettings) SetDefaults(ss ServiceSettings) {
type ConfigFunc func() *Config
const ConfigAccessTagType = "access"
const ConfigAccessTagWriteRestrictable = "write_restrictable"
const ConfigAccessTagCloudRestrictable = "cloud_restrictable"
// Config fields support the 'access' tag with the following values corresponding to the suffix of the associated
// PERMISSION_SYSCONSOLE_*_* permission Id: 'about', 'reporting', 'user_management_users',
@ -2822,6 +2873,9 @@ const ConfigAccessTagWriteRestrictable = "write_restrictable"
//
// PERMISSION_MANAGE_SYSTEM always grants read access.
//
// Config values with the access tag 'cloud_restrictable' mean that are marked to be filtered when it's used in a cloud licensed
// environment with ExperimentalSettings.RestrictedSystemAdmin set to true.
//
// Example:
// type HairSettings struct {
// // Colour is writeable with either PERMISSION_SYSCONSOLE_WRITE_REPORTING or PERMISSION_SYSCONSOLE_WRITE_USER_MANAGEMENT_GROUPS.
@ -2874,6 +2928,8 @@ type Config struct {
DisplaySettings DisplaySettings
GuestAccountsSettings GuestAccountsSettings
ImageProxySettings ImageProxySettings
CloudSettings CloudSettings
FeatureFlags *FeatureFlags `json:",omitempty"`
}
func (o *Config) Clone() *Config {
@ -2889,6 +2945,18 @@ func (o *Config) ToJson() string {
return string(b)
}
func (o *Config) ToJsonFiltered(tagType, tagValue string) string {
filteredConfigMap := structToMapFilteredByTag(*o, tagType, tagValue)
for key, value := range filteredConfigMap {
v, ok := value.(map[string]interface{})
if ok && len(v) == 0 {
delete(filteredConfigMap, key)
}
}
b, _ := json.Marshal(filteredConfigMap)
return string(b)
}
func (o *Config) GetSSOService(service string) *SSOSettings {
switch service {
case SERVICE_GITLAB:
@ -2960,6 +3028,11 @@ func (o *Config) SetDefaults() {
o.DisplaySettings.SetDefaults()
o.GuestAccountsSettings.SetDefaults()
o.ImageProxySettings.SetDefaults(o.ServiceSettings)
o.CloudSettings.SetDefaults()
if o.FeatureFlags == nil {
o.FeatureFlags = &FeatureFlags{}
o.FeatureFlags.SetDefaults()
}
}
func (o *Config) IsValid() *AppError {
@ -3588,4 +3661,66 @@ func (o *Config) Sanitize() {
if o.ServiceSettings.GfycatApiSecret != nil && len(*o.ServiceSettings.GfycatApiSecret) > 0 {
*o.ServiceSettings.GfycatApiSecret = FAKE_SETTING
}
*o.ServiceSettings.SplitKey = FAKE_SETTING
}
// structToMapFilteredByTag converts a struct into a map removing those fields that has the tag passed
// as argument
func structToMapFilteredByTag(t interface{}, typeOfTag, filterTag string) map[string]interface{} {
defer func() {
if r := recover(); r != nil {
mlog.Error("Panicked in structToMapFilteredByTag. This should never happen.", mlog.Any("recover", r))
}
}()
val := reflect.ValueOf(t)
elemField := reflect.TypeOf(t)
if val.Kind() != reflect.Struct {
return nil
}
out := map[string]interface{}{}
for i := 0; i < val.NumField(); i++ {
field := val.Field(i)
structField := elemField.Field(i)
tagPermissions := strings.Split(structField.Tag.Get(typeOfTag), ",")
if isTagPresent(filterTag, tagPermissions) {
continue
}
var value interface{}
switch field.Kind() {
case reflect.Struct:
value = structToMapFilteredByTag(field.Interface(), typeOfTag, filterTag)
case reflect.Ptr:
indirectType := field.Elem()
if indirectType.Kind() == reflect.Struct {
value = structToMapFilteredByTag(indirectType.Interface(), typeOfTag, filterTag)
} else if indirectType.Kind() != reflect.Invalid {
value = indirectType.Interface()
}
default:
value = field.Interface()
}
out[val.Type().Field(i).Name] = value
}
return out
}
func isTagPresent(tag string, tags []string) bool {
for _, val := range tags {
tagValue := strings.TrimSpace(val)
if tagValue != "" && tagValue == tag {
return true
}
}
return false
}

View File

@ -0,0 +1,18 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package model
type FeatureFlags struct {
// Exists only for unit and manual testing.
// When set to a value, will be returned by the ping endpoint.
TestFeature string
// Toggle on and off scheduled jobs for cloud user limit emails see MM-29999
CloudDelinquentEmailJobsEnabled bool
}
func (f *FeatureFlags) SetDefaults() {
f.TestFeature = "off"
f.CloudDelinquentEmailJobsEnabled = false
}

View File

@ -4,14 +4,19 @@
package model
import (
"bytes"
"encoding/json"
"image"
"image/gif"
"image/jpeg"
"io"
"mime"
"net/http"
"path/filepath"
"strings"
"github.com/disintegration/imaging"
"github.com/mattermost/mattermost-server/v5/mlog"
)
const (
@ -53,6 +58,7 @@ type FileInfo struct {
Height int `json:"height,omitempty"`
HasPreviewImage bool `json:"has_preview_image,omitempty"`
MiniPreview *[]byte `json:"mini_preview"` // declared as *[]byte to avoid postgres/mysql differences in deserialization
Content string `json:"-"`
}
func (fi *FileInfo) ToJson() string {
@ -151,6 +157,19 @@ func NewInfo(name string) *FileInfo {
return info
}
func GenerateMiniPreviewImage(img image.Image) *[]byte {
preview := imaging.Resize(img, 16, 16, imaging.Lanczos)
buf := new(bytes.Buffer)
if err := jpeg.Encode(buf, preview, &jpeg.Options{Quality: 90}); err != nil {
mlog.Error("Unable to encode image as mini preview jpg", mlog.Err(err))
return nil
}
data := buf.Bytes()
return &data
}
func GetInfoForBytes(name string, data io.ReadSeeker, size int) (*FileInfo, *AppError) {
info := &FileInfo{
Name: name,

View File

@ -157,7 +157,7 @@ func (group *Group) requiresRemoteId() bool {
func (group *Group) IsValidForUpdate() *AppError {
if !IsValidId(group.Id) {
return NewAppError("Group.IsValidForUpdate", "model.group.id.app_error", nil, "", http.StatusBadRequest)
return NewAppError("Group.IsValidForUpdate", "app.group.id.app_error", nil, "", http.StatusBadRequest)
}
if group.CreateAt == 0 {
return NewAppError("Group.IsValidForUpdate", "model.group.create_at.app_error", nil, "", http.StatusBadRequest)

View File

@ -16,6 +16,7 @@ import (
"io"
"math/big"
"net/http"
"reflect"
"strconv"
"strings"
)
@ -124,13 +125,19 @@ func (p *PostAction) Equals(input *PostAction) bool {
for key, value := range p.Integration.Context {
inputValue, ok := input.Integration.Context[key]
if !ok {
return false
}
if value != inputValue {
return false
switch inputValue.(type) {
case string, bool, int, float64:
if value != inputValue {
return false
}
default:
if !reflect.DeepEqual(value, inputValue) {
return false
}
}
}

View File

@ -22,6 +22,7 @@ const (
JOB_TYPE_EXPIRY_NOTIFY = "expiry_notify"
JOB_TYPE_PRODUCT_NOTICES = "product_notices"
JOB_TYPE_ACTIVE_USERS = "active_users"
JOB_TYPE_CLOUD = "cloud"
JOB_STATUS_PENDING = "pending"
JOB_STATUS_IN_PROGRESS = "in_progress"
@ -65,6 +66,7 @@ func (j *Job) IsValid() *AppError {
case JOB_TYPE_PRODUCT_NOTICES:
case JOB_TYPE_EXPIRY_NOTIFY:
case JOB_TYPE_ACTIVE_USERS:
case JOB_TYPE_CLOUD:
default:
return NewAppError("Job.IsValid", "model.job.is_valid.type.app_error", nil, "id="+j.Id, http.StatusBadRequest)
}

View File

@ -4,7 +4,7 @@
package model
const (
USER_AUTH_SERVICE_LDAP = "ldap"
LDAP_PUBIC_CERTIFICATE_NAME = "ldap-public.crt"
LDAP_PRIVATE_KEY_NAME = "ldap-private.key"
USER_AUTH_SERVICE_LDAP = "ldap"
LDAP_PUBLIC_CERTIFICATE_NAME = "ldap-public.crt"
LDAP_PRIVATE_KEY_NAME = "ldap-private.key"
)

View File

@ -80,7 +80,9 @@ type MarketplacePluginFilter struct {
ServerVersion string
BuildEnterpriseReady bool
EnterprisePlugins bool
Cloud bool
LocalOnly bool
Platform string
}
// ApplyToURL modifies the given url to include query string parameters for the request.
@ -94,7 +96,9 @@ func (filter *MarketplacePluginFilter) ApplyToURL(u *url.URL) {
q.Add("server_version", filter.ServerVersion)
q.Add("build_enterprise_ready", strconv.FormatBool(filter.BuildEnterpriseReady))
q.Add("enterprise_plugins", strconv.FormatBool(filter.EnterprisePlugins))
q.Add("cloud", strconv.FormatBool(filter.Cloud))
q.Add("local_only", strconv.FormatBool(filter.LocalOnly))
q.Add("platform", filter.Platform)
u.RawQuery = q.Encode()
}

View File

@ -21,4 +21,6 @@ const (
MIGRATION_KEY_ADD_SYSTEM_CONSOLE_PERMISSIONS = "add_system_console_permissions"
MIGRATION_KEY_SIDEBAR_CATEGORIES_PHASE_2 = "migration_sidebar_categories_phase_2"
MIGRATION_KEY_ADD_CONVERT_CHANNEL_PERMISSIONS = "add_convert_channel_permissions"
MIGRATION_KEY_ADD_SYSTEM_ROLES_PERMISSIONS = "add_system_roles_permissions"
MIGRATION_KEY_ADD_MANAGE_SHARED_CHANNEL_PERMISSIONS = "manage_shared_channel_permissions"
)

View File

@ -99,6 +99,7 @@ var PERMISSION_USE_CHANNEL_MENTIONS *Permission
var PERMISSION_USE_GROUP_MENTIONS *Permission
var PERMISSION_READ_OTHER_USERS_TEAMS *Permission
var PERMISSION_EDIT_BRAND *Permission
var PERMISSION_MANAGE_SHARED_CHANNELS *Permission
var PERMISSION_SYSCONSOLE_READ_ABOUT *Permission
var PERMISSION_SYSCONSOLE_WRITE_ABOUT *Permission
@ -121,6 +122,9 @@ var PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_CHANNELS *Permission
var PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_PERMISSIONS *Permission
var PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_PERMISSIONS *Permission
var PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_SYSTEM_ROLES *Permission
var PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_SYSTEM_ROLES *Permission
var PERMISSION_SYSCONSOLE_READ_ENVIRONMENT *Permission
var PERMISSION_SYSCONSOLE_WRITE_ENVIRONMENT *Permission
@ -516,6 +520,12 @@ func initializePermissions() {
"authentication.permissions.delete_others_posts.description",
PermissionScopeChannel,
}
PERMISSION_MANAGE_SHARED_CHANNELS = &Permission{
"manage_shared_channels",
"authentication.permissions.manage_shared_channels.name",
"authentication.permissions.manage_shared_channels.description",
PermissionScopeSystem,
}
PERMISSION_REMOVE_USER_FROM_TEAM = &Permission{
"remove_user_from_team",
"authentication.permissions.remove_user_from_team.name",
@ -750,6 +760,18 @@ func initializePermissions() {
"authentication.permissions.use_group_mentions.description",
PermissionScopeSystem,
}
PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_SYSTEM_ROLES = &Permission{
"sysconsole_read_user_management_system_roles",
"authentication.permissions.use_group_mentions.name",
"authentication.permissions.use_group_mentions.description",
PermissionScopeSystem,
}
PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_SYSTEM_ROLES = &Permission{
"sysconsole_write_user_management_system_roles",
"authentication.permissions.use_group_mentions.name",
"authentication.permissions.use_group_mentions.description",
PermissionScopeSystem,
}
PERMISSION_SYSCONSOLE_READ_ENVIRONMENT = &Permission{
"sysconsole_read_environment",
"authentication.permissions.use_group_mentions.name",
@ -855,6 +877,7 @@ func initializePermissions() {
PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_TEAMS,
PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_CHANNELS,
PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_PERMISSIONS,
PERMISSION_SYSCONSOLE_READ_USERMANAGEMENT_SYSTEM_ROLES,
PERMISSION_SYSCONSOLE_READ_ENVIRONMENT,
PERMISSION_SYSCONSOLE_READ_SITE,
PERMISSION_SYSCONSOLE_READ_AUTHENTICATION,
@ -872,6 +895,7 @@ func initializePermissions() {
PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_TEAMS,
PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_CHANNELS,
PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_PERMISSIONS,
PERMISSION_SYSCONSOLE_WRITE_USERMANAGEMENT_SYSTEM_ROLES,
PERMISSION_SYSCONSOLE_WRITE_ENVIRONMENT,
PERMISSION_SYSCONSOLE_WRITE_SITE,
PERMISSION_SYSCONSOLE_WRITE_AUTHENTICATION,
@ -912,6 +936,7 @@ func initializePermissions() {
PERMISSION_PROMOTE_GUEST,
PERMISSION_DEMOTE_TO_GUEST,
PERMISSION_EDIT_BRAND,
PERMISSION_MANAGE_SHARED_CHANNELS,
}
TeamScopedPermissions := []*Permission{

View File

@ -133,6 +133,7 @@ func init() {
PERMISSION_SYSCONSOLE_READ_SITE.Id,
PERMISSION_SYSCONSOLE_READ_AUTHENTICATION.Id,
PERMISSION_SYSCONSOLE_READ_PLUGINS.Id,
PERMISSION_SYSCONSOLE_READ_COMPLIANCE.Id,
PERMISSION_SYSCONSOLE_READ_INTEGRATIONS.Id,
PERMISSION_SYSCONSOLE_READ_EXPERIMENTAL.Id,
}
@ -482,15 +483,16 @@ func (r *Role) IsValidWithoutId() bool {
return false
}
for _, permission := range r.Permissions {
permissionValidated := false
for _, p := range append(AllPermissions, DeprecatedPermissions...) {
check := func(perms []*Permission, permission string) bool {
for _, p := range perms {
if permission == p.Id {
permissionValidated = true
break
return true
}
}
return false
}
for _, permission := range r.Permissions {
permissionValidated := check(AllPermissions, permission) || check(DeprecatedPermissions, permission)
if !permissionValidated {
return false
}

View File

@ -1620,3 +1620,160 @@ func (z *User) Msgsize() (s int) {
s += msgp.BoolSize + msgp.StringPrefixSize + len(z.MfaSecret) + msgp.Int64Size + msgp.BoolSize + msgp.StringPrefixSize + len(z.BotDescription) + msgp.Int64Size + msgp.StringPrefixSize + len(z.TermsOfServiceId) + msgp.Int64Size
return
}
// DecodeMsg implements msgp.Decodable
func (z *UserMap) DecodeMsg(dc *msgp.Reader) (err error) {
var zb0003 uint32
zb0003, err = dc.ReadMapHeader()
if err != nil {
err = msgp.WrapError(err)
return
}
if (*z) == nil {
(*z) = make(UserMap, zb0003)
} else if len((*z)) > 0 {
for key := range *z {
delete((*z), key)
}
}
for zb0003 > 0 {
zb0003--
var zb0001 string
var zb0002 *User
zb0001, err = dc.ReadString()
if err != nil {
err = msgp.WrapError(err)
return
}
if dc.IsNil() {
err = dc.ReadNil()
if err != nil {
err = msgp.WrapError(err, zb0001)
return
}
zb0002 = nil
} else {
if zb0002 == nil {
zb0002 = new(User)
}
err = zb0002.DecodeMsg(dc)
if err != nil {
err = msgp.WrapError(err, zb0001)
return
}
}
(*z)[zb0001] = zb0002
}
return
}
// EncodeMsg implements msgp.Encodable
func (z UserMap) EncodeMsg(en *msgp.Writer) (err error) {
err = en.WriteMapHeader(uint32(len(z)))
if err != nil {
err = msgp.WrapError(err)
return
}
for zb0004, zb0005 := range z {
err = en.WriteString(zb0004)
if err != nil {
err = msgp.WrapError(err)
return
}
if zb0005 == nil {
err = en.WriteNil()
if err != nil {
return
}
} else {
err = zb0005.EncodeMsg(en)
if err != nil {
err = msgp.WrapError(err, zb0004)
return
}
}
}
return
}
// MarshalMsg implements msgp.Marshaler
func (z UserMap) MarshalMsg(b []byte) (o []byte, err error) {
o = msgp.Require(b, z.Msgsize())
o = msgp.AppendMapHeader(o, uint32(len(z)))
for zb0004, zb0005 := range z {
o = msgp.AppendString(o, zb0004)
if zb0005 == nil {
o = msgp.AppendNil(o)
} else {
o, err = zb0005.MarshalMsg(o)
if err != nil {
err = msgp.WrapError(err, zb0004)
return
}
}
}
return
}
// UnmarshalMsg implements msgp.Unmarshaler
func (z *UserMap) UnmarshalMsg(bts []byte) (o []byte, err error) {
var zb0003 uint32
zb0003, bts, err = msgp.ReadMapHeaderBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
if (*z) == nil {
(*z) = make(UserMap, zb0003)
} else if len((*z)) > 0 {
for key := range *z {
delete((*z), key)
}
}
for zb0003 > 0 {
var zb0001 string
var zb0002 *User
zb0003--
zb0001, bts, err = msgp.ReadStringBytes(bts)
if err != nil {
err = msgp.WrapError(err)
return
}
if msgp.IsNil(bts) {
bts, err = msgp.ReadNilBytes(bts)
if err != nil {
return
}
zb0002 = nil
} else {
if zb0002 == nil {
zb0002 = new(User)
}
bts, err = zb0002.UnmarshalMsg(bts)
if err != nil {
err = msgp.WrapError(err, zb0001)
return
}
}
(*z)[zb0001] = zb0002
}
o = bts
return
}
// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z UserMap) Msgsize() (s int) {
s = msgp.MapHeaderSize
if z != nil {
for zb0004, zb0005 := range z {
_ = zb0005
s += msgp.StringPrefixSize + len(zb0004)
if zb0005 == nil {
s += msgp.NilSize
} else {
s += zb0005.Msgsize()
}
}
}
return
}

View File

@ -31,6 +31,10 @@ const (
SYSTEM_WARN_METRIC_NUMBER_OF_ACTIVE_USERS_500 = "warn_metric_number_of_active_users_500"
SYSTEM_WARN_METRIC_NUMBER_OF_POSTS_2M = "warn_metric_number_of_posts_2M"
SYSTEM_WARN_METRIC_LAST_RUN_TIMESTAMP_KEY = "LastWarnMetricRunTimestamp"
AWS_METERING_REPORT_INTERVAL = 1
AWS_METERING_DIMENSION_USAGE_HRS = "UsageHrs"
USER_LIMIT_OVERAGE_CYCLE_END_DATE = "UserLimitOverageCycleEndDate"
OVER_USER_LIMIT_FORGIVEN_COUNT = "OverUserLimitForgivenCount"
)
const (

View File

@ -15,6 +15,42 @@ type Thread struct {
Participants StringArray `json:"participants"`
}
type ThreadResponse struct {
PostId string `json:"id"`
ReplyCount int64 `json:"reply_count"`
LastReplyAt int64 `json:"last_reply_at"`
LastViewedAt int64 `json:"last_viewed_at"`
Participants []*User `json:"participants"`
Post *Post `json:"post"`
}
type Threads struct {
Total int64 `json:"total"`
Threads []*ThreadResponse `json:"threads"`
}
type GetUserThreadsOpts struct {
// Page specifies which part of the results to return, by PageSize. Default = 0
Page uint64
// PageSize specifies the size of the returned chunk of results. Default = 30
PageSize uint64
// Extended will enrich the response with participant details. Default = false
Extended bool
// Deleted will specify that even deleted threads should be returned (For mobile sync). Default = false
Deleted bool
// Since filters the threads based on their LastUpdateAt timestamp.
Since uint64
}
func (o *Threads) ToJson() string {
b, _ := json.Marshal(o)
return string(b)
}
func (o *Thread) ToJson() string {
b, _ := json.Marshal(o)
return string(b)

View File

@ -98,6 +98,12 @@ type User struct {
TermsOfServiceCreateAt int64 `db:"-" json:"terms_of_service_create_at,omitempty"`
}
//msgp UserMap
// UserMap is a map from a userId to a user object.
// It is used to generate methods which can be used for fast serialization/de-serialization.
type UserMap map[string]*User
type UserUpdate struct {
Old *User
New *User
@ -540,11 +546,11 @@ func (u *User) SanitizeInput(isAdmin bool) {
if !isAdmin {
u.AuthData = NewString("")
u.AuthService = ""
u.EmailVerified = false
}
u.LastPasswordUpdate = 0
u.LastPictureUpdate = 0
u.FailedAttempts = 0
u.EmailVerified = false
u.MfaActive = false
u.MfaSecret = ""
}

View File

@ -516,7 +516,7 @@ func IsValidHttpUrl(rawUrl string) bool {
return false
}
if _, err := url.ParseRequestURI(rawUrl); err != nil {
if u, err := url.ParseRequestURI(rawUrl); err != nil || u.Scheme == "" || u.Host == "" {
return false
}

View File

@ -13,6 +13,7 @@ import (
// It should be maintained in chronological order with most current
// release at the front of the list.
var versions = []string{
"5.30.0",
"5.29.0",
"5.28.0",
"5.27.0",

View File

@ -35,7 +35,7 @@ const avgReadMsgSizeBytes = 1024
// WebSocketClient stores the necessary information required to
// communicate with a WebSocket endpoint.
// A client must read from PingTimeoutChannel, EventChannel and ResponseChannel to prevent
// deadlocks from occuring in the program.
// deadlocks from occurring in the program.
type WebSocketClient struct {
Url string // The location of the server like "ws://localhost:8065"
ApiUrl string // The API location of the server like "ws://localhost:8065/api/v3"

View File

@ -57,6 +57,7 @@ const (
WEBSOCKET_EVENT_CONFIG_CHANGED = "config_changed"
WEBSOCKET_EVENT_OPEN_DIALOG = "open_dialog"
WEBSOCKET_EVENT_GUESTS_DEACTIVATED = "guests_deactivated"
WEBSOCKET_EVENT_USER_ACTIVATION_STATUS_CHANGE = "user_activation_status_change"
WEBSOCKET_EVENT_RECEIVED_GROUP = "received_group"
WEBSOCKET_EVENT_RECEIVED_GROUP_ASSOCIATED_TO_TEAM = "received_group_associated_to_team"
WEBSOCKET_EVENT_RECEIVED_GROUP_NOT_ASSOCIATED_TO_TEAM = "received_group_not_associated_to_team"
@ -68,6 +69,7 @@ const (
WEBSOCKET_EVENT_SIDEBAR_CATEGORY_ORDER_UPDATED = "sidebar_category_order_updated"
WEBSOCKET_WARN_METRIC_STATUS_RECEIVED = "warn_metric_status_received"
WEBSOCKET_WARN_METRIC_STATUS_REMOVED = "warn_metric_status_removed"
WEBSOCKET_EVENT_CLOUD_PAYMENT_STATUS_UPDATED = "cloud_payment_status_updated"
)
type WebSocketMessage interface {
@ -201,6 +203,22 @@ func (ev *WebSocketEvent) ToJson() string {
return string(b)
}
// Encode encodes the event to the given encoder.
func (ev *WebSocketEvent) Encode(enc *json.Encoder) error {
if ev.precomputedJSON != nil {
return enc.Encode(json.RawMessage(
fmt.Sprintf(`{"event": %s, "data": %s, "broadcast": %s, "seq": %d}`, ev.precomputedJSON.Event, ev.precomputedJSON.Data, ev.precomputedJSON.Broadcast, ev.Sequence),
))
}
return enc.Encode(webSocketEventJSON{
ev.Event,
ev.Data,
ev.Broadcast,
ev.Sequence,
})
}
func WebSocketEventFromJson(data io.Reader) *WebSocketEvent {
var ev WebSocketEvent
var o webSocketEventJSON

View File

@ -14,6 +14,7 @@ import (
var (
DefaultUrlSchemes = []string{"http", "https", "ftp", "mailto", "tel"}
wwwAutoLinkRegex = regexp.MustCompile(`^www\d{0,3}\.`)
)
// Given a string with a w at the given position, tries to parse and return a range containing a www link.
@ -30,7 +31,7 @@ func parseWWWAutolink(data string, position int) (Range, bool) {
}
// Check that this starts with www
if len(data)-position < 4 || !regexp.MustCompile(`^www\d{0,3}\.`).MatchString(data[position:]) {
if len(data)-position < 4 || !wwwAutoLinkRegex.MatchString(data[position:]) {
return Range{}, false
}
@ -59,9 +60,8 @@ func isAllowedBeforeWWWLink(c byte) bool {
switch c {
case '*', '_', '~', ')':
return true
default:
return false
}
return false
}
// Given a string with a : at the given position, tried to parse and return a range containing a URL scheme
@ -153,9 +153,8 @@ func checkDomain(data string, allowShort bool) int {
// this is called from parseWWWAutolink
if foundPeriod {
return i
} else {
return 0
}
return 0
}
// Returns true if the provided link starts with a valid character for a domain name. Equivalent to
@ -251,7 +250,6 @@ func canEndAutolink(c rune) bool {
switch c {
case '?', '!', '.', ',', ':', '*', '_', '~', '\'', '"':
return false
default:
return true
}
return true
}

View File

@ -37,13 +37,14 @@ type Range struct {
End int
}
func closeBlocks(blocks []Block, referenceDefinitions *[]*ReferenceDefinition) {
func closeBlocks(blocks []Block, referenceDefinitions []*ReferenceDefinition) []*ReferenceDefinition {
for _, block := range blocks {
block.Close()
if p, ok := block.(*Paragraph); ok && len(p.ReferenceDefinitions) > 0 {
*referenceDefinitions = append(*referenceDefinitions, p.ReferenceDefinitions...)
referenceDefinitions = append(referenceDefinitions, p.ReferenceDefinitions...)
}
}
return referenceDefinitions
}
func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefinition) {
@ -78,7 +79,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
for i := lastMatchIndex; i >= 0; i-- {
if container, ok := openBlocks[i].(ContainerBlock); ok {
if addedBlocks := container.AddChild(newBlocks); addedBlocks != nil {
closeBlocks(openBlocks[i+1:], &referenceDefinitions)
referenceDefinitions = closeBlocks(openBlocks[i+1:], referenceDefinitions)
openBlocks = openBlocks[:i+1]
openBlocks = append(openBlocks, addedBlocks...)
didAdd = true
@ -98,7 +99,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
continue
}
closeBlocks(openBlocks[lastMatchIndex+1:], &referenceDefinitions)
referenceDefinitions = closeBlocks(openBlocks[lastMatchIndex+1:], referenceDefinitions)
openBlocks = openBlocks[:lastMatchIndex+1]
if openBlocks[lastMatchIndex].AddLine(indentation, r) {
@ -109,7 +110,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
for i := lastMatchIndex; i >= 0; i-- {
if container, ok := openBlocks[i].(ContainerBlock); ok {
if newBlocks := container.AddChild([]Block{paragraph}); newBlocks != nil {
closeBlocks(openBlocks[i+1:], &referenceDefinitions)
referenceDefinitions = closeBlocks(openBlocks[i+1:], referenceDefinitions)
openBlocks = openBlocks[:i+1]
openBlocks = append(openBlocks, newBlocks...)
break
@ -119,7 +120,7 @@ func ParseBlocks(markdown string, lines []Line) (*Document, []*ReferenceDefiniti
}
}
closeBlocks(openBlocks, &referenceDefinitions)
referenceDefinitions = closeBlocks(openBlocks, referenceDefinitions)
return document, referenceDefinitions
}

View File

@ -595,7 +595,7 @@ func ParseInlines(markdown string, ranges []Range, referenceDefinitions []*Refer
}
func MergeInlineText(inlines []Inline) []Inline {
var ret []Inline
ret := inlines[:0]
for i, v := range inlines {
// always add first node
if i == 0 {

View File

@ -3,13 +3,16 @@
package markdown
import "strings"
type Line struct {
Range
}
func ParseLines(markdown string) (lines []Line) {
func ParseLines(markdown string) []Line {
lineStartPosition := 0
isAfterCarriageReturn := false
lines := make([]Line, 0, strings.Count(markdown, "\n"))
for position, r := range markdown {
if r == '\n' {
lines = append(lines, Line{Range{lineStartPosition, position + 1}})
@ -23,5 +26,5 @@ func ParseLines(markdown string) (lines []Line) {
if lineStartPosition < len(markdown) {
lines = append(lines, Line{Range{lineStartPosition, len(markdown)}})
}
return
return lines
}

View File

@ -23,9 +23,8 @@ func isWhitespace(c rune) bool {
switch c {
case ' ', '\t', '\n', '\u000b', '\u000c', '\r':
return true
default:
return false
}
return false
}
func isWhitespaceByte(c byte) bool {