Граф коммитов

968 Коммитов

Автор SHA1 Сообщение Дата
Eli Yukelzon
b0bddeb5e6 MM-29988 - Update exising Post APIs with collapsed threads (#16503) 2021-01-14 13:46:27 +02:00
Eli Yukelzon
502786580b hotfix-threads-migrate (#16687) 2021-01-13 17:32:25 +02:00
Agniva De Sarker
d356ef349b MM-31876: Fix racy test GetReplica (#16656)
Automatic Merge
2021-01-12 15:15:17 +01:00
Jesse Hallam
9667c96f97 MM-30892: Avoid unnecessary table scan in AnalyticsPostCount. (#16643)
* MM-30892: Avoid unnecessary table scan in AnalyticsPostCount.

[AnalyticsPostCount](d9e8402dc2/store/sqlstore/post_store.go (L1513-L1541)) unconditionally joins on the `Channels` table even when not filtering to a team.

This is a proposal to stop doing this, reducing this to a simple index query when no team is specified. Note that this is technically a subtle semantic difference, since orphaned posts (from deleted or invalid channel ids) are currently excluded. But I submit the benefits outweigh the technical differences here.

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

* Update store/sqlstore/post_store.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* Update store/sqlstore/post_store.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

Co-authored-by: Claudio Costa <cstcld91@gmail.com>
2021-01-11 14:01:47 -04: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
Ibrahim Serdar Acikgoz
037ce8bc31 downgrade some error logs for store package (#16632) 2021-01-06 16:37:36 +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
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
Mattermost Build
83afd756b6 Bump version (#16592)
* Bump version

* Uncomment shouldPerformUpgrade

Co-authored-by: Mmbot <mmbot@mattermost>
Co-authored-by: Elisabeth Kulzer <elikul@elikul.de>
2020-12-23 16:33:07 +01:00
Ibrahim Serdar Acikgoz
8036ba86e7 [MM-31398] upgrade error level to critical in case of panic or os.Exit (#16584)
* upgrade error level to critical in case of panic or os.Exit

* reflect revivew comments

* fix error capitalization
2020-12-23 13:11:35 +03:00
Agniva De Sarker
6487d0ca91 MM-31062: Rewrite empty string checks to be more idiomatic (#16587)
https://mattermost.atlassian.net/browse/MM-31062

```release-note
NONE
```
2020-12-22 19:20:59 +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
Claudio Costa
10be00f005 Update db schema version for MM-31401 and MM-27312 (#16580) 2020-12-18 22:25:52 +01:00
Doug Lauder
6a3bc50f13 MM-31401 Add Shared flag to Channels table (#16568)
* add Shared flag to Channels table
2020-12-16 14:02:16 -05:00
Diogo Nicolau
8e2986e5ed MM-27312 Allow uploading 10 files per post (#16235)
* Allow uploading 10 files per post

* Increase Post.Fileids column size to fit 10 files

* Add Post.Fileids column changes to DB v531

* Fix current_schema_version

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* Update store/sqlstore/upgrade.go

Co-authored-by: Claudio Costa <cstcld91@gmail.com>

* Fix schema version

Co-authored-by: Diogo Lima Nicolau <diogo.lima.nicolau@cern.ch>
Co-authored-by: Harrison Healey <harrisonmhealey@gmail.com>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-14 09:30:02 +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
Carlos Tadeu Panato Junior
f27c55a884 db: upgrade db to 5.30 (#16453)
* db: upgrade db to 5.30
2020-12-07 10:20:22 +01:00
Eli Yukelzon
86e228b6c6 MM-30558 - Add unreadReplies and unreadMentions to thread membership (#16304) 2020-12-06 10:02:53 +02: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
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
Eli Yukelzon
c2036f614e MM-30970 Add Basic unreadMentions support for collapsed threads (#16407)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-01 17:20:23 +02:00
Eli Yukelzon
1bd7dc41bd MM-30865 Invalid Participants handling on post delete in thread (#16353)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-12-01 16:50:39 +02:00
Eli Yukelzon
1e15ad0686 MM-30917 Fix invalid reply count calculation during thread migration (#16395) 2020-11-26 10:41:29 +02:00
Jesús Espino
d274cf8afa Removing unnecesary SqlStore interface (#16057) 2020-11-20 10:51:58 +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
John Tzikas
5797d6ace3 Add logic to skip duplicate table errors when initializing db (#16270)
* Add logic to skip duplicate table errors when initializing db

* Update store/sqlstore/supplier.go

Co-authored-by: Gabe Jackson <gabe@coffeepowered.co>

* Handle mysql and pg table already exist errors

* Apply PR suggestions
* Fix typo on IsDuplicate
* Update mysql error link to point to the official one

Co-authored-by: Gabe Jackson <gabe@coffeepowered.co>
2020-11-17 17:01:20 -05:00
Rodrigo Villablanca
95221d9ace GroupStore migration (#15795)
* Migration completed

* Fix tests

* Fix tests

* Fix tests

* Suggestions

* Trigger CI

* Suggestions

* Merge with master

* Migration completed

* Fix typo

* fix err check

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2020-11-17 09:02:36 +05:30
Harrison Healey
2ebc8ec90f MM-20897 Add category muting (#16225)
* Make UpdateSidebarCategories return the original categories

* MM-20897 Add category muting

* Prevent muting the DMs category

* Fix muted state not being stored in the database

* Address feedback

* Address some feedback

* Fix unit tests

* MM-20897 Mute/unmute channels in the database in bulk

* Satisfy golangci-lint
2020-11-16 15:19:01 -05:00
Farhan Munshi
c9a4a475d3 [MM-28717] Refactor applyMultiRoleFilters to use sq builder (#15500)
* Refactor apply multi role filters and add role filters to get all profiles

* Add some tests

* Fix tests

* Fix lint

* Trigger CI

* Rename param to make more sense

* Tie get filtered user stats to usermanagement read users

* Dont filter out other system roles when searching for team members or team admins only filter out system admins

* add new permissions

* add migration

* fix test

* remove system roles as default permissions

* implement changes discussed with dennis

* add read only and fix i18n

* use model consts instead of strings

* turn the permissions into pseudo constants

* Update read only default permissions

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Hossein Ahmadian-Yazdi <hyazdi1997@gmail.com>
2020-11-13 10:57:57 -05:00
Agniva De Sarker
39b5b601f8 MM-30026: Use DB master when getting team members from a session (#16170)
* MM-30026: Use DB master when getting team members from a session

A race condition happens when the read-replica isn't updated yet
by the time a session expiry message reaches another node in the cluster.

Here is the sequence of events that can cause it:
- Server1 gets any request which has to wipe session cache.

- The SQL query is written to DB master, and a cluster message is propagated
to clear the session cache for that user.

- Now before the read-replica is updated with the master’s update,
the cluster message reaches Server2. The session cache is wiped out for that user.

- _Any random_ request for that user hits Server2. Does NOT have to be
the update team name request. The request does not find the value
in session cache, because it’s wiped off, and picks it up from the DB.
Surprise surprise, it gets the stale value. Sticks it into the cache.

By now, the read-replica is updated. But guess what, we aren’t going to
ask the DB anymore, because we have it in the cache. And the cache has the stale value.

We use a temporary approach for now by introducing a context in the DB calls so that
the useMaster information can be easily passed. And this has the added advantage of
reusing the same context for future DB calls in case it happens. And we can also
add more context keys as needed.

A proper approach needs some architectural changes. See the issue for more details.

```release-note
Fixed a bug where a session will hold on to a cached value
in an HA setup with read-replicas configured.
```

* incorporate review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-11-10 10:43:45 +05:30
Eli Yukelzon
45e340b5be MM-29987 Implement new collapsed threads API (#16091) 2020-11-08 10:36:46 +02:00
Jesús Espino
b08b51d52d MM-30300: Add coalesce to get null content as empty string on FileInfo store (#16216)
* MM-30300: Add coalesce to get null content as empty string on FileInfo store

* Making explicit the fields get from the FileInfo table

* Addressing PR review comments
2020-11-06 12:49:15 +01:00
Jesús Espino
24621a22ed Add the content field to FileInfo (#15749)
* Add the content field to FileInfo

* Fixing the upgrade code

* Trying to fix the text-scheme

* Fixing test-schema

* Fixing test-schema

* Moving the migration to the next version
2020-11-02 15:43:48 +01:00
Eli Yukelzon
fe352ab57f MM-29703 Mark threads as read when channels are marked (#15994)
Co-authored-by: Jesús Espino <jespinog@gmail.com>
2020-10-30 17:00:21 +02:00
Carlos Tadeu Panato Junior
1729239385 upgrade DB to 5.29 (#16081) 2020-10-30 13:37:26 +01:00
Harrison Healey
8bb772638c MM-29067 Add deterministic IDs for default sidebar categories (#16030)
Automatic Merge
2020-10-29 10:24:01 -04:00
Alex Johnson
9cb704d537 Documents exported methods within SqlTeamStore methods (#15996)
Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>
2020-10-27 16:19:11 +01:00
Claudio Costa
9484366784 Fix nil dereference panic in SearchArchivedInTeam (#16064)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-26 15:19:14 +01:00
Rodrigo Villablanca
96f1739f8f UserStore migration (#15563)
* Migration completed

* Fix tests

* Fix tests

* Fix tests

* Suggestions

* Trigger CI

* Suggestions

* Merge with master

* Trigger CI

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2020-10-26 15:11:27 +05:30
Agniva De Sarker
d51d843fcd MM-22950: Remove supplier test (#16072)
This test is too flaky to be written as a test. Let's just remove it.

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

```release-note
NONE
```
2020-10-26 13:21:24 +05:30
Martin Kraft
d519ab580f MM-28815: Message export query optimization. (#15757)
* MM-28815: Optimizes message export query.

* MM-28815: Removes DeleteAt WHERE condition.

* MM-28815: Adds Id to the ORDER BY clause.

* MM-28815: Concatenates the string to remove the confusing '%%' in the query.

* MM-28115: Remvoes secondary sorting.

* MM-28815: Keeps the alias in the order by.

* MM-28815: Removing forced index.

* MM-28815: Formatting.
2020-10-16 10:21:36 -04:00
Eli Yukelzon
8844141df3 MM-28249 Auto follow threads (#15878)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-15 18:01:16 +03:00
Aayush Pal
fa9279a675 Added GoDoc for functions mentioned in Task 7 (#14004) team_store.go (#15762) 2020-10-14 12:53:48 +02:00
Jeremy MacArthur
71997eaac7 Adding godocs for the 4 functions listed: (#15806)
* Adding godocs for the 4 functions listed:

SqlTeamStore.UpdateLastTeamIconUpdate
SqlTeamStore.UpdateMembersRole
SqlTeamStore.UserBelongsToTeams
SqlTeamStore.GetTeamMembersForExport

* Apply suggestions from code review

Applying suggestions from the community to help clean up the grammar in the docs.

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>

* Apply suggestions from code review part 2

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-10-08 13:42:55 +02:00
Ibrahim Serdar Acikgoz
c67c46a684 [MM-28810] channel_store_categories: check if object is nil after the query (#15635)
* check if onj is nil

* channel_store_categories: add tests

* reflect review comments

* remove store declaraation
2020-10-07 09:33:18 +03:00
Eli Yukelzon
375931a4b9 Post image schema fix (#15763) 2020-10-04 16:14:06 +03:00
Rodrigo Villablanca
bb4df5a68e ChannelStore migration Part 3 (#15504)
* Migration finished

* Change error var name

* Fix imports

* Fix tests

* Merge with master

* Doing some suggestions

* More suggestions

* Fix i18n

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2020-10-04 10:12:29 +05:30
Joshua Bezaleel Abednego
5353bceaea MM-24948: Command webhook store squirrel refactor (#14659)
Automatic Merge
2020-10-03 22:57:28 -04:00