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

1282 Коммитов

Автор SHA1 Сообщение Дата
Agniva De Sarker
3c83187c5b MM-43929: Ignore archived team memberships in GraphQL (#20130)
https://mattermost.atlassian.net/browse/MM-43929

```release-note
NONE
```
2022-05-04 19:43:02 +05:30
Jesse Hallam
72a5d99ae3 MM-43770: Rename to Threads.ThreadDeleteAt (#20074)
Old versions of the Mattermost server did not qualify queries scanning both `Posts` and `Threads`, and choke on the ambiguity in deciding between the new `DeleteAt` on `Threads` and the `DeleteAt` on `Posts` in existing queries.

While this problem is transient only while running multiple server versions, it effectively makes our backwards compatibility guarantee void, not to mention complicating cloud deployments.

Work around this by renaming `Threads.DeleteAt` to `Threads.ThreadDeleteAt`. The old migration is nulled out, but remains, since some test servers have already upgraded and manually fixing each affected instance would be problematic. Thew new migration takes care of removing the old column -- if it ever existed.

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

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-29 14:42:38 -03:00
Miguel de la Cruz
c076f9fdf9 Remove code duplication and move utility methods to the store utils (#20091)
* Remove code duplication and move utility methods to the store utils

* Fix typo
2022-04-29 12:15:38 +02:00
Mylon Suren
52ac449012 [MM-42739] Insights - Top Channels API Endpoint (#19953)
* [MM-42739] Initial setup for top channels for team

* [MM-42739] Add initial tests

* [MM-42739] Update tests

* [MM-42739] Add top channels for user

* [MM-42739] Fix query

* [MM-42739] Update query

* [MM-42739] Improve query performance

* [MM-42739] Remove rank

* [MM-42739] Fix tests to use new time range today

* [MM-42739] Add tests for top channels for user

* [MM-42739] Add test for pagination

* Remove top channels by time struct

* [MM-42739] Update test names

* [MM-42739] Remove rank from top reactions

* [MM-42739] Return empty array instead of nil when result is empty

* [MM-42739] Add additional tests and update permissions check for teams

* [MM-42739] Add excluded channel tests for top reactions

* [MM-42739] Move insights to api4/insights and keep time range as string until required

* [MM-42739] Update queries only check DeleteAt after union

* [MM-42739] Improve query performance by using publicchannels table

* [MM-42739] Fix broken query after merge
2022-04-26 14:42:24 -04:00
Martin Kraft
f460401cf2 Query optimization for top reactions. (#20047) 2022-04-22 13:22:07 -04:00
Agniva De Sarker
0b9f8ef284 MM-43653: Fix incorrect system store update (#20051)
https://mattermost.atlassian.net/browse/MM-43653

```release-note
NONE
```
2022-04-22 20:17:25 +05:30
Miguel de la Cruz
6608f3a9ca Extract binary_parameters handle logic into public methods for external use (#20043) 2022-04-21 15:59:54 +02:00
Jesse Hallam
5bd223c836 MM-43045: minimize JOIN Posts (#19934) 2022-04-19 17:06:31 -03:00
Mylon Suren
99f02fe96e [MM-42742] Add top reactions endpoint (#19850) 2022-04-14 13:09:35 -04:00
Michel Engelen
ca8aea9a06 [MM-41993]: fixed counting thread mentions in unread root post (#19874)
* removed appending the root post to the posts list

also changed `UpdateAt` to `CreateAt` in thread_store.go in accordance with kyriakos

* fixed failing test after latest change

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 12:43:14 -04:00
Agniva De Sarker
7f0d1cf0dd MM-43144: Add teams loader (#19960)
```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 20:51:33 +05:30
Agniva De Sarker
16b1cbd6e3 spelling (#19956)
* spelling: activated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: attachments

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: categories

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: category

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: cellspacing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: channel

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compliance

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constraint

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: counts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: createat

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deactivate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: destination

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exceeded

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: failed

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: foreign

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: hours

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inactivity

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: inappropriate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: initialized

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: management

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: mismatch

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: recipients

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: scheme

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: signature

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: subscription

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: suggestions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: sync

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: telemetry

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: webhook

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* Trigger CI
```release-note
NONE
```

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-11 19:31:19 +05:30
Agniva De Sarker
d1de4857aa MM-43145: channels loader (#19957)
Add channels dataloader

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

```release-note
NONE
```
2022-04-11 13:41:09 +05:30
mkraft
0e4b0b6939 MM-43082: Added new telemetry values for groups. (#19918) 2022-04-08 11:25:40 -04:00
mkraft
ce2646de3e Disambiguates some units. (#19875)
* Disambiguates some units.

* Updates DB attribute.

* Updates some more error-prone units.

* Updates some tests with legible constants.

* Updates query for MySQL case sensitivity.

* Fixes more casing issues.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-07 13:58:40 -04:00
Kyriakos Z
15a9a7ad2f MM-42725: exclude channels from teams user has left (#19939)
Automatic Merge
2022-04-07 20:27:05 +03:00
Guillermo Vayá
302736d4a3 [MM-42889] fixed search term for archived channels (#19937)
* [MM-42889] fixed search term for archived channels

* remove logs

* remove logs x2

Co-authored-by: = <=>
2022-04-07 09:52:48 -04:00
Agniva De Sarker
f93d6d5687 MM-43137: Fix racy test TestUpdateActiveBotsSideEffect (#19935)
This was introduced with 2e027ae927.

We fix it by deep copying the user struct before returning from store.

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

```release-note
NONE
```
2022-04-07 19:21:06 +05:30
Jesse Hallam
3016fa6010 MM-42919: avoid sequential scan on Posts (#19878)
On Postgres, `GetTeamsUnreadForUser` triggers a sequential scan on `Posts`. We can avoid this by querying the `Threads` table directly and only joining to `Posts` to eliminate deleted threads. (We could avoid the latter if we later denormalize `DeleteAt` onto `Threads`.)

Fixes: https://mattermost.atlassian.net/browse/MM-42919
2022-04-06 09:21:01 -03:00
Agniva De Sarker
2e027ae927 Optimize marshalling for jsonb types (#19898)
We check for the presence of binary_parameters
in the DSN and add the 0x01 byte accordingly.

This helps us avoid casting to string
and efficiently use the database.

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-06 15:01:32 +05:30
Jesse Hallam
7b5ac343f0 adopt forked squirrel supporting from UPDATE FROM (#19896)
Fork https://github.com/Masterminds/squirrel as https://github.com/lieut-data/squirrel with the following changes:
* https://github.com/Masterminds/squirrel/pull/256 supporting FROM clause to update builder (Postgres)
* Extension of above to support multiple FROM in UPDATE (Postgres)
* Support for multiple tables in UPDATE (MySQL)

This PR then leverages those changes to simplify a query that previously had to be coded by hand and duplicate for each of MySQL and Postgres.
2022-04-04 09:30:59 -03:00
Ibrahim Serdar Acikgoz
27bd16e5f5 store/channel_store_categories: check if the category has a valid type (#19880)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-04-04 15:05:31 +03:00
Ibrahim Serdar Acikgoz
97d3368a98 update morph dependency (#19891) 2022-04-04 14:03:39 +03:00
Agniva De Sarker
f8a3119426 MM-41260: Revamp ES/Bleve batching logic (#19841)
The older method used to reply completely on timestamps
to take batches of items in a timestamp range and then
just incrementing the timestamp. This led to handling
edge-cases such as more items than the batch count, all
having the same timestamp.

Additionally, relying on timestamp as the page cursor
meant that indexing was not very efficient if you had
several items spread out across large spans of time.

To get away from all of that we use a proper cursor-based
approach consisting of createAt+Id. With this, we move
completely to a constant page size where we can fetch
a given number of objects irrespective of when they
were created. This makes indexing much more faster and
efficient.

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

```release-note
Elasticsearch and Bleve indexing have been revamped to be much
more efficient and faster. The config parameter BulkIndexingTimeWindowSeconds
for both elasticsearch and bleve have been removed.
A new config parameter called BatchSize has been introduced instead.
This parameter controls the number of objects that
can be indexed in a single batch. This makes things
more efficient and maintains a constant workload.
```
2022-03-31 10:46:01 +05:30
Julien Tant
0babc01749 [MM-41998] Channel Info RHS: display number of files for a channel (#19822)
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-25 13:28:14 -07:00
Agniva De Sarker
c1f3827801 MM-38164: Paginate the GetPostThread API (#19485)
We implement a cursor based pagination model
to page through the posts in a given thread.

The cursor is a combination of the post.CreateAt+
post.Id to differentiate multiple posts in a given
timestamp.

Some additional parameters like direction, fromPost,
fromCreateAt and perPage were introduced to implement
this.

```release-note
NONE
```
2022-03-24 12:51:41 +05:30
Agniva De Sarker
68382c5fb7 MM-40272: Ability to resume elasticsearch indexing job (#19812)
Due to the way our community deployment is done. The job server
is restarted every day. This means that whenever there is a job
that takes more than 24 hours, it will always get cancelled
when the server restarts and therefore will never finish.

This PR adds ability to resume any stopped jobs, by storing
intermediate progress in the job metadata and setting
the job to pending instead of cancelled when everything is
shut down.

The user can still cancel a job explicitly by clicking on
the cross button in the system console. That functionality
hasn't changed. Only server stop or stopping/starting
job server via config will pause/resume jobs.

```release-note
The elasticsearch indexing job is resumable now. Stopping a
server while the job is running will put the job in pending status
and will resume the job when the server starts.

The job can still be explicitly cancelled via the system console UI.
```
2022-03-23 13:46:10 +05:30
Ibrahim Serdar Acikgoz
dae769221d [MM-42183] Add a check for mysql collation (#19700)
* add a check for mysql collation

* reflect review comments

* update collation check logic

* save indent
2022-03-21 21:15:12 +03:00
Ben Schumacher
7710a2fe37 [MM-40735] Add MattermostAppID to OAuth app (#19214) 2022-03-15 18:00:27 +01:00
Agniva De Sarker
4da98cb51a Kill gorp (#19786)
* Kill gorp

Gorp is dead. Long live Gorp.

```release-note
NONE
```
2022-03-15 19:49:19 +05:30
Ibrahim Serdar Acikgoz
b03d87af40 [MM-41576] Add schema version to the client configuration (#19757)
* revamp db version and add applied migrations endpoint

* replace old schema version with new

* add db version subcommand

* add to local api

* reflect review comments

* log errors

* remove setting the version from model.CurrentVersion

* fix a test

* use different field for schema version

* add build hash and current version to the support packet

* add tests

* update test to use new assets
2022-03-15 16:39:23 +03:00
Jesse Hallam
47c44a9b7d break up getThreadsForUser, leverage errgroup (#19709)
* MM-42282: handle teamId parameter correctly

As per https://community-daily.mattermost.com/core/pl/ugs7ue6e4j8a7cgegk1bxje8to, `ThreadStore.GetThreadsForUser` accepts a `teamId` parameter, but incorrectly handles an empty value of `""` as looking only for channels with an empty `teamId` (aka DMs and GMs) instead of finding all channels and effectively ignoring the team property.

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

* break up getThreadsForUser, leverage errgroup

This change breaks up `GetThreadsForUser` in the `ThreadStore` into its constituent `GetTotalUnreadThreads`, `GetTotalThreads`, `GetTotalUnreadMentions`, and the original `GetThreadsForUser` but now solely returning the thread structures. Instead of a monolithic method at the store level, the application layer now handles calling bulk requests, leveraging `errgroup` for simpler parallelization.

This change brings with it a few benefits:
* Simpler code, including more idiomatic usage of squirrel
* Simpler SQL, joining tables only when configured conditions require same. (No performance benefit here, since an unused LEFT JOIN generally has no overhead.)
* Discrete Grafana metrics for each store method, giving us better insight into the performance characteristics in play.
* **Performance boost**: reduced overhead when clearing push notifications.

This last point is what prompted the re-re-reactoring in this PR. As I broke things up, I realized that `clearPushNotificationSync` only used the `TotalUnreadMentions`, but asked for the count of total threads and total unread threads. By exposing the discrete methods, this code path avoids two aggregate queries. We clear notifications when marking a thread as read, and when marking a channel with unread mentions as viewed, so I expect we'll see at least a modest boost to performance from simply not wasting these cycles anymore.

No performance improvements are expected from this PR for the general case of using `GetThreadsForUser` to populate the threads view.

* never discard errors from building queries

* no MustSql

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-15 10:29:00 -03:00
Agniva De Sarker
9d10199e5f Removing remaining instances of GetReplica/GetMaster (#19773)
```release-note
NONE
```
2022-03-15 11:14:33 +05:30
Jesse Hallam
b5e78a0ce1 MM-42282: handle teamId parameter correctly (#19685)
As per https://community-daily.mattermost.com/core/pl/ugs7ue6e4j8a7cgegk1bxje8to, `ThreadStore.GetThreadsForUser` accepts a `teamId` parameter, but incorrectly handles an empty value of `""` as looking only for channels with an empty `teamId` (aka DMs and GMs) instead of finding all channels and effectively ignoring the team property.

Fixes: https://mattermost.atlassian.net/browse/MM-42282
2022-03-11 10:57:42 -04:00
Jordan Hewitt
72c6b8fe48 Mm 19333 migrate sql channel store to use squirrel (#19550)
* about to merge with master.

* merge from latest master.

* refactor squirrel function names to match original. clean up extra debugging.

* fix lint.

* reverted websocket_norace_test

* Fix issue of incorrect error being returned.

* made changes from annotated code.

* fix small lint issue.

* remove comment.

* cleaned up code some more.

* fix error with archived tests.

* Cleanup

```release-note
NONE
```

* more cleanup

```release-note
NONE
```

* address review comments

```release-note
NONE
```

* sq.Eq optimization

```release-note
NONE
```

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2022-03-11 19:38:52 +05:30
Ibrahim Serdar Acikgoz
0f918a0aa4 migrations: use go:embed instead of gobindata (#19769) 2022-03-11 14:14:50 +03:00
Tim Scheuermann
caa30c9bc4 MM-19336 Migrated GetMembersByIds and GetMembersByChannelIds to Squirrel (#19728)
* Ported GetMembersByIds and GetMembersByChannelIds to Squirrel

* Added checks for empty ID lists

* Updated GetAllChannelMembersById to use Squirrel

* Added a method to get the query placeholder directly

* Migrated UpdateMultipleMembers to use a Squirrel query

* Migrated UpdateMultipleMembers to Squirrel

* Initialize a prepared query builder for channelMembersForTeamWithSchemeSelectQuery

* Migrated GetMembersForUser to Squirrel

* Slight improvement for constructMySQLJSONArgs

* Migrated UpdateMemberNotifyProps to Squirrel

* Migrated GetMembers to Squirrel

* Migrated GetMember to Squirrel

* Avoid shadowing err

* Don't set query builder on copy of SqlChannelStore

* Fixed typo in error message

* Fixed missing elipsis

* Shorter SQL generation for GetAllChannelMembersById

* Don't unnecessarily copy the reference

* Use a function to generate the ChannelMember map

* Avoid shadowing err

* Don't use IN for matching multiple possible values

* Initialize the members lists

* Remove check for empty channelIDs list

* Fixed test and removed check for empty list

* Use err2 rather than eerr

Co-authored-by: Tim Scheuermann <tim@plusmid.dev>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-11 01:27:09 +05:30
Tim Scheuermann
f5b6e09965 MM-19334 Ported AutocompleteInTeamForSearch to Squirrel (#19723)
Automatic Merge
2022-03-10 21:14:19 +02:00
Jesse Hallam
a2a78577e9 Revert "[MM-41576] Revamp database schema version (#19586)" (#19746)
* Revert "[MM-41576] Revamp database schema version (#19586)"

This reverts commit 645fee3fe3.

* Revert "MM-42049 - license endpoint not working (#19686)"

This reverts commit 4fe89e5847.
2022-03-08 16:28:28 -04:00
Ibrahim Serdar Acikgoz
645fee3fe3 [MM-41576] Revamp database schema version (#19586)
* revamp db version and add applied migrations endpoint

* replace old schema version with new

* add db version subcommand

* add to local api

* reflect review comments

* log errors

* remove setting the version from model.CurrentVersion

* fix a test
2022-03-08 18:13:37 +03:00
Ben Cooke
c82c826960 [MM-41956] Unique name error on update (#19600)
* tools updates

* Revert "tools updates"

This reverts commit 6293297b55803c5a263e200ebd80192899666ae9.

* fixing error id for duplicate name on patch endpoint

* fixing broken test

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MBP.ht.home>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-07 16:15:41 -05:00
Jesse Hallam
f5b5a3c746 MM-40302: CRT, fix performance of MarkAllAsReadInChannels (#19566)
* deadcode: remove UpdateChannelLastViewedAt

* deadcode: remove ThreadStore.(Save(Multiple)|Update|Delete)

* deadcode: followThead in App.MarkChannelAsUnreadFromPost

* document ThreadMembership, Thread structs

* maintain LastUpdated consistently

Whenever we touch a `ThreadMembership` record, we should be setting `LastUpdated` to the current timestamp. The mobile client relies on this to detect changes to these records.

* simplify: never updateThreads from `App.MarkChannelAsUnreadFromPost`

Change all invocations of `ChannelStore.UpdateLastViewedAtPost` from `App.MarkChannelAsUnreadFromPost` to pass `updateThreads` as `false`. When `ChannelStore.UpdateLastViewedAtPost` was invoked with `updateThreads` as `true`, it would in turn call `ThreadStore.UpdateUnreadsByChannel` but pass `updateViewedTimestamp` as `false`. This effectively updated the `LastUpdated` field of the corresponding thread memberships but never touched any of the actual data (such as `LastViewed`).

The overall CRT feature continued to work, because `App.MarkChannelAsUnreadFromPost` directly updates the relevant thread memberships via `ThreadStore.MaintainMembership`.

* deadcode: updateThreads in ChannelStore.UpdateLastViewedAtPost

* simplify: never updateThreads from App.SendNotifications

Change all invocations of `ChannelStore.IncrementMentionCount` from
`App.SendNotifications` to pass `updateThreads` as `false`. When `ChannelStore.IncrementMentionCount` was invoked with `updateThreads` as `true`, it would in turn call `ThreadStore.UpdateUnreadsByChannel` but pass `updateViewedTimestamp` as `false`. This effectively updated the `LastUpdated` field of the corresponding thread memberships but never touched any of the actual data (such as `UnreadMentions`).

The overall CRT feature continued to work, because `App.SendNotifications` directly updates the relevant thread memberships mention counts via `ThreadStore.MaintainMembership`.

* deadcode: updateThreads in ChannelStore.IncrementMentionCount

* fix & rename ThreadStore.UpdateUnreadsByChannel

Rename `ThreadStore.UpdateUnreadsByChannel` to `ThreadStore.UpdateLastViewedByThreadIds`, making it unconditionally set the `LastViewed` for the given threads (as well as `LastUpdated`).

All previous invocations of this method that passed `updateViewedTimestamp` have been previously removed.

* unrelated gofmt -w -s changes to satisfy linter

* always set LastUpdated to model.GetMillis()

* deadcode: ThreadStore.SaveMembership

* fix TestMarkUnreadWithThreads

* MM-40302: CRT, use updateThreads param vs. MarkAllAsReadInChannels

`MarkAllAsReadInChannels` was the subject of a significant performance regression in v5.37 and is known to be very inefficient, by virtue of always writing to an ever increasing number of rows, and doing so on common events like simply viewing a channel.

Fortunately, `ChannelStore.UpdateLastViewedAt` already supported an `updateThreads` parameter that implemented the start of an improved algorithm: query the set of threads with newer posts, and then update only /those/. Missing was the need to reset the `UnreadMentions`, but thanks to the previous simplifications in #19523, we can make this change largely without impacting other semantics.

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

* fix MySQL

* remove another JOIN

* remove outdated comment

* unit tests
2022-03-06 19:55:59 -04:00
Kitae Kim
aefd6c8e0f Migrate buildSearchPostFilterClause to use Squirrel (#19583)
Automatic Merge
2022-03-03 10:34:18 +01:00
Agniva De Sarker
768fe43d3a MM-41752: Batch update mention increment (#19596)
Previously, we were incrementing mentions one-by-one
all concurrently in an unbounded fashion.

This would cause a big spike in memory usage if there
were an `@all` mention in a large channel.

We fix this by changing the SQL query to take all userIDs
at once.

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

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-03 08:50:19 +05:30
Daniel Espino García
d6603b4bf8 [MM-41611] Only check for userId when saving userTermsOfService (#19587)
* Only check for userId when saving userTermsOfService

* Add test

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-03-01 13:17:05 +01:00
Jesse Hallam
6757edc4e2 MM-41349: CRT, fix LastUpdated semantics (#19523)
* deadcode: remove UpdateChannelLastViewedAt

* deadcode: remove ThreadStore.(Save(Multiple)|Update|Delete)

* deadcode: followThead in App.MarkChannelAsUnreadFromPost

* document ThreadMembership, Thread structs

* maintain LastUpdated consistently

Whenever we touch a `ThreadMembership` record, we should be setting `LastUpdated` to the current timestamp. The mobile client relies on this to detect changes to these records.

* simplify: never updateThreads from `App.MarkChannelAsUnreadFromPost`

Change all invocations of `ChannelStore.UpdateLastViewedAtPost` from `App.MarkChannelAsUnreadFromPost` to pass `updateThreads` as `false`. When `ChannelStore.UpdateLastViewedAtPost` was invoked with `updateThreads` as `true`, it would in turn call `ThreadStore.UpdateUnreadsByChannel` but pass `updateViewedTimestamp` as `false`. This effectively updated the `LastUpdated` field of the corresponding thread memberships but never touched any of the actual data (such as `LastViewed`).

The overall CRT feature continued to work, because `App.MarkChannelAsUnreadFromPost` directly updates the relevant thread memberships via `ThreadStore.MaintainMembership`.

* deadcode: updateThreads in ChannelStore.UpdateLastViewedAtPost

* simplify: never updateThreads from App.SendNotifications

Change all invocations of `ChannelStore.IncrementMentionCount` from
`App.SendNotifications` to pass `updateThreads` as `false`. When `ChannelStore.IncrementMentionCount` was invoked with `updateThreads` as `true`, it would in turn call `ThreadStore.UpdateUnreadsByChannel` but pass `updateViewedTimestamp` as `false`. This effectively updated the `LastUpdated` field of the corresponding thread memberships but never touched any of the actual data (such as `UnreadMentions`).

The overall CRT feature continued to work, because `App.SendNotifications` directly updates the relevant thread memberships mention counts via `ThreadStore.MaintainMembership`.

* deadcode: updateThreads in ChannelStore.IncrementMentionCount

* fix & rename ThreadStore.UpdateUnreadsByChannel

Rename `ThreadStore.UpdateUnreadsByChannel` to `ThreadStore.UpdateLastViewedByThreadIds`, making it unconditionally set the `LastViewed` for the given threads (as well as `LastUpdated`).

All previous invocations of this method that passed `updateViewedTimestamp` have been previously removed.

* unrelated gofmt -w -s changes to satisfy linter

* always set LastUpdated to model.GetMillis()

* deadcode: ThreadStore.SaveMembership

* fix TestMarkUnreadWithThreads

* GetMasterX
2022-02-28 16:24:34 -04:00
Allan Guwatudde
81f82729d2 Fixed MM-42027 (#19619)
* [MM-42027] - Invitation Email is resent as a Reminder after invalidating pending email invites

* generate app layers mocks

* add tests

* improve err handling

* fix translations

* change status code
2022-02-25 20:02:08 +03:00
Kitae Kim
a640ba7d05 Fix the broken MariaDB JSON path queries (#19548)
Automatic Merge
2022-02-24 21:04:18 +01:00
Agniva De Sarker
2a59047d07 Moved morph dependency to new repo (#19618)
```release-note
NONE
```

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
2022-02-23 20:11:12 +05:30
Allan Guwatudde
8d6d1c51c2 [MM-40917] - Inactive Server Email Notification (#19374)
* [MM-40917] - Inactive Server Email Notification

* add email template

* make store layers

* add some store tests

* fix translations

* fix logic

* improve

* fix lint

* feedback-impl

* fix wrong text

* optimize queries

* move feature flag check

* feedback impl-1

* add line

* feedback impl

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-02-22 20:41:58 +03:00