Commit Graph

11985 Commits

Author SHA1 Message Date
Claudio Costa
80dd2915db [MM-19914] Fix data races in WebSocketEvent (#13039)
* Make WebSocketEvent type immutable

* Update code to use updated immutable WebSocketEvent type

* Export WebSocketEvent fields and mark them as deprecated
2019-12-24 09:32:11 +01:00
Claudio Costa
9ab7bee0a6 Return http.StatusNotFound error when trying to get a channel by name without permissions (#13443) 2019-12-23 21:46:52 +01:00
Jesús Espino
b3e49ec45c Use require/assert.Empty instead of require/assert.Len(t, X, 0) (#13413) 2019-12-22 12:35:31 +01:00
Christopher Speller
fdd1ae974f Fix encoding on configuration tables. (#13296) 2019-12-20 15:31:03 -08:00
catalintomai
e48d093d01 MM-19877: Remove references to PermanentDeleteBatch from audit store (#13393)
* MM-19877: Remove references to PermanentDeleteBatch from audit store
2019-12-20 15:37:01 +00:00
Jesús Espino
68e0b1fdc2 Enforces structured logging in enterprise code (#13444) 2019-12-20 15:18:59 +01:00
Sanele T. Mahlalela
de9a0197e2 [GH-13074] Migrate TermsOfServiceCache from store/sqlstore/terms_of_service.go to the new store/localcachelayer (#13205)
* migrated termsOfServiceCache from sqlstore to localcachelayer, and mocked store tests

* revert gitignore local change

* fixed caching in termsOfService Get, and added basic tests for termsOfServiceCache

* added a test for cache save, and fixed call to Store tests

* fixed GeLatest termsOfService from cache test

* added license headers to terms_of_service cache files

* using doStandardReadFromCache and doStandardAddToCache when reading and writing to cache

* removed unused variable, termsOfServiceCacheName

* added special key for the latest termsOfService value in termsOfServiceCache

* updated license information on localcachelayer termsOfServiceCache files

* fixed not updating latest termsOfServiceCache on Get by ID, and invalidating cache cluster on termsOfServiceCache save

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2019-12-20 13:51:54 +01:00
Miguel de la Cruz
f41c90657e Remove bad update user email example (#13356) 2019-12-20 04:37:45 -08:00
Agniva De Sarker
c9cd14b50b MM-21331: Add aggregate cache metrics for channelByNameCache (#13440)
The `channelByNameCache` in the `GetByNames` query checks each teamId+channelName
combination in the cache and if any of the keys is not present, it queries the DB.

In this case, this is effectively a cache miss from the point of view of user.
But since the cache is at a teamId+channelName level, there may be several hits and some misses.
This is misleading as it does not generate proper metrics and might lead to a
false assumption of how effective the cache is.

We create separate metrics which account for all or none cache hits/misses.
This removes the old metrics which are used by other queries. So they are now separated,
and it will improve both the old and new metric. Because the old metric is not contaminated,
and the new metric is also separate.
2019-12-20 17:04:19 +05:30
Vladimir Lebedev
e4481aae21 MM-20104 -Migrate channelCache cache from store/sqlstore/channel_store.go to th… (#13254)
* Migrate channelCache cache from store/sqlstore/channel_store.go to the new store/localcachelayer

* fix import for new path

* remove unnecessary code, refactor cache constant

* resolve conflicts

* fix missing variable and import after merging

* refactor code, fix current issue

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2019-12-20 13:34:58 +05:30
Vladimir Lebedev
722924b910 MM-19508 Extend ShouldProcessMessage to filter out from_webhoo… (#13270)
Extend ShouldProcessMessage to filter out from_webhook posts
2019-12-19 20:52:41 +01:00
Claudio Costa
7274f4c6c2 [MM-21020] Return same error when creating a duplicate channel (#13429)
* Return same error when trying to create a channel with the same name of an existing one

* Remove unused arguments
2019-12-19 18:50:20 +01:00
Jesús Espino
fc9d49b2d2 MM-21254: Removing unnused/unnecesary getClientLicense etag (#13416) 2019-12-19 17:00:15 +01:00
Scott Bishel
3bccc03df3 MM-19872: Update dependencies for enterprise implementation of new SAML2 golib. (#13298)
* Update dependencies for enterprise implementation of new SAML2 golib.

* add indirect
2019-12-19 08:27:34 -07:00
Hossein Ahmadian-Yazdi
155ada09fb [MM-10858] Channel Member Update Websocket Event (#13305)
* Channel Member update event

* Address PR comments and extend tests

* golang ci addressed

* Update api4/channel_test.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>
2019-12-19 08:53:29 -05:00
Scott Bishel
be3e008dca MM-19867: - Implement allowing multiple SAML Libraries (#13299)
* Implement allowing multiple SAML Libraries

* fix unit tests

* updates based on review feedback

* Only set on startup, not config changes

* update unit tests, reload enterprise

* need to reset for previous tests

* update license statement

* fix licensing line
2019-12-18 15:35:53 -07:00
Martin Kraft
75ffd0b69e MM-14675: Eliminates implicit GroupChannel/GroupTeam associations. (#13199)
* MM-14675: Upserts GroupTeam when GroupChannel is linked.
MM-14675: Delete all associated GroupChannels when deleting a GroupTeam.
MM-14675: Using replica DB where possible.
MM-14675: Updates create method used in tests.

* MM-14675: Removes unnecessary DB retrieval of GroupSyncable record.
2019-12-18 08:54:09 -05:00
Sanele T. Mahlalela
0ffe199928 A bit of cleanup in localcachelayer test descriptions (#13283) 2019-12-18 14:10:00 +01:00
Johannes Tigges
e43b404579 GH-13376: Improve community server links and phrasing in READM… (#13379)
Improve community server links and phrasing in README.md to be more inviting and accurate.

Fixes #13376
2019-12-18 12:14:53 +01:00
Agniva De Sarker
0e6f0cfbd6 MM-21118: Use querybuilder instead of fmt.Sprintf in channelStore (#13385)
* MM-21118: Use querybuilder instead of fmt.Sprintf in channelStore

We use the querybuilder API instead of just building the query string
manually using fmt.Sprintf

* Replaced comma with colon
2019-12-17 18:03:38 +01:00
Hossein Ahmadian-Yazdi
de0672937c [MM-19422] Add SQL trace and LDAP trace output to both console and server logs (#13190)
* Add MLOG for sql store

* Update printf function

* Update store/sqlstore/supplier.go

Co-Authored-By: Martin Kraft <martin@upspin.org>

* Update go mod

* update go mod and tidy it up

* update vendor folder
2019-12-17 09:47:09 -05:00
Agniva De Sarker
a83df931b9 Replace pipe with redirection to a subshell (#13409)
When the writing process sends an EAGAIN to the fd, tee dies.
We correct this behavior by redirecting the output to a subshell
which handles this correctly.

Relevant link here: https://serverfault.com/questions/369757/why-is-this-tee-losing-stdout
2019-12-17 14:58:25 +01:00
Jesús Espino
4cbea3d5b5 Use require.Len instead of require.Equal for length checks in model/search_params_test.go (#13410)
* Use require.Len instead of require.Equal for length checks in model/search_params_test.go

* Using require.Empty instead of require.Len(t, X, 0)
2019-12-17 12:12:38 +01:00
Jesús Espino
b8ef62e502 Adding structuredLogging check and fix inconsistencies (#13370)
* Adding structuredLogging check and fix inconsistencies

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments
2019-12-16 13:57:21 +01:00
Jesús Espino
fd0a3a687d Exposing named error from zap api on our mlog api (#13395) 2019-12-15 13:54:50 +01:00
Claudio Costa
2b7916e08f [MM-21119] Update config files permissions (#13386)
* Update config files permissions

* Add error check

* Update permissions for persist
2019-12-13 19:53:42 +01:00
Claudio Costa
c06b2d28c3 Disallow changing type when updating a channel (#13387) 2019-12-13 18:12:47 +01:00
Agniva De Sarker
e2e2ad48ce Add -trimpath flag to the builds (#13348)
Go 1.13 introduced this new flag which removes all absolute file system paths
from the binary and just keeps the module path / GOPATH. To debug binary
crashes or stack traces, we only need the path to the code and not the full
file path. Hence this is a quick way to reduce the binary size without any information
loss.

Shaves off around 750KB from the server binary.
2019-12-13 14:12:28 +01:00
Jesse Hallam
89c0b61bc3 MM-21103: change plugin signature path (#13360)
* MM-21103: change plugin signature path

Save as `<plugin_id>.tar.gz.sig` instead of `<plugin_id>.sig`. The latter was a relic of the previous design to support multiple plugin signatures, but now creates an inconsistency with how the original source files were supplied as `<some_name>.tar.gz` and `<some_name>.tar.gz.sig`.

Fixes: https://mattermost.atlassian.net/browse/MM-21103

* relax signature matches to avoid assuming signatures always exist
2019-12-12 13:45:55 -04:00
Agniva De Sarker
7d499d2750 MM-21116: Improve channelSearch SQL query generation (#13371)
* MM-21116: Improve channelSearch SQL query generation

The likeTerm from buildFulltextClause was being built inefficient using strings.
We change it to use squirrel to build the query.

And while at it, we also change the len check with checking with
an empty string which is more idiomatic. Both compile to the same
code, so there is no difference performance wise.

* Use a better variable name
2019-12-12 23:13:33 +05:30
Eli Yukelzon
4d3f7ae06c Revert "fix npm ci step" (#13378)
Automatic Merge
2019-12-12 09:49:18 -05:00
Jason Blais
6e275d0866 Add missing diagnostics for 5.18 release (#13358)
@hahmadia https://github.com/mattermost/mattermost-server/pull/13018
@sbishel https://github.com/mattermost/mattermost-server/pull/12362
@ali-farooq0 https://github.com/mattermost/mattermost-server/pull/13017
2019-12-12 09:17:31 -05:00
Claudio Costa
acb19f640b [MM-21115] Add permissions check on user_typing event (#13373)
* Add permissions check on user_typing event

* Fix test
2019-12-11 20:18:36 +01:00
Claudio Costa
637d9e0ea6 Add CSRF check for handlers that do not require a session but have one (#13354) 2019-12-11 07:56:53 -08:00
Eli Yukelzon
f672eb7291 corrected file permissions for localstore (#13369)
Automatic Merge
2019-12-11 09:42:00 -05:00
Agniva De Sarker
bc496a0d96 Add the old fmt and vet targets to legacy.mk (#13202)
* Add the old fmt and vet targets to legacy.mk

This is to ease the transition until a time
when everybody has moved to using golangci-lint.

* Just run golangci-lint for make vet
2019-12-11 17:13:43 +05:30
larkox
d8f5b2a4da [GH-13099] Migrate lastPostTimeCache cache from store/sqlstore/post_store.go to the new store/localcachelayer (#13134)
Automatic Merge
2019-12-11 06:42:00 -05:00
Jesse Hallam
bb1facb1f5 MM-20755: fix post actions in DMs/GMs (#13248)
* MM-20755: fix post actions in DMs/GMs

The fix for https://github.com/mattermost/mattermost-server/issues/12377 assumed that all channels have teams, but this is false for DMs and GMs.  Test for this and avoid failing on a missing team as such.

Fixes: https://mattermost.atlassian.net/browse/MM-20755

* tweak code for clarity
2019-12-10 12:57:54 -04:00
Ben Schumacher
354f20e7f0 Bump app version to 5.20 (#13230) 2019-12-10 13:17:06 +01:00
Jesús Espino
f55a81163e Adding mattermost-govet to the pipeline (#13257)
* Adding mattermost-govet to the pipeline

* Trying to fix circleCI config

* Trying to fix circleCI config

* Trying to fix circleCI config

* Trying to fix circleCI config

* Update Makefile

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* Update Makefile

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Addressing PR review comments

* Adding legacy check-licenses task to legacy.mk

* Removing unnecesary GO111MODULE=off lines

* Adding jenkins mattermost-govet installation
2019-12-10 13:10:35 +01:00
Jason Frerich
876cf82bad [MM-14725] Inform System Admins when a user who managed bot ac… (#11669)
* Add notification, to sysadmins, when a user is disabled and the user
owns bots.

* If the user doesn't have any bots, there is no need to send a
notifcation to sysadmins

* Remove comment

* Update documention link

* Send as System

* Query teams for each sysadmin and add first response to hardcoded link.

* Remove fmt.print debug statements

* remove link with hard-coded team.  Will add this as future enhancement
Expose GetDisableBotSysadminMessage function so it can be tested
Add test new function for testing new notification feature

* Fix shadow error

* Swap sentences in the message when  System Console > Bot Accounts > Disable bot accounts when owner is deactivated: is set to false

* Another message correction

* Rename Custom Integrations to Integrations

* rename botsDisabled variable to disableBotsSetting

* - increase the number of bots and sysadmins queried to 1000.
- limit the number of bots printed in the post to 10, but mention the
  total bots owned by the user

* Enable translations for sysadmin messages

* - Rename function. The actual purpose for the function is to notify
  sysadmins that a user, that owned bots, was disabled.
- convert GetDisableBotSysadminMessage from a function to a method.
  This allows getting *a.Config().ServiceSettings.DisableBotsWhenOwnerIsDeactivated
  in the method and avoids having to pass the value as an input to a
  function

* fix "make i18n-extract" error.  Reorganize .json file

* Correct the upper range value to be the minimum of number of elements in the
userBots array, or the upper limit (10)

* replace t.fatal with require statements
fix golangci-lint errors

* Create separate message when user managed less than or fewer than 10 bots
Test cases for both message types

* fix i18n sorting

* Using pagination to get the bots and sysadmins instead of setting
arbitrary value for PerPage and only retrieving first page

* only use one translation ID for the message.
push all logic into the template so translators can view the logic
add disableBotsSetting and printAllBots variables to the translation
map

* Break the for loop once len(bots) < perPage value, instead of
breaking once there are no bots. This saves one additional call
2019-12-06 20:00:47 -06:00
Jesse Hallam
345b0c560a MM-20948: nocache for static plugin assets (#13322)
Serve static plugin assets with a `Cache-Control: no-cache, public` header. This avoids caching a 404 response for such an asset, preventing it from being loaded until expiry even if the file later becomes available.

This is currently preventing updates of plugins on community and would generally affect any customer with a cache in front of the Mattermost servers.

Fixes: https://mattermost.atlassian.net/browse/MM-20948
2019-12-05 23:57:30 -04:00
Carlos Tadeu Panato Junior
d3a1a37f93 upgrade DB to 5.18 (#13315) 2019-12-05 23:06:50 +01:00
Ali Farooq
186524bba4 Revert "MM-20105: Migrate channelByNameCache cache from store/sqlstore/channel_store.go to the new store/localcachelayer (#13189)" (#13329)
Automatic Merge
2019-12-05 16:15:07 -05:00
Jesús Espino
0d735042d9 Fixing flaky test around websocket counts in analytics API endpoint (#13314) 2019-12-05 22:06:15 +01:00
Shota Gvinepadze
9898f91f7e [MM-20309] production public key (#13244)
* Add production public key

* Fix unit tests
2019-12-05 23:41:52 +04:00
Ben Schumacher
5122b9e292 [MM-20723] Add golint for plugin package to golangci (#13090) 2019-12-05 20:31:53 +01:00
Carlos Tadeu Panato Junior
d12bf77f53 dont build master or release branches (#13310)
those branches are being built in the internal jenkins
2019-12-05 17:05:52 +01:00
Mario de Frutos Dieguez
8347f3e1fa Bulk import/export supports direct messages from a user to themselves (#13200)
* Test added to check support for import of messages sent to your own DM
channel

* Support for single member direct channel messages and posts

Now bulk import is able to export/import the self direct channel and
the posts inside

* Improve how the copy of channel members for DM and DM posts

* Improved the tests for the export self-channels
2019-12-05 22:58:38 +08:00
Farhan Munshi
8cafd11162 [MM-20620] Handle trailing slash when building marketplace api… (#13273) 2019-12-04 17:55:53 +01:00