Commit Graph

1136 Commits

Author SHA1 Message Date
Claudio Costa
b724ba6243 Execute update posts query first (#18524) 2021-10-04 15:04:13 +02:00
Claudio Costa
177680f08c [MM-36472] Fix inconsistencies in Roles columns (#18390)
* Fix inconsistencies in Roles columns

* Add new migrations
2021-10-01 15:31:29 +02:00
Daniel Espino García
305e4793c3 Only consider flagged posts that are on channels you are member of (#18380)
* Only consider flagged posts that are on channels you are member of

* Fix and add tests
2021-09-29 17:16:25 -04:00
Daniel Espino García
02a9ef3f82 [MM-38216] Add API endpoint and adapt search to allow multi-team search (#18371)
* Add API endpoint and adapt search to allow multi-team search

* Refactor handler, refactor sql query to use squirrel, rename app and store functions and add tests

* Fix lint

* Fix search engines and remove unneeded comments

* Fix test

* Remove user from channel after test
2021-09-23 14:43:09 +02:00
Agniva De Sarker
688ee34054 MM-38712: Flush logs while exiting from store upgrade (#18438)
Our store upgrade methods used mlog.Critical and then slept
for a second and triggered os.Exit.

First of all, with the new mlog refactor Critical wasn't a standard
log level so it was never to be logged.

And secondly, this completely missed the fact that there already
existed an API method Fatal which did exactly this.

We mark the Critical API as deprecated, and use Fatal for all
occurences.

The choice should be between either to use Error or Fatal.

While here, we also remove the non-standard exit codes which
just confused things further while debugging.

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

```release-note
NONE
```
2021-09-22 20:12:57 +05:30
Doug Lauder
a1b853d1dc MM-38611 getSharedChannels: only return channels user is member of (#18417)
* getSharedChannels: only return channels user is member of
2021-09-20 15:00:47 -04:00
dave
fd597d325a Migrate from gorp to sqlx in store/sqlstore/audit_store.go (#18409) 2021-09-20 18:55:36 +05:30
Kyriakos Z
237e4fd531 MM-37896: thread recency when updating a post (#18363)
When a post is edited we should not update the thread recency
(LastReplyAt).
2021-09-17 09:01:41 -04:00
Agniva De Sarker
0953e3f0cf Migrating Emoji store to use sqlx (#18301)
* Migrating Emoji store to use sqlx

https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=646cee9a-219c-49f3-8e0b-6ec2cff4deba

```release-note
NONE
```

* Incorporate review suggestions

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-09-14 13:46:42 +05:30
Agniva De Sarker
17fe158f5e Migrating OAuthStore to sqlx (#18302)
* Migrating OAuthStore to sqlx

https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=71efa7c4-53be-4732-87cc-d53726d2cd53

```release-note
NONE
```

* Fixing some broken tests

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-09-13 19:23:58 +05:30
Agniva De Sarker
21a53320d3 Migrating bot store to use sqlx (#18300)
https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=5da060fd-8fbc-449d-8219-c73a9dd0bd7c

```release-note
NONE
```
2021-09-02 17:08:11 +02:00
Claudio Costa
92837fa1ee [MM-22051] Remove To/From JSON (#18070)
* Posts

* Add missing translation

* Fix internal store marshaling

* [MM-22051] Remove To/From JSON (Channels) (#18116)

* Channels

* Channel members

* ChannelSearch

* Channel categories, list, sidebar, stats, view

* Fix conversions

* [MM-22051] Remove To/From JSON (Users) (#18121)

* User related structs

* Fix return

* Team related structures (#18127)

* [MM-22051] Remove To/From JSON (Status, Bot, Reaction, Thread, FileInfo) (#18130)

* Status

* Bot

* Reaction

* Thread

* FileInfo

* Some fixes

* Translations update from Weblate (#18143)

* Translated using Weblate (German)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/

* Translated using Weblate (Turkish)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2309 of 2309 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

Update translation files

Updated by "Cleanup translation files" hook in Weblate.

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/

* Translated using Weblate (German)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/de/

* Translated using Weblate (Turkish)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/tr/

* Translated using Weblate (Hungarian)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/hu/

* Translated using Weblate (English (Australia))

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/en_AU/

* Translated using Weblate (Bulgarian)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/bg/

* Translated using Weblate (Japanese)

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/ja/

* Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (2301 of 2301 strings)

Translation: mattermost-languages-shipped/mattermost-server
Translate-URL: https://translate.mattermost.com/projects/mattermost/mattermost-server_master/zh_Hans/

Co-authored-by: JtheBAB <srast@bioc.uzh.ch>
Co-authored-by: Kaya Zeren <kayazeren@gmail.com>
Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu>
Co-authored-by: Matthew Williams <Matthew.Williams@outlook.com.au>
Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com>
Co-authored-by: kaakaa <stooner.hoe@gmail.com>
Co-authored-by: aeomin <lin@aeomin.net>

Co-authored-by: Weblate (bot) <hosted@weblate.org>
Co-authored-by: JtheBAB <srast@bioc.uzh.ch>
Co-authored-by: Kaya Zeren <kayazeren@gmail.com>
Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu>
Co-authored-by: Matthew Williams <Matthew.Williams@outlook.com.au>
Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com>
Co-authored-by: kaakaa <stooner.hoe@gmail.com>
Co-authored-by: aeomin <lin@aeomin.net>

* [MM-22051] Remove To/From JSON methods from model (#18138)

* Scheme

* Role

* Session

* Config

* Status

* Fix logic

* Emoji

* GuestsInvite

* Group

* Command

* ClusterInfo

* License

* Job

* System

* Plugin

* Command2

* IncomingWebhook

* OutgoingWebhook

* Fix tests

* Update traslation

* Some fixes

* Add missing return

* Simplify

* Make Config.ToJSONFiltered() return []byte

* Make Busy.ToJSON() return []byte

* Include error in log

* Split logic

* [MM-22051] Remove To/From JSON (final) (#18150)

* SwitchRequest

* PluginEventData

* Permalink

* PushNotification

* SuggestCommand

* PluginsResponse

* WebSocketMessage

* RemoteCluster

* SharedChannel

* PluginStatuses

* InitialLoad

* ClusterDiscovery

* ClusterStats

* MfaSecret

* GroupSyncable

* SAML

* WebSocketRequest

* TypingRequest

* SecurityBulletin

* OAuthApp

* IntegrationAction

* DataRetention

* Preference

* FileInfoList

* Compliance

* Preferences

* FileInfoSearchResults

* TermsOfService

* InstallMarketplacePluginRequest

* GitLabUser

* UploadSessions

* Remove unused helpers

* Fix tests

* [MM-23280] Fix linting for ToJSON/FromJSON (#18153)

* SwitchRequest

* PluginEventData

* Permalink

* PushNotification

* SuggestCommand

* PluginsResponse

* WebSocketMessage

* RemoteCluster

* SharedChannel

* PluginStatuses

* InitialLoad

* ClusterDiscovery

* ClusterStats

* MfaSecret

* GroupSyncable

* SAML

* WebSocketRequest

* TypingRequest

* SecurityBulletin

* OAuthApp

* IntegrationAction

* DataRetention

* Preference

* FileInfoList

* Compliance

* Preferences

* FileInfoSearchResults

* TermsOfService

* InstallMarketplacePluginRequest

* GitLabUser

* UploadSessions

* Remove unused helpers

* Fix tests

* Fix linting for ToJSON/FromJSON

* Fix conversions

Co-authored-by: Weblate (bot) <hosted@weblate.org>
Co-authored-by: JtheBAB <srast@bioc.uzh.ch>
Co-authored-by: Kaya Zeren <kayazeren@gmail.com>
Co-authored-by: Tóth Csaba // Online ERP Hungary Kft <csaba.toth@online-erp.hu>
Co-authored-by: Matthew Williams <Matthew.Williams@outlook.com.au>
Co-authored-by: Nikolai Zahariev <nikolaiz@yahoo.com>
Co-authored-by: kaakaa <stooner.hoe@gmail.com>
Co-authored-by: aeomin <lin@aeomin.net>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-09-01 14:43:12 +02:00
Kyriakos Z
bb05e7c412 MM-35017: order and inclusion of participants (#18235)
* MM-35017: order and inclusion of participants

From now on root poster is not considered a thread participant,
only repliers are participants.

Ordering: A second reply to the thread from the same user should place
the user last at the participants list.

* Fixes shadow

* Fixes tests

* Order By CreateAt for participants of old threads

* Removes unnecessary check on root id

* Removes GetParticipantProfilesByIds it's not needed

At first GetParticipantProfilesByIds was created because GetProfileByIds
gets users by order of username.
This was not needed, we can order by user ids in Go.

This commit removes GetParticipantProfilesByIds and replaces it by
GetProfileByIds as it was done before.

* Fixes participants order for pre CRT threads

Older threads (before CRT) are being converted to CRT threads upon
reply.
This commit considers the order of participants to be inserted to
the new thread.

* Adds tests for thread participants

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-30 17:13:55 -04:00
Agniva De Sarker
5b8720d539 MM-38132: Improve Auto Responder logic (#18264)
We properly truncate the date part from the createAt time.

The SQL query is improved now to directly return the bool.

Fixed the test to properly test the feature.

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

```release-note
NONE
```
2021-08-30 23:06:45 +05:30
Agniva De Sarker
1f3e2d0c4f Added a sqlXPassThrough layer (#18238)
* Added a sqlXPassThrough layer

This layer embeds the original sqlx object and wraps some
key methods to avoid some boilerplate.

- Add timeout to all methods from the timeout in settings.
- Added trace functionality.
- Added auto-rebind capabilities so that each store method
doesn't need to call rebind every time.
- Added auto-lowering of query string to support NamedExec
for both MySQL and Postgres

All methods are not wrapped as all are likely not to be called
from our code. As and when they are called, support will be added.

```release-note
NONE
```

* fix lint issues

```release-note
NONE
```

* address review comments

```release-note
NONE
```

* incorporate suggestions

```release-note
NONE
```
2021-08-30 10:20:28 +05:30
Carlos Tadeu Panato Junior
6031b163d8 Update MM version/sqlstore to version 6.0.0 (#18247)
Automatic Merge
2021-08-24 16:15:03 +02:00
Agniva De Sarker
7bbcf86531 Update channel member notify props to use native JSON (#18114)
* Update channel member notify props to use native JSON

Created a new store method that patches the notify props field.

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=91d08676-4a0e-4f02-8dce-d24d4fc56449

```release-note
NONE
```

* cleanup

```release-note
NONE
```

* forgot to commit

```release-note
NONE
```

* Fix edge case

```release-note
NONE
```

* address review comments

```release-note
NONE
```

* fix incorrect order

```release-note
NONE
```

* Address review comments

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-23 10:04:30 +05:30
Claudio Costa
c4c1fda128 [MM-36387] Address db performance audit items (#18078) 2021-08-21 08:05:52 +03:00
Agniva De Sarker
b553b50e15 Prepare support for sqlx (#18133)
* Prepare support for sqlx

Just setting up some basic skeleton to start
replacing gorp queries with sqlx.

There is still an issue with efficiently writing
cross-platform named queries, because :FieldName
needs to be :fieldname for Postgres.

The positional params can be rebound depending on
driver name. But named queries can't from my
investigation. Will look into this.

```release-note
NONE
```

* Refactor mapper

```release-note
NONE
```

* Forgot to init slice

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-20 10:53:34 +02:00
Claudio Costa
74518ea165 Combine alterations on Posts table (#18210)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-20 09:56:17 +02:00
Kyriakos Z
a0c5d8feab MM-36234,MM-37030,MM-37031: CRT, desktop thread notifications (#18088)
* CRT: desktop thread notifications

* Fixes go lint

* Adds default for desktop CRT notifications

* Adds email and push notifications for CRT threads

Adds user ids of thread followers with CRT to crtMentions so they will get
notified appropriately.

* Minor change

* Refactor a bit

CRTMentions.addMention had a bug on the return and de-duplication.
This commit fixes duplicate notifications by looking up if the user is to be
notified on CRT on both email and push notifications.

* Minor refactor

* Changes according to review comments

- Fixes adding to followers a user that had explicitly unfollowed a
  thread.
- Simplified send email according to email_threads option
- Send mentions and followers in separate arrays via the websocket
- Fixes push notifications message for push_threads

* Adds a comment on a buggy use case

* Updates comment to correct ticket link

* Fixes when user notifications is set to all

There was a bug where if user had set notifications to all
then they would receive desktop notifications even for non following threads.

A similar bug existed in push notifications, where if a user has set it
to all the threads setting would still be considered.

This commit fixes that by adding users to notificationsForCRT
StringArray when they have the non thread setting to 'all'.

* Fixes notifications to users unfollowing threads

Users which had previously explicitly unfollowed a thread
should not receive notifications about those threads.

* Update store mocks

* Fixes push notifications for CRT

Push notification about replies for CRT users should have a title of
"Reply to Thread".

CRT users with global user setting to 'UserNotifyAll' should not get
notifications for unfollowed threads.

This commit fixes those issues.

* Fixes i18n error

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-19 17:28:46 +03:00
Claudio Costa
536895a9ba Bump max allowed file uploads per post (#17948) 2021-08-18 15:50:17 +02:00
Doug Lauder
a4507327a7 MM-36764 mlog refactor (#18118)
Refactor mlog
- simplify mlog by removing redundant code
- remove Zap dependency
- update unit test helpers
- update logging config
- update auditing
2021-08-17 16:08:04 -04:00
Claudio Costa
04b27ce93c [MM-28985] Remove pointers to slice (part 1) (#18034)
* Remove pointers to slice (part 1)

* Remove use of pointers to slice from model package (#18045)

* Fix after merge
2021-08-17 11:18:33 +02:00
Agniva De Sarker
132f114793 Modified updateUserNotifyProps to directly update the field (#18097)
* Modified updateUserNotifyProps to directly update the field

The method was only being used during import and it unnecessarily
made multiple queries to the DB.

Changed to a separate query that just updated the props field.

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=e4f9a891-85d6-4886-8590-1e327f7f8b8f

```release-note
NONE
```

* invalidating cache

```release-note
NONE
```
2021-08-17 10:51:41 +02:00
Claudio Costa
d181ae9262 [MM-29217] Remove Posts.ParentId (#17923) 2021-08-17 11:25:22 +03:00
Agniva De Sarker
dd67fea99b Use DB native JSON operations for Delete post (#18122)
* Use DB native JSON operations for Delete post

https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=cb23f737-89c3-4e19-861e-2466c0a16205

```release-note
NONE
```

* move to adapters

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-08-16 20:35:19 +05:30
Claudio Costa
308a88efb1 [MM-37898] Exclude bots from initial user store emptiness check (#18139)
* Exclude bots from initial user store emptiness check

* Add test
2021-08-14 07:40:16 +02:00
Agniva De Sarker
d1b164ab1f Improve session cleanup (#18123)
- We move logging statements to the upper layer.
Store functions are low-level methods and should return error
upwards rather than logging.
- Used IN instead of any (array ()) which is equivalent.
- Made the delay to be of type time.Duration and un-exported it.
- Unexported the batch size constant.

```release-note
NONE
```
2021-08-13 20:15:24 +05:30
Agniva De Sarker
2711262729 Update Session Props to use one query (#18120)
https://community-daily.mattermost.com/plugins/focalboard/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=6f15ea48-995c-4975-8b28-bd58f7d6a34a

```release-note
NONE
```
2021-08-13 20:13:27 +05:30
Agniva De Sarker
e1b0644b0d Using native JSON operations to add thread participants (#18093)
Automatic Merge
2021-08-12 16:45:03 +02:00
Claudio Costa
bd65e8daf9 Replace db count query in user signup process (#18072) 2021-08-12 11:23:21 +02:00
dave
16c2925ba2 Fix staticcheck errors from _test.go files (#18033)
Automatic Merge
2021-08-10 07:15:03 +02:00
Agniva De Sarker
249a0b9870 MM-36990: Use upsert for system key update (#18037)
* MM-36990: Use upsert for system key update

We make the app migration idempotent by using DB native upsert.

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

```release-note
NONE
```

* Fix SaveOrUpdateWithWarnMetricHandling too

```release-note
NONE
```

* Update store/sqlstore/system_store.go

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

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Claudio Costa <cstcld91@gmail.com>
2021-08-03 14:23:47 +05:30
Claudio Costa
404b7eeade [MM-37202] Use native upsert query in StatusStore.SaveOrUpdate() (#18011)
Automatic Merge
2021-08-03 10:05:02 +02:00
Agniva De Sarker
f2119d60fa Print a helpful message for JSON column update failures. (#18041)
Automatic Merge
2021-08-02 21:05:03 +02:00
Ashish Bhate
296076bf2d [MM-36544][MM-37439] Don't re-follow on reply to unfollowed thread (#18020)
Summary
If a user has unfollowed a thread, another user's reply in the thread should not cause the first user to re-follow the thread. The first user will be re-followed if they are mentioned in the thread.
Simplify and make flexible the logic surrounding following and remove some duplicate code.

Ticket Link
https://mattermost.atlassian.net/browse/MM-36544
https://mattermost.atlassian.net/browse/MM-37439
2021-07-30 18:47:41 +05:30
Elisabeth Kulzer
fcea39ad36 DB upgrade 5.38 (#18027)
Automatic Merge
2021-07-29 16:05:03 +02:00
Claudio Costa
1ae1c38c9f [MM-36995] Start using db native JSON datatypes (#17930)
* Start using db native JSON datatypes

* Fix syntax to work on MySQL 5.7.12
2021-07-28 08:50:36 +02:00
Joram Wilander
a0cc420e2a MM-35392 Load thread unreads for other teams on app load (#17944)
* Add ability to include thread unreads in team unreads api response

* Do not include GMs/DMs in team unreads for threads

* Fix bad merge
2021-07-22 10:24:20 -04:00
Agniva De Sarker
c4b4e1bc38 MM-36271: Bump major version to 6.0 (#17973)
https://mattermost.atlassian.net/browse/MM-36271

```release-note
We bump the major version to 6.0
```
2021-07-22 12:21:47 +05:30
Agniva De Sarker
da7d71ccf7 MM-21357: Use typed constant for channel types (#17928)
* MM-21357: Use typed constant for channel types

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

```release-note
- Introduced a new type ChannelType for all channel types.
- Updated the Client4.UpdateChannelPrivacy method to ChannelType.
```

* Address review comments

```release-note
NONE
```

* telemetry fix

```release-note
NONE
```
2021-07-21 16:38:39 +02:00
Agniva De Sarker
4968657651 MM-37034: Bump the MySQL min version to 5.7 (#17919)
* MM-37034: Bump the MySQL min version to 5.7

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

```release-note
Minimum required MySQL version is now 5.7
```

* fix shadow warnings

```release-note
NONE
```

* Bumped to 5.7.12

```release-note
NONE
```

* update comment

```release-note
NONE
```

* refactor

```release-note
NONE
```

* fix lint error

```release-note
NONE
```

* fix2

```release-note
NONE
```

* add tests

```release-note
NONE
```

* simplify

```release-note
NONE
```
2021-07-21 16:38:39 +02:00
Ben Schumacher
97ccf0bdf6 [MM-16751] golint model (#17896) 2021-07-21 16:38:39 +02:00
source-punk
a59d3a9fa6 [MM-36711] nested sql query for reply_count in getSingle post method of post_sto… (#17845)
* nested sql query for reply_count in getSingle post method of post_store.go

* added tests for replyCount in GetSingle api

* updated the post object message field in GetSingle unit test to use model.NewRandomString
2021-07-16 10:30:23 -04:00
Ashish Bhate
f204c745cb [MM-35345]: fix unreads in threads and migration (#17938)
Summary
Fix unreads query for threads to check deleted option
Normalize unreads query to look for threads after given time
Fix migration to only run once, and increment timestamp by one so that threads are definitely marked as read.

Ticket Link
Fixes issues with https://mattermost.atlassian.net/browse/MM-35345
And possibly some issues with thread unreads.
2021-07-16 19:26:16 +05:30
Agniva De Sarker
61e42c8110 GroupStore: Use native upsert (#17902)
Now that version 10 is minimum, we can start to use
advanced postgres features.

https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=0445b560-91b9-469b-8f19-febf1881bcd6

```release-note
NONE
```
2021-07-15 19:40:45 +05:30
Ashish Bhate
e50cfca2ea [MM-35345][MM-35494] fixes for incorrect mentions and unreads for threads and channels (#17803)
Summary:
The CRT backend was first released in version 5.29.0. Since then, the behaviour of the CRT feature has been refined, several bugs have been fixed, and a few sql columns have been added. Before these various fixes went in, the threads and channel membership tables have accumulated incorrect mention and unreads data. This PR fixes some of this bad historical data.
Summary of fixes:

- Marks threads as read for users where the last reply time of the thread is earlier than the time the user viewed the channel. Marking a thread means setting the mention count to zero and setting the last viewed at time of the the thread as the last viewed at time of the channel. This is done through a "sql migration"
- Fix channel counts, i.e. the total message count, total root message count, mention count, and mention count in root messages for users who have viewed the channel after the last post in the channel. This is done as a "sql migration"


Ticket Link:
Parts of
https://mattermost.atlassian.net/browse/MM-35494
https://mattermost.atlassian.net/browse/MM-35345
2021-07-14 17:39:40 +05:30
Agniva De Sarker
f5610801e3 PreferenceStore: Use native upsert for Postgres (#17894)
* PreferenceStore: Use native upsert for Postgres

Now that version 10 is minimum, we can start to use
advanced postgres features.

https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=0445b560-91b9-469b-8f19-febf1881bcd6

```release-note
NONE
```

* fix lint issues

```release-note
NONE
```
2021-07-09 23:38:52 +05:30
Agniva De Sarker
ba9cbae0d5 PluginStore: Use native upsert for Postgres (#17882)
Now that version 10 is minimum, we can start to use
advanced postgres features.

https://focalboard-community.octo.mattermost.com/workspace/zyoahc9uapdn3xdptac6jb69ic?id=285b80a3-257d-41f6-8cf4-ed80ca9d92e5&v=495cdb4d-c13a-4992-8eb9-80cfee2819a4&c=0445b560-91b9-469b-8f19-febf1881bcd6

```release-note
NONE
```
2021-07-09 19:36:35 +05:30