Commit Graph

167 Commits

Author SHA1 Message Date
Jesús Espino
8199e7b5f3 Fix mailservice tests race condition (#16999) 2021-02-23 15:55:16 +01:00
Atanas Alexandrov
e44190f4cc NO-TCIKET fix bad smells - error strings should not be capitalized (#16930)
Automatic Merge
2021-02-23 06:22:27 +01:00
Jesús Espino
2b6c0e9746 Adding bulk-indexing and improving a bit the name indexing for bleve and elasticsearch (#16704)
* Adding bulk-indexing and improving a bit the name indexing for bleve and elasticsearch

* Update services/searchengine/bleveengine/bleve.go

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Update store/sqlstore/file_info_store.go

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Update store/sqlstore/file_info_store.go

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Adding tests requested in the PR review

* fixing tests

* Adding a feature flag to avoid indexing files before the feature is released

* Fixing i18n

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-22 14:28:52 +01:00
Jesús Espino
5f190b5624 Isolate more the mfa service (#16925)
* Isolate more the mfa service

* Simplifing the mfa service

* Removing channels and adding waitgroup

* Migrating mfa service to regular errors

* Fixing tests

* i18n extract

* Addressing PR review comments

* Removing unneeded struct
2021-02-18 12:12:21 +01:00
Chetanya Kandhari
7585e16d84 Custom status feature (#16835)
* Create the system console setting and send to webapp

* MI-1145: Add custom status APIs

* MI-1145 Add slash commands to set and clear status

* Add validation for custom status API

* Trim custom status message

* Code refactoring

- Run gofmt

- Rename constants

* Remove sendUserUpdated webhook event

* Fix recent custom status length

* Update error conditions

* Disable /status slash command when config setting is off

* MI-1155: Create the feature flag for custom status APIs and slash commands

* Move recent custom statuses to user preferences (#7)

* Move recent custom statuses to user preferences

* Code refactoring and feedback changes

* Update slash command text and emoji regex

* Make the custom status feature flag off by default

* Update SetCustomStatus, handle recents not set better

* Update status codes

* Update slash command handling

* Add telementry settings

* Fix i18n order

* Revert "Fix i18n order"

This reverts commit 499f7eaca8.

* Update i18n strings
2021-02-18 12:08:01 +01:00
Jesús Espino
d06a62ce64 Reduce the coupling of the mailservice with the rest of the application (#16898)
* Reduce the coupling of the mailservice with the rest of the application

* Fixing tests in CI

* Simplifiying mailservice config

* Addressing PR review comments

* Fixing tests

* Removing unnecesary type definition

* Fixing ServerName usage
2021-02-16 12:42:03 +01:00
Ibrahim Serdar Acikgoz
e9ea3abbf5 [MM-32136] add "telemetry: disabled" comments to the Config struct (#16758)
* add config telemetry comments

* reflect review comments

* add ThreadAutoFollow and EnableLinkPreviews to telemetries

* ignore NativeAppSettings.AppCustomURLSchemes from tm

* add export settings to telemetries
2021-02-15 22:26:19 +03:00
Jesús Espino
a3de71fba4 Reducing the filestore dependencies from the rest of the source code (#16816)
* Reducing the filestore dependencies from the rest of the source code

* Making more generic config conversion to FileBackendSettings

* Fixing usage of the NewFileBackend function

* Fixing more usages of the NewFileBackend function

* Fix some linter errors

* Fix more linter errors

* Fixing some unit tests

* Fixing linter problem

* Addressing PR review comments

* Simplifing the CopyFile for tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-15 10:09:28 +01:00
Jesús Espino
5f043b0a08 Changed require.Nil to require.NoError when error type is used (#16900) 2021-02-10 09:30:36 +01:00
Anurag Shivarathri
0abceccb58 MM-32047:Added AppCustomURLSchemes settings to telemetry (#16796)
* Added AppCustomURLSchemes to telemetry

* Added Slices compare check isDefault function

* Replaced reflect based solution for comparing string slices

* added default array

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-09 21:24:28 +05:30
Jesús Espino
fbe0294e86 Migrating AppError to error for mailservice (#16810)
* Migrating AppError to error for mailservice

* Updating i18n strings

* Fixing shadow variable problem

* Addressing PR review comments

* fixing test
2021-02-09 12:28:42 +01:00
Atanas Alexandrov
cda69d4dd7 [NO-TICKET] Remove unused function attributes (#16878) 2021-02-08 14:41:07 +05:30
Mahmudul Haque
a63dea6c55 unparam lint (#16771)
* fixed: `identifier` is unused lint error

* make saveMultipleMembersT method saveMultipleMembers

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-04 11:08:05 +05:30
Atanas Alexandrov
a31f666019 [NO-TICKET] Cleanup - remove unused code (#16828) 2021-02-02 11:28:31 +01:00
Hossein
01f264cd62 [MM-31790] Support Packet Generation BACKEND (#16667)
* init commit

* clean up the code

* make mocks

* fix translations

* mocks and lint fixes

* add tests

* little fixes

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Update i18n/en.json

Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>

* Address Comments

* fix i18n

* update api endpoint

* add enable file and file level for conditional show of banner

* Address Comments

* Make it more clear about returns

* Create zip file utility function

* update en.json

* address comments

* write tests

* check for data in test

* remove warning string

* Correct expected and actual

* set database through environment variables

* reset environment variable at end of test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
2021-02-01 15:18:52 -05:00
Claudio Costa
9c9fbe6dd9 [MM-32234] Fix config.json getting reset (#16805)
* Add support for read-only config stores

* Allow read/write config store for plugin commands that require it
2021-01-28 20:04:17 +01:00
Agniva De Sarker
5b45b0762e MM-31993: Add flag to disable gossip compression (#16701)
* MM-31993: Add flag to disable gossip compression

Load tests have shown that our workload is not very suitable
to LZW compression. And in fact, compressing leads to more
network bandwidth than less. So we are spending more CPU cycles,
and creating more traffic, leading to a lose-lose situation.

We add a flag to control this behavior. Ideally, this should not
be a flag in the first place, since there is never a need to enable this
because clearly there is no benefit.

But to keep our community servers working, we need to be able
to configure this.

https://mattermost.atlassian.net/browse/MM-31993

```release-notes
Add a flag to disable compression in the Gossip protocol.

By default the value of the flag is false, which is not the existing
default. Therefore, this will cause incompatibility issues during upgrade
where servers of different versions are part of the same cluster.
It is recommended to completely shutdown a cluster, and then do an upgrade.
```

* flip flag to true

* Trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-28 11:41:03 +05:30
Agniva De Sarker
2846ad9f93 MM-31391: Add max connection idle timeout to config (#16792)
* Update config.go

* Update telemetry.go

* Update store and store test

* Update settings.go

* use new error code

* Trigger CI

Co-authored-by: Haardik Dharma <dharmahaardik08@gmail.com>
2021-01-28 09:37:15 +05:30
Arjuna Marambe
5f16fc644a 15249 sync.pool (#16103)
* use sync.pool for session

* added back to sync pool

* reverted change

* added a new line

* added back session object

* added back session object

* added back session object

* revert

* refactored into function

* added the session object back into the pool

* work in progress

* work in progress

* work in progress

* code review comments

Co-authored-by: Arjuna Marambe <arjunam@buildxact.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-27 19:58:24 +01:00
Madhav Hugar
94c24eea20 Fix empty string comparison issues in the codebase (#16686)
Automatic Merge
2021-01-25 11:15:17 +01:00
Claudio Costa
200a56fa5a [MM-28423] Implement ImportDelete job (#16588)
* Implement ImportDelete job

* Add missing translation

* Improve logging

* Avoid deleting the file in case of errors
2021-01-25 10:40:30 +01:00
Devin Binnie
95ee824c8b [MM-30851] Replace ExperimentalChannelSidebarOrganization with EnableLegacySidebar (#16529)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-18 10:15:31 -05:00
Jesús Espino
2a63b5552a Add search engine support for files (#16190)
* Add search engine support for files

* Fixing i18n

* Fix golangci-lint

* Fix consistency problem in the Search receiver functio of the SqlFileStore

* Fixing some tests

* Fixing test

* Apply suggestions from code review

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>

* Addressing PR review comments

* Removing some empty lines

* Address PR review comments

* Fixing problem after merge master

* Fixing spelling problem

* Add missed translations

* Fixing certain global variable usages after merge master

* Fixing some constants usage

* Fixing goimports order

Co-authored-by: Mario de Frutos Dieguez <mario@defrutos.org>
2021-01-11 15:14:16 +01:00
Agniva De Sarker
e89b26e8f3 goimports (#16640)
* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w`

* added goimports lint check to .golangci.yml

* format using `goimports -local github.com/mattermost/mattermost-server/v5 -w` for a corner case

* make app-layers, *-mocks and store-layers for ci check

Co-authored-by: Mahmudul Haque <mahmudulhaque@protonmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-01-07 22:42:43 +05:30
Agniva De Sarker
091659c8ad MM-31436: Upgrade dependencies (#16605)
* MM-31436: Upgrade dependencies

Ran make update-dependencies

https://mattermost.atlassian.net/browse/MM-31436

```release-note
NONE
```

* add missing dep

* fix lru marshaling
2021-01-07 14:39:17 +05:30
Agniva De Sarker
09d2f698cc MM-31061: Remove pointers to slice (#16631)
* MM-31061: Remove pointers to slice

This PR removes instances of pointers
to slices in the codebase. There are some other instances in app/import_functions.go
but that's necessary to prevent empty arrays from appearing in the JSON output.

```release-note
NONE
```

https://mattermost.atlassian.net/browse/MM-31061

* fix tests
2021-01-06 21:23:00 +05:30
Ibrahim Serdar Acikgoz
f9c0c1072f [MM-31360] downgrade error logs which doesn't break the flow (#16612)
* downgrade error logs which doesn't break the flow

* reflect revivew comments
2021-01-04 17:02:34 +03:00
Agniva De Sarker
c1dd23a3c8 MM-31063: Change constants to use CamelCase (#16608)
* MM-31063: Change constants to use CamelCase

* store package

* change allcaps to camel case (#16615)

* New tools.mod

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2021-01-04 11:32:29 +05:30
Ibrahim Serdar Acikgoz
40e16ba07f [MM-31359] remove duplicated error logs (#16583)
* remove duplicated error logs

* reflect review comments

* add context

* add error details
2020-12-29 09:48:36 +03:00
Agniva De Sarker
c54b262351 MM-31356: Add a minimum required version check for Postgres (#16597)
* MM-31356: Add a minimum required version check for Postgres

To keep conformance with our failing fast and obvious philosophy,
we add a check to prevent Mattermost server from starting
if the postgres version is below 10.0.

This gives customers a chance to upgrade their database before upgrading
their Mattermost version, than to run into weird compatibility issues
after they have finished the upgrade.

https://mattermost.atlassian.net/browse/MM-31356

```release-note
NONE
```

* fix lint errors

* Use a function to pretty-print version string

* rectify comment
2020-12-23 22:06:13 +05:30
Agniva De Sarker
1a131b54af MM-31064: Simplify indentation (#16565)
* MM-31064: Simplify indentation

Reduce indentation where possible.

```release-note
NONE
```

Command ran to verify:
golangci-lint run --disable-all --enable golint --max-issues-per-linter=10000 --max-same-issues=100000 ./... | grep "block ends with a return state"

https://mattermost.atlassian.net/browse/MM-31064

* incorporate review comments

* enable golint for outdent rule

* fix remaining issues

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-21 18:50:47 +03:00
Jesús Espino
7419898449 Remove usages of AppError on filesstore service (#15841)
* Remove usages of AppError on filesstore service

* Fixing a golint error

* Fixing shadowed variable

* Adding err.Error() to the NewAppError calls

* Fixing tests

* Adding missed translations

* Fix error handling and updating the translation that affects it

* Fixing two typos
2020-12-20 12:53:07 +01:00
Florent Peterschmitt
349b83f23a implement and use striped LRU cache to lower mutex contention (#15764)
* Implement Striped LRU cache

* ci

* fix

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-09 19:25:14 +05:30
Scott Bishel
f548ecbee1 MM-27688-OpenId Connect (#16222)
* implement openid connect

* update error strings

* handle OpenIdSetting.Secret as FAKE SETTING

* add openid to telemetry

* update config defaults, add telemetry

* fix bug with Office365

* Retrieve Office365 AuthData from IdToken

* fix linter

* add feature flag, reset defaults for config

* fix build error

* fix unit tests

* add authentication permission to Feature
Flags

* turn off feature flag

* set default button color

* set default button color only on openid

* fix for merging FeatureFlags in config

* remove feature flag

* revert config changes

* remove debug statements

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-08 19:58:37 -07:00
Jesse Hallam
cd9185fa23 MM-30801: pre-package channel export plugin (#16406)
* MM-30801: pre-package channel export plugin

The [channel export plugin](https://github.com/mattermost/mattermost-plugin-channel-export) complements [incident management](https://github.com/mattermost/mattermost-plugin-incident-management).

* only enable IM/CE by default on enterprise ready builds
2020-12-04 15:09:05 -04:00
Claudio Costa
df906cad9d [MM-28422] Enable processing of import files through API (#16062)
* Implement unzip function

* Implement FileSize method

* Implement path rewriting for bulk import

* Small improvements

* Add ImportSettings to config

* Implement ListImports API endpoint

* Enable uploading import files

* Implement import process job

* Add missing license headers

* Address reviews

* Make path sanitization a bit smarter

* Clean path before calculating Dir

* [MM-30008] Add mmctl support for file imports (#16301)

* Add mmctl support for import files

* Improve test

* Remove unnecessary handlers

* Use th.TestForSystemAdminAndLocal

* Make nouser id a constant
2020-12-03 11:38:00 +01:00
Sudheer
6cebcead22 MM-27989 Remove experimental setting for data prefetch (#16306)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-02 11:14:30 -05:00
Jesús Espino
a74fe05695 Removing supplier concept from the sql store (#16355)
* Removing supplier concept from the sql store

* Removing other metions to supplier

* Fixing gofmt

* Fixing gofmt

* Renaming NewSqlStore to New

* Fixing tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-02 12:06:23 +01:00
John Tzikas
3fdc6cb531 Fix misspellings and enable misspell on ci (#16285)
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2020-12-01 16:27:05 +01:00
Agniva De Sarker
6a56af2a14 MM-30863: Fix race in LRU (#16382)
* MM-30863: Fix race in LRU

After shortening the critical section, we missed out the fact
that the byte slice is still accessible after the element is returned.
So the lock needs to be active until the byte slice is fully read and
unmarshaled

https://mattermost.atlassian.net/browse/MM-30863

```release-note
NONE
```

* incorporate suggestions

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-26 20:24:23 +05:30
Akshay Chhajed
26676953a4 MM-30140 LRU critical section optimization (#16184)
* MM-30140 LRU critical section optimization

* Remove empty line

* Renamed lru function
2020-11-20 11:29:27 +01:00
Eli Yukelzon
cf4df5fcd2 MM-30048 added thread related socket messages (#16234)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-20 11:00:52 +02:00
Jesse Hallam
2ac83ffac7 MM-30800: prepackage incident management 1.1 (#16323)
* prepackage incident management v1.1 (#16195)

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

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>

* update telemetry whitelist

* newer version!

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-19 16:13:53 -04:00
Ben Schumacher
4063f407a1 Use different user-agent for twitter links (#16210) 2020-11-17 14:48:51 +01:00
Miguel de la Cruz
6c857a4525 [MM-30436] Add support for configuration custom defaults (#16265)
* [MM-30436] Add support for configuration custom defaults

* Addressing review comments

* Addressing PR comments

* Soft fail if the configuration defaults cannot be read

* Directly print error in log message

* Fix linter

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-16 15:25:48 +01:00
Agniva De Sarker
0ca8cb36b4 MM-26425: Make URL parsing for image proxy more robust (#16197)
* MM-26425: Make URL parsing for image proxy more robust

- We don't bypass protocol relative URLs.
- We don't bypass hostnames with a similar prefix.

https: //mattermost.atlassian.net/browse/MM-26425

```release-note
NONE
```

* fix tests and incorporate review comments

* Handle opaque URLs

* Fix path tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-10 13:06:59 +05:30
Harrison Healey
dc030bebbf MM-30090 Add telemetry for ManagedResourcePaths (#16221) 2020-11-06 08:32:37 -05:00
Agniva De Sarker
66731e2740 MM-29980: Optimize profilesInChannels cache to fast path (#16116)
* MM-29980: Optimize profilesInChannels cache to fast path

We add one more message type to the fast path- profiles in channels. There
are 2 primary reasons for this:

- This is not really a new model type, but just a map of users. And users already use
the fast path. So we can get some more gains without really investing much more code.
- A more important reason is that with the upcoming striped mutex changes, we will get
a higher throughput at the cost of a bit more CPU utilization. The reason being that
since less amount of time will be spent in lock-contention, the CPU is free to do more
stuff. So this change is to counter that increase.

As usual, this gives much better performance than the original decoder.

Micro-benchmark results
```
name               old time/op    new time/op    delta
LRU/UserMap=new-8    16.6µs ± 3%     3.9µs ± 4%  -76.15%  (p=0.000 n=10+10)

name               old alloc/op   new alloc/op   delta
LRU/UserMap=new-8    4.78kB ± 0%    2.74kB ± 0%  -42.65%  (p=0.000 n=10+10)

name               old allocs/op  new allocs/op  delta
LRU/UserMap=new-8      38.0 ± 0%      30.0 ± 0%  -21.05%  (p=0.000 n=10+10)
```

https://mattermost.atlassian.net/browse/MM-29980

Here are some results from a load test. The comparison is done with a 2 node cluster; one running master
and one running with this patch so that it's easier to compare. The total users are 2000.

<See PR>

```release-note
NONE
```

* Fix gofmt

* Trigger CI
2020-11-04 10:08:10 +05:30
Christopher Speller
1aadd36644 MM-28859 Add feature flag managment system using split.io and remove viper. (#15954)
* Add feature flag managment system using split.io and remove viper.

* Fixing tests.

* Attempt to fix postgres tests.

* Fix watch filepath for advanced logging.

* Review fixes.

* Some error wrapping.

* Remove unessisary store interface.

* Desanitize SplitKey

* Simplify.

* Review feedback.

* Rename split mlog adatper to split logger.

* fsInner

* Style.

* Restore oldcfg test.

* Downgrading non-actionable feature flag errors to warnings.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-29 15:54:39 -07:00
Jesús Espino
8d5be2d657 Document extractor service (#15665)
* Document extractor service

* Fixing vendor modules

* Addressing PR Review comments

* Some small simplifications

* Fixing a linter complain

* simplifying a bit the code using package variables

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-27 15:58:38 +01:00