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

3118 Коммитов

Автор SHA1 Сообщение Дата
Vishal
44011db725 Add a semaphore (#21027) 2022-09-15 13:38:16 +05:30
Agniva De Sarker
c5d7ac0876 MM-46604: Fix racy access to session props (#20996)
The core mistake was that the webconn doesn't really go out of scope
once the connection disconnects. It is kept in the webhub connIndex
to be reconnected if the user connects again. This was the new
behavior as part of reliable websockets.

Therefore, it was a mistake to return the session to the pool
once the connection drops. Because the connection would still
recieve events from the web_hub.

And once you release the session, another login might acquire the
session and set some props, while the web_hub might still try
to send events to it, which will cause a read of the map prop.

The following test case illustrates such a race. It is very
hard to trigger it organically, hence I artificially wrote
the code.

The right fix is to release the session only when the connection
is stale and gets deleted from the conn index. The PR has been
load tested in `-race` mode just for extra sanity check.

```go
func TestHubSessionRace(t *testing.T) {
  th := Setup(t).InitBasic()
  defer th.TearDown()

  s := httptest.NewServer(dummyWebsocketHandler(t))
  defer s.Close()

  th.Server.HubStart()
  wc1 := registerDummyWebConn(t, th.App, s.Listener.Addr(), th.BasicUser.Id)
  defer wc1.Close()

  var wg sync.WaitGroup
  wg.Add(2)
  go func() {
    defer wg.Done()
    token := wc1.GetSessionToken()
    // Return to pool after *WebConn.Pump finishes
    wc1.App.Srv().userService.ReturnSessionToPool(wc1.GetSession())
    // A new HTTP requests acquires a session which gets it from the pool
    sess, _ := wc1.App.GetSession(token)
    // Login happens which sets some session properties
    sess.AddProp(model.SessionPropPlatform, "chrome")
  }()
  go func() {
    defer wg.Done()
    // Called from *WebConn.shouldSendEvent
    t.Log("session: ", wc1.GetSession().Props[model.SessionPropIsGuest] == "true")
  }()
  wg.Wait()
}
```

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

```release-note
NONE
```
2022-09-14 14:27:24 +05:30
Anurag Shivarathri
203c6a5013 Badge count fix for push notifications when CRT is enabled (#20898)
* Fix

* Fixed other cases and tests

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-12 14:51:33 +05:30
Shivashis Padhi
38aaa9e3d3 [MM-46603] P1 - Improvements in handling '0 posts' channels (#20905)
Automatic Merge
2022-09-09 20:34:00 +03:00
Doug Lauder
1d7822d154 Revert "Allow inline JSON in config.json for advanced logging config (#20954)" (#20983)
This reverts commit 5211d5de15.
2022-09-09 12:56:05 -04:00
Doug Lauder
5211d5de15 Allow inline JSON in config.json for advanced logging config (#20954)
* Allow embedded JSON in config.json for AdvancedLoggingConfig

* fix escaped JSON case

* Add unit test cases for escaped JSON

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-09 07:51:17 -04:00
Nick Misasi
8401a31c3a [MM-44729] Update payment failed email (#20925)
* Update Payment Failed Email

* Actually add the mjml file:

* Fix mjml indentation

* Fix pipelines

* Fix translations

* Fix translations

* Clean up translations

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-08 11:01:50 -04:00
kshitij katiyar
5a718f3c63 MM-29123: Removed the hard coded gitlab.com in Terms of Service error (#20830)
Automatic Merge
2022-09-08 13:04:00 +03:00
Julien Tant
d23c7ed2a3 [MM-46663] Only enable marketplace command completion when config allows it (#20919) 2022-09-06 08:43:34 -07:00
Allan Guwatudde
bd42f0cd8c [MM-45564] - Notify Admin v2 (#20777)
* [MM-45564] - Notify Admin v2

* add dummy data

* update dummy data

* add store methods

* experiment with recurring task

* complete saving of the notification

* make improvements

* make improvements

* add store layer tests

* fix lint

* update store layer tests

* add app layer unit tests

* add store layers

* add app layer tests

* fix lint

* fix lint

* fix tests

* fix tests lint

* fix lint

* fix lint

* fix retry layer test

* add notifications manual trigger

* filter notifications based on current plan

* add test case

* temp change

* feedback impl

* fix translations

* change job scheduler

* refactor job

* fix store layer tests

* extract i18n

* fix lint

* fix translations

* fix translations

* add license statement for new file

* feedback impl-2

* fix lint

* update make file

* add intl ids

* improve

* fix lint

* feedback impl

* move code and rename files

* fix lint

* feedback impl

* add config for trigger notifications api

* fix tests

* tmp change

* undo temp changes

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-02 13:52:48 +03:00
Kyriakos Z
c11ad8995f Adds OmitConnection parameter to broadcast (#20723)
* Adds OmitConnection parameter to broadcast

Currently we have no means to omit sending a websocket event to a
specific connection id.
This is needed mainly so that the initiator won't receive an event for
the action it just initiated.
Will be used for the global drafts feature, so that we won't update
drafts through ws when a user is typing.

This commit adds OmitConnection to the Broadcast struct and to the
NewWebSocketEvent function signature.
shouldSendEvent should return false for that specific connection.

* Return early only if connection id matches the omitted

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-09-02 13:17:22 +03:00
Agniva De Sarker
8f362cb8f6 Revert "Use error log level for websocket timeouts (#19609)" (#20929)
Apparently, this can happen in normal situations as well
and is causing confusion amongst customers. Reverting.

This reverts commit 9534efe534.

```release-note
NONE
```
2022-09-01 21:01:03 +05:30
Tim Scheuermann
aef5165cdc [MM-38705] Move import validators into own package (#20914) 2022-08-31 13:29:37 +02:00
Agniva De Sarker
c72e9131f4 MM-46577: Remove empty translation strings (#20876)
We replace the empty translation key with <untranslated>
which is ignored by the translation check tool.

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

```release-note
NONE
```
2022-08-25 19:59:16 +05:30
Nick Misasi
e8a45a8cf7 [MM-43399] Cloud Delinquency Email Sequence (#20814)
* Add DelinquentSince to Subscription fields

* Stashing, migrating

* Adding file

* Adding many email templates

* Fix templates pipeline

* Fix translations

* Fix mocks

* Many changes

* Adjust mocks

* Update i18n/en.json

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* PR fixes

* Update string

* Update i18n/en.json

Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>

* Update URL's for buttons to open the delinquency modal

* Update emails from mjml

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com>
2022-08-25 09:39:35 -04:00
Shivashis Padhi
e3efc46f69 [MM-43444] Delete profile image and invalidate cache on permanent user deletion (#20033)
* Delete profile image and invalidate cache on permanent user deletion

* Modify request to send 202 with error information on failing to delete profile image
2022-08-25 11:30:50 +05:30
Shivashis Padhi
6adbcc5d05 MM-45899: Insights: least active channels (#20796)
* Add api endpoints, app layers for top inactive channels with dummy store calls

* Add store functions for top inactive channels

* Add model, store, app tests.

* Add client function and api tests

* Add participants information to TopInactiveChannel

* Translation fix

* Style fix while writing response

* Return channelmember IDs instead of profiles, query in batch avoiding inside the loop

* Make the following changes

 - move DeleteAt to subqueries, to avoid select, group by
 - Remove TeamId from response
 - Count bots and webhook posts

* SQL query lint fix, store test fix to include bot messages

* make app-layers

* Fix empty participant lists being sent as [""]

* Track channel joins, to distinguish 0 activity channels vs new channels

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-24 23:14:56 +05:30
Ibrahim Serdar Acikgoz
efbcb0a35a move logger under platform (#20831)
* move logger under platform
2022-08-24 10:10:56 +03:00
Doug Lauder
6a6e05073e Add preferences service API for products (#20869) 2022-08-23 11:57:07 -04:00
Julien Tant
3138543d10 [MM-46468] Change /help and add /marketplace (#20850) 2022-08-23 08:37:06 -07:00
Ibrahim Serdar Acikgoz
ddce3fa47b fix flaky busy test (#20861)
* fix flaky busy test

* increase busy duration
2022-08-23 11:42:04 +03:00
Shivashis Padhi
7643a28263 Merge pull request #20690 from plant99/MM-45118_my_top_dms
[MM-45118] Add insights endpoint for top dms
2022-08-19 19:33:44 +05:30
Ashish Bhate
ff4406e8b2 MM-46402: Use pointer to pointer to set pointer to nil (#20827)
Summary
We need a pointer to a pointer to set the original pointer to nil
The original task was not being set to nil (the local variable containing the pointer was being set to nil). The cancel function was being called even though the task had already been cancelled. This repeated cancellation was causing a panic because we were trying to close a channel that had already been closed the first time the task was cancelled.

Ticket Link
https://mattermost.atlassian.net/browse/MM-46402
2022-08-19 07:27:16 +05:30
Mattermod
e87a2bbe19 Merge branch 'master' into MM-45118_my_top_dms 2022-08-18 20:42:32 +03:00
Vishal
53985ef162 [MM-45730] Fix Sentry crash: nil deference in model/post_list.go:152 (#20742)
* Add check to include ID in Order, only if it exists in Posts

* avoid calling GetPostsBeforePost if lastUnreadPostId is inaccessible
2022-08-18 14:33:33 +05:30
Tim Scheuermann
a28a967eba MM-45991 Wrap errors (#20785) 2022-08-18 11:01:37 +02:00
Ibrahim Serdar Acikgoz
8e0d46e0c6 re-assign cluster interface after initializing enterprise interfaces (#20839)
* re-assign cluster interface after initializing enterprise interfaces

* add a unit test to check if cluster is triggered

* remove env overrides

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-17 23:07:04 +03:00
Doug Lauder
df60c20f86 add userService to the services provided by channels product (#20840) 2022-08-17 11:21:22 -04:00
Agniva De Sarker
d9d75b1a7d MM-45198: Migrate app/import and api4/import (#20799)
We migrate them to use logger context.

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

```release-note
NONE
```
2022-08-17 19:58:52 +05:30
Agniva De Sarker
5e00295b5a MM-38702: Do not fail during importing without attachment (#20800)
We just log a warning instead of failing completely.

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

```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-17 13:36:36 +05:30
Shivashis Padhi
582812f1fc Merge branch 'master' of github.com:mattermost/mattermost-server into top-dms-clean 2022-08-12 17:00:55 +05:30
Martin Kraft
55b3961b98 MM-45120: Track team join times. Add API to retrieve new team members since a given time. (#20708)
* MM-45120: Starts tracking team join time. Adds API to retrieve team members who joined after a given time.

* MM-45120: Updates json casing to match model.User.
2022-08-11 10:38:52 -04:00
Shivashis Padhi
e5c1b17d77 Lint fixes 2022-08-11 12:19:25 +05:30
Shivashis Padhi
4ec3eade3b Merge branch 'master' of github.com:mattermost/mattermost-server into top-dms-clean 2022-08-10 21:00:57 +05:30
Tim Scheuermann
1738bd6e92 [MM-45991] Check and return JSON errors (#20735) 2022-08-10 10:56:58 +02:00
Tim Scheuermann
b4570afa90 Replace deprecated ioutil with io and os (#20776)
* Replace ioutil with io and os

* Replace ioutil in utils/file.go

* Minor fix to tests and excluded files

Co-authored-by: Tim Scheuermann <tim.scheuermann@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-09 14:25:46 +03:00
Ashish Bhate
15b6046a62 MM-44922: Flush log buffer before assert (#20795)
Summary
Flush log buffer before asserting log text.

Ticket Link
https://mattermost.atlassian.net/browse/MM-44922
2022-08-09 16:49:43 +05:30
Agniva De Sarker
97b3ffd7ea MM-43202: Change some 501 response codes to fix SLO violations (#20767)
There were lots of cases where we were using the code 501
in an incorrect manner, and since 5xx codes are considered
as SLO violations, these were flagged by our monitoring incorrectly.

These were the guidelines to change the codes:
1. Any case of missing license or config not correctly enabled
is set as Forbidden. The logic is that the user is correctly
authenticated with a session, but does not have enough privileges
to have the higher license, or hasn't changed the config correctly.
2. Any case of incorrectly formed request is obviously a 400.

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

```release-note
NONE
```
2022-08-08 20:02:49 +05:30
Ibrahim Serdar Acikgoz
f0e4794cda Move config store into Platform Service (#20718)
* update config methods
2022-08-08 16:52:31 +03:00
Mattermod
4fc8ef0125 Merge branch 'master' into MM-45118_my_top_dms 2022-08-05 09:56:52 +03:00
Agniva De Sarker
14246abdef MM-45993: Return errors during sending websocket messages (#20760)
During attaching an object to a websocket message, we would
marshal it to json and attach the string output. But if the
marshalling failed, we would just log a warning and move on.

This would add an empty string to the message. But the client
assumes that the object is correctly attached and would
fail silently if it cannot find it.

So we become more strict and return the error so that
it reaches the caller.

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

```release-note
NONE
```
2022-08-05 08:49:01 +05:30
Agniva De Sarker
151f295d82 MM-45021: Fix flaky testGetFlaggedPostsForUser (#20769)
The method a.postRemoveFromChannelMessage was being called
from a goroutine. Therefore, when SystemAdminClient.GetFlaggedPostsForUser
was being called later in the test with a mock post store,
it would naturally fail because the store would now be a
different store but the goroutine was supposed to be finished.

A hacky solution would be to add a sleep before
starting the mocked API call. But a deeper question
is why was the method run in a goroutine in the first place.

Removing a user from a channel is not a very common operation
and even if we look at the method, if the user is trying to
remove themselves, that message happens synchronously, but if
they are removing another user, that runs in a goroutine.

This seems like a very weird behavior. Therefore, to be consistent
I have just removed the goroutine and made everything synchronous.

The next step would be to stop logging an error and just return
the error upwards instead. Because that's what happens in the other
condition. But that would be exceeding the scope too much. Maybe
in a separate PR.

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

```release-note
NONE
```
2022-08-04 22:07:19 +05:30
Tim Scheuermann
2365f1286b [MM-46054] Log missing default channels (#20738) 2022-08-04 11:15:54 +02:00
Agniva De Sarker
6cc9933b58 Fix minio client breakage with bifrost round 2 (#20758)
* Revert "Revert "MM-43828: Pass object length for some image operations (#20711)" (#20740)"

This reverts commit c7ae090dad.

* Fix to work in bifrost mode

```release-note
NONE
```
2022-08-04 11:21:51 +05:30
Pablo Andrés Vélez Vidal
e7156476fa MM-45542 - do not fail if site url is not set when requesting trial (#20713)
* MM-45542 - do not fail if site url is not set when requesting trial

* remove unnecessary text

Co-authored-by: Pablo Velez Vidal <pablo.velez@mattermost.com>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-03 23:54:43 +02:00
Agniva De Sarker
f07c31c5d9 MM-45196: Migration api4/command and app/cmd to logger context (#20730)
```release-note
NONE
```

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2022-08-02 20:48:54 +05:30
Ibrahim Serdar Acikgoz
ac79a887a2 Move metrics under platform service (continued) (#20732)
* move metrics into platform

Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in>
2022-08-02 10:59:29 +03:00
Agniva De Sarker
55f64195b1 MM-45195: Use api4/bot and app/bot to use logger context (#20729)
https://mattermost.atlassian.net/browse/MM-45195

```release-note
NONE
```
2022-08-01 13:48:45 +05:30
Agniva De Sarker
c7ae090dad Revert "MM-43828: Pass object length for some image operations (#20711)" (#20740)
Automatic Merge
2022-07-29 17:53:14 +03:00
Mattermod
8a532c0b8c Merge branch 'master' into MM-45118_my_top_dms 2022-07-29 10:46:32 +03:00