* Move some variables out of model
There were some stuff that's not necessary to be in model
and can just remain unexported variables.
```release-note
NONE
```
* Add license
```release-note
NONE
```
th.InitBasic initializes users, channels, and teams. But a lot of
tests don't use it at all, causing unncessary delays. A single InitBasic
call takes around 400ms. This PR removes 71 of them, approximately shaving
off 28 seconds. Arguably, this would be more because some tests run in loops.
- replace all instances of `fmt.Sprintf("whatever")` with simply "whatever".
- replace all instances of `fmt.Println(fmt.Sprintf("whatever %d", i))` with `fmt.Printf("whatever %d\n", i)`
* change how we are parsing the args.command
* change comment
* atttempt to write unit test
* remove quotes
* use unicode.IsSpace
* MM-21343 fix panic
* use table
* test cases
* bad request, add test for missing '/'
* mispelled err
* Update app/command.go
Co-Authored-By: Jesse Hallam <jesse.hallam@gmail.com>
* Update app/command.go
Co-Authored-By: Jesse Hallam <jesse.hallam@gmail.com>
* use a map
* use subtest and add test case of empty command
* go fmt
* do not use t.fatal
* Update app/command.go
Co-Authored-By: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
* fix missing unicode import
Co-authored-by: wiggin77 <wiggin77@warpmail.net>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Co-authored-by: Bot from GolangCI <42910462+golangcibot@users.noreply.github.com>
* Create infrastructure to manage mentions
Two new files have been added (along with their tests); namely:
- model/at_mentions.go: utilities to parse and manage mentions; for the moment,
it just contains a regex and a couple of functions to parse possible mentions
and to post-process them, but it can be extended in the future.
- model/mention_map.go: it contains two new types (UserMentionMap and
ChannelMentionMap) that both have FromURLValues and ToURLValues. These types
can be used when adding the mentions to the payload of the plugin slash
commands.
* Extend custom commands payload with mentions
Two couples of new fields are added to the payload; namely:
- user_mentions and user_mentions_ids: two aligned arrays of the same length
containing all the different @-mentions found in the command: the i-th element
of user_mentions_ids is the user identifier of the i-th element of
user_mentions.
- channel_mentions and channel_mentions_ids: two aligned arrays of the same
length containing all the different ~-mentions found in the command: the i-th
element of channel_mentions_ids is the channel identifier of the i-th element
of channel_mentions.
* Fix shadowing of variables and redundant return
* Fix shadowing of variable
* Address review comments (HT @lieut-data)
- Improvements in mentionsToTeamMembers and mentionsToPublicChannels:
- Scope implementation details inside the functions.
- Improve goroutines synchronization by using a sync.WaitGroup.
- Retry lookup of username only if the returned error is http.StatusCode,
so we can return early if the error is more severe.
- Invert check in PossibleAtMentions to improve readability.
- Make user and channel mention keys private to the module.
- Allow the specification of an empty map of mentions in
(Channel|User)MentionsFromURLValues when both mentions keys are absent.
- Replace custom functions in tests with require.Equal on maps.
* Test functions to parse mentions from messages
* Extend plugin commands payload with mentions
* Add functions to CommandArgs to add mentions
The functions make sure that the maps are initialized before adding any value.
* Address review comments (HT @lieut-data)
- Adds a mlog.Warn to avoid burying the error when the user is not found.
- Improve readability in loop populating the mention map by moving the
initialization of the map closer to the loop and by iterating over the channel
itself, not over its length.
* File was not gofmt-ed with -s
* Close channel when all goroutines are finished
* Again, all code should be checked with gofmt -s
* Refactor code out of a goroutine
This change helps improve the readability of the code and does not affect its
overall performance. Less complexity is always better.
* Close channel and iterate over its range
Adapt mentionsToPublicChannels to have the same structure in the management
of the mentions channel as in mentionsToTeamMembers.
* Adapt mentionsToTeamMembers to new App
Commit 17523fa changed the App structure, making the *Server field
private, which is now accessed through the Srv() function.
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
* Consistent license message for all the go files
* Fixing the last set of unconsistencies with the license headers
* Addressing PR review comments
* Fixing busy.go and busy_test.go license header
#### Summary
Unfortunately, `which shadow` didn't resolve to the shadow binary, so hard-code the expected path in `$GOPATH/bin`. At the same time, run `go vet` across both the server and enterprise (if present), reducing the number of required invocations.
This is accompanied by an enterprise change to fix shadowing issues there.
#### Ticket Link
N/A (tooling upgrade)
#### Checklist
- [x] Has enterprise changes: https://github.com/mattermost/enterprise/pull/403
* Rerouted the unit test logs through t.Log
* resolving merge confilvts
* Update testing.go
* Update helper_test.go
* Added godocs for NewTestingLogger
* Added go docs for NewTestingLogger
* Resolving conflicts
* MM 10658 Change config fields to pointers (#8898)
* Change fields of config structs to pointers and set defaults
MM-10658 https://github.com/mattermost/mattermost-server/issues/8841
* Fix tests that go broken during switching config structs to pointers
MM-10658 https://github.com/mattermost/mattermost-server/issues/8841
* Apply changes of current master while switching config structs to pointers
MM-10658 https://github.com/mattermost/mattermost-server/issues/8841
* Fix new config pointer uses
* Fix app tests
* Fix mail test
* remove debugging statement
* fix TestUpdateConfig
* assign config consistently
* initialize AmazonS3Region in TestS3TestConnection
* initialize fields for TestEmailTest
* fix TestCheckMandatoryS3Fields