Commit Graph

465 Commits

Author SHA1 Message Date
George Goldberg
51bd710ecd MM-9728: Online migration for advanced permissions phase 2 (#8744)
* MM-9728: Online migration for advanced permissions phase 2

* Add unit tests for new store functions.

* Move migration specific code to own file.

* Add migration state function test.

* Style fixes.

* Add i18n strings.

* Fix mocks.

* Add TestMain to migrations package tests.

* Fix typo.

* Fix review comments.

* Fix up the "Check if migration is done" check to actually work.
2018-05-14 15:59:04 +01:00
Martin Kraft
91557bbd97 Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2 2018-05-11 08:05:23 -04:00
Christopher Speller
d8dd271e43 MM-4998 Adding LoginIdAttribute to allow LDAP users to change their login ID without losing their account (#8756)
* Adding LoginIdAttribute

* Modifying LDAP to use loginIDAttribute.

* Adding IDAttribute migration and AD objectGUID support.

* Removing unused idea.

* Fix typo.
2018-05-10 09:46:09 -07:00
George Goldberg
11c60ea41a Merge branch 'master' into advanced-permissions-phase-2 2018-05-10 12:03:51 +01:00
Carlos Tadeu Panato Junior
db6b8f6238 fix test and add new (#8759) 2018-05-10 17:56:11 +08:00
Christopher Speller
454c113b4e Removing bad test. 2018-05-09 18:03:28 -07:00
Martin Kraft
d3e14a1bf8 Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2 2018-05-09 15:00:07 -04:00
Saturnino Abril
30fd4a2951 update permission of converting a channel from public to private to allow team admin (#8723) 2018-05-05 02:16:00 +08:00
George Goldberg
60cf74352f MM-10140: API Implementation for Schemes related Endpoints (#8615)
* Implement basic scheme CRUD endpoints.

* Get All Schemes (Paged) Endpoint and store plumbing.

* Add get teams/channels for schemes.

* Fix unit tests.

* Review fixes.

* More review fixes.
2018-05-03 09:00:26 -04:00
Joram Wilander
d6537deb3d Add inactive user count to analytics and fix client analytics function (#8695) 2018-05-02 07:50:56 -07:00
Martin Kraft
f4dcb4edf2 MM-10182 & MM-10183: Adds channel scheme and team scheme API endpoint. (#8680)
* MM-10183: Adds channel scheme API endpoint.

MM-10182: Adds team scheme API endpoint.

MM-10182_3: Switch from scheme_id in path to body.

* MM-10182/MM-10183: Changes path from 'schemes' to 'scheme'.

* MM-10182: Fix merge error.
2018-05-02 07:31:14 -04:00
Martin Kraft
ff6c42309c Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2 2018-05-01 18:59:20 -04:00
Saturnino Abril
30011f67e8 [MM-10354] Add feature to remove team icon (#8684)
* set team.LastTeamIconUpdate to 0 when removing team icon

* add APIv4 for removing team icon

* removed comment and updated typo on AppError
2018-04-30 17:57:57 +08:00
Christopher Speller
686c2fbab7 Structured logging (#8673)
* Implementing structured logging

* Changes to en.json to allow refactor to run.

* Fixing global logger

* Structured logger initalization.

* Add caller.

* Do some log redirection.

* Auto refactor

* Cleaning up l4g reference and removing dependancy.

* Removing junk.

* Copyright headers.

* Fixing tests

* Revert "Changes to en.json to allow refactor to run."

This reverts commit fd8249e99b.

* Fixing some auto refactor strangeness and typo.

* Making keys more human readable.
2018-04-27 12:49:45 -07:00
Corey Hulen
2acbc77d78 MM-10375 Fixing connected socket count (#8682)
* Fixing connected socket count

* Adding unit test
2018-04-27 10:38:40 -07:00
George Goldberg
2386acb3dd Merge branch 'master' into advanced-permissions-phase-2 2018-04-27 10:53:38 +01:00
Jesse Hallam
6d50d836f5 MM-10232, MM-10259: Improve error handling from invalid json (#8668)
* MM-10232: improve error handling from malformed slash command responses

Switch to json.Unmarshal, which doesn't obscure JSON parse failures like
json.Decode. The latter is primarily designed for streams of JSON, not
necessarily unmarshalling just a single object.

* rework HumanizedJsonError to expose Line and Character discretely

* MM-10259: pinpoint line and character where json config error occurs

* tweak HumanizeJsonError to accept err first
2018-04-26 11:19:25 -04:00
Martin Kraft
7294644e9d Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-2 2018-04-24 10:21:18 -04:00
Saturnino Abril
3224d2f6a3 add api to convert a channel from public to private and restrict that to system_admin (#8655) 2018-04-23 08:18:58 -04:00
George Goldberg
cd55c44c8f MM-8796: Full implementation of "Schemes" in Store/Model/App layers. (#8357)
* Add Scheme model and stub store.

* Port ChannelStore to be Scheme aware.

* Make almost all the API/APP layer work with ChannelSchemes.

Only thing still hacky is UpdateChannelMemberRoles().

* Add basic SchemeStore implementation.

* Migrate UpdateChannelMemberRoles properly and fix tests.

* Update store tests and mocks so they work.

* Include creating default roles in Scheme create store function.

* Implement role deletion and start scheme deletion.

* Only use non-deleted roles for authorization.

* Add GetByScheme method to Team store.

* Add GetChannelsByScheme.

* Update store mocks.

* Implement scheme deletion in the store.

* Rename is valid function.

* Add offset and limit to queries to fetch teams and channels by scheme.

* Fix queries.

* Implement scheme awareness in Team store and add a migration.

* Tidy up ChannelStore mapping functions and add exhaustive unit tests.

* Add all missing i18n.

* Proper tests for TeamStore internal functions and fix them.

* Make additional TeamMember fields nullable.

* Make new ChannelMember fields nullable.

* Create new nullable columns without defaults.

* Make new fields in large tables nullalble.

* Fix empty list of TeamMembers.

* Deduplicate SQL queries.

* Fix spelling.

* Fix review comment.

* More review fixes.

* More review fixes.
2018-04-20 14:49:13 -04:00
Jesús Espino
0910eae31d MM-9779: Incorporate a Token into the invitations system (#8604)
* Incorporate a Token into the invitations system

* Adding unit tests

* Fixing some api4 client tests

* Removing unnecesary hash validation

* Change the Hash concept on invitations with tokenId

* Not send invitation if it wasn't able to create the Token

* Fixing some naming problems

* Changing the hash query params received from the client side

* Removed unneded data param in the token usage
2018-04-18 13:46:10 -07:00
Joram Wilander
b15f69ea30 Handle app errors in user autocomplete endpoint (#8643) 2018-04-17 15:39:08 -07:00
Daniel Schalla
997df03ac1 Initial Commit of Ephemeral Message Support for System Admins (#8611)
Fixed Permission Test

Fixed and extended ephemeral message tests; Removed Online/Activity Updates

Set Create Time to current time

gofmt
2018-04-17 08:20:47 -04:00
Christopher Speller
ba6f9075c1 Fix opengraph images not going through the image proxy. (#8627) 2018-04-16 09:00:59 -04:00
Joram Wilander
21b1cd44e0 Fix error handling when requesting profile image for bad user ID (#8618) 2018-04-13 07:57:22 -07:00
Stan Chan
7826774a14 Add Auto Responder handler (#8386)
WIP Out Of Office

Return error for status command if user status is OOO

Ignore notifications if Out Of Office

Disable AutoResponder if status is set to online

Add test for AutoResponder

DisableAutoResponse when manually setting status

Remove check on status slash command

return early if user does not exists in SendAutoResponse method

Add proper error handling

Add a newline after error handling

Revert back to err == nil in api4/status.go

Remove a.Go when using a.Publish

Add name consistency with the feature auto responder

Last changes for name consistency, also fix failing test with auto_responder

Fix names of functions in auto responder test

Add ExperimentalEnableAutomaticReplies flag

Auto Responder reply to a post
2018-04-12 15:02:36 -04:00
Harrison Healey
0a6b96cb40 MM-9849 Added tracking of which settings are set through environment variables (#8586)
* MM-9849 Added tracking of which settings are set through environment variables

* Removed old version of viper

* Added forked version of viper

* Fixed unit tests

* Fixed more unit tests

* Removed copy from App.GetEnvironmentConfig
2018-04-09 18:16:11 +02:00
Christopher Speller
80925f7cfd Fixing unit tests for Go 1.10 (#8568) 2018-04-03 15:41:02 -04:00
Christopher Speller
cf1688f94a Fixing DB load causing user logout. (#8559) 2018-04-02 08:22:25 -07:00
Christopher Speller
59606791a7 MM-9999 Fix unwanted team invite_id in email invites. (#8550)
* Fix unwanted team invite_id in email invites.

* Removing unused translation.
2018-03-29 14:20:36 -07:00
Jesús Espino
014a3b6a60 Fixing misspell errors (#8544) 2018-03-29 10:04:54 -04:00
George Goldberg
71c9dff766 Merge branch 'advanced-permissions-phase-1' 2018-03-27 22:36:55 +01:00
Saturnino Abril
07b14c370a post a system message after a channel is converted from public to private (#8501) 2018-03-27 21:14:42 +08:00
Martin Kraft
e13e64711f Merge remote-tracking branch 'origin/master' into advanced-permissions-phase-1 2018-03-27 09:01:42 -04:00
Jesse Hallam
8491ba5740 Relax 4k post message limit (#8478)
* MM-9661: rename POST_MESSAGE_MAX_RUNES to \0_v1

* MM-9661: s/4000/POST_MESSAGE_MAX_RUNES_V1/ in tests

* MM-9661: introduce POST_MESSAGE_MAX_RUNES_V2

* MM-9661: migrate Postgres Posts.Message column to TEXT from VARCHAR(4000)

This is safe to do in a production instance since the underyling type is
not changing. We explicitly don't do this automatically for MySQL, but
also don't need to since the ORM would have already created a TEXT column
for MySQL in that case.

* MM-9661: emit MaxPostSize in client config

This value remains unconfigurable at this time, but exposes the current
limit to the client. The limit remains at 4k in this commit.

* MM-9661: introduce and use SqlPostStore.GetMaxPostSize

Enforce a byte limitation in the database, and use 1/4 of that value as
the rune count limitation (assuming a worst case UTF-8 representation).

* move maxPostSizeCached, lastPostsCache and lastPostTimeCache out of the global context and onto the SqlPostStore

* address feedback from code review:

* ensure sqlstore unit tests are actually being run
* move global caches into SqlPostStore
* leverage sync.Once to address a race condition

* modify upgrade semantics to match new db semantics

gorp's behaviour on creating columns with a maximum length on Postgres
differs from MySQL:
* Postgres
  * gorp uses TEXT for string columns without a maximum length
  * gorp uses VARCHAR(N) for string columns with a maximum length of N
* MySQL
  * gorp uses TEXT for string columns with a maximum length >= 256
  * gorp uses VARCHAR(N) for string columns with a maximum length of N
  * gorp defaults to a maximum length of 255, implying VARCHAR(255)

So the Message column has been TEXT on MySQL but VARCHAR(4000) on
Postgres. With the new, longer limits of 65535, and without changes to
gorp, the expected behaviour is TEXT on MySQL and VARCHAR(65535) on
Postgres. This commit makes the upgrade semantics match the new database
semantics.

Ideally, we'd revisit the gorp behaviour at a later time.

* allow TestMaxPostSize test cases to actually run in parallel

* default maxPostSizeCached to POST_MESSAGE_MAX_RUNES_V1 in case the once initializer panics

* fix casting error

* MM-9661: skip the schema migration for Postgres

It turns out resizing VARCHAR requires a rewrite in some versions of
Postgres, but migrating VARCHAR to TEXT does not. Given the increasing
complexity, let's defer the migration to the enduser instead.
2018-03-26 17:55:35 -04:00
Christopher Speller
4a69c277a6 Adding go client support and basic unit tests for channel autocomplete. (#8510) 2018-03-26 12:41:06 -07:00
George Goldberg
ca5198c7b6 Ignore blank role names in getRolesByName call. (#8507) 2018-03-26 13:56:57 +02:00
Elias Nahum
67c0efae1b Allow to get the team icon for open teams (#8499)
* Allow to get the team icon for open teams

* feedback review
2018-03-23 16:49:18 +03:00
Martin Kraft
5fa1b35819 Merge branch 'master' into advanced-permissions-phase-1 2018-03-23 09:08:49 -04:00
Chris Duarte
74e703f58d Timezone feature (#8185)
* Add supported timezones into config

Remove Timezone list creation in favor of timezone from configs

Add Timezone field to Users table

Clean up format of SupportedTimezones in config

* Remove unwanted change

* Add test for updating user timezone

* Add empty map[string]string if Timezone is null

* Add EnableTimezoneSelection config

* Revert back to map[string]string for ClientConfig

* Refactor SupportedTimezones into timezones.json

* Include timezones.json in TestConfigFlag

* Add timezone api endpoint

* Bump varchar size to 256 and setMaxSize in user_store

* Refactor LoadConfig to LoadConfig and LoadTimezoneConfig

* Remove unnecessary argument in LoadConfig, mail_test

* Add test for timezone endpoint

* Add license header

* Refactor timezones endpoint to system.go

* Add system base route to timezone endpoint

* db timezone upgrade in db v4.9

* Avoid saving SupportedTimezones to config.json

* Add timezonePath support in config

* Remove EnableTimezoneSelection from config

* Use return statement without return parameter

* Refactor test for SupportedTimezones

* Check for supportedTimezone != nil instead of using len

* Decouple SupportedTimezones out of Config

* Fix failing test

* Add LastTeamIconUpdate back in upgrade.go

* Write timezone config in config_flag_test

* Add code fallback for default timezone support
2018-03-22 09:53:43 -04:00
Jesse Hallam
9d701c7044 Fix various segfaults when running go test manually (#8448)
* failing to find i18n shouldn't segfault

The server was trying to handle the fact that it couldn't find the i18n
directory, by emitting a translated log message...

* fix utils.FindDir

The attempts to find the directory in the parent or grandparent directory
don't work if the current working directory was inside `enterprise`, with
`enterprise` itself being a symlink as per the usual developer setup.

Recurse to the root of the filesystem, cleaning the path along the way
to work around this limitation (and allow tests to be run from an
arbitrarily deep nesting level.)

Fix corresponding usages to employ filepath.Join.

* failing to find html templates shouldn't segfault

* fail fast if the test user cannot be created

* rework utils.FindDir to retain backwards compatibility
2018-03-21 18:27:14 +00:00
Joram Wilander
b1b23079c6 Fix paging for GET /teams and GET /teams/{id}/members endpoints (#8488) 2018-03-21 23:33:47 +08:00
George Goldberg
37f0e5e0eb Merge branch 'master' into advanced-permissions-phase-1 2018-03-19 10:53:37 +00:00
Carlos Tadeu Panato Junior
db4402c40d remove s3 region to be mandatory and fix when user call test s3 when the config is saved (#8454) 2018-03-14 00:26:56 +08:00
Carlos Tadeu Panato Junior
1b29b50330 update email test in the driver to be able to send the config in the body (#8453)
Signed-off-by: cpanato <ctadeu@gmail.com>
2018-03-13 10:42:56 -05:00
George Goldberg
fadcdd271a Merge branch 'master' into advanced-permissions-phase-1 2018-03-13 13:36:23 +00:00
Harrison Healey
4e26594fcb Removed mssola/user_agent library (#8417)
* Removed mssola/user_agent library

* Changed user agent tests to use t.Run
2018-03-12 10:21:20 -04:00
Stephen Kiers
302dae5bb9 MM-9274- Sort Users in Channel by status (#8181)
* sort by lastActivity

* added status ordering to Users

* sort offline before dnd

* remove data not needed

* added seperate call for when order=‘status’ is on GetUser request

* remove PrintLn

* styling fix

* remove mistake

* mistake 2

* better comment

* explicit if statemnt

* writing tests

* removed manually added mocks

* generated mock

* ICU-668 Added unit tests

* style fix

* sort by lastActivity

* added status ordering to Users

* sort offline before dnd

* remove data not needed

* added seperate call for when order=‘status’ is on GetUser request

* remove PrintLn

* styling fix

* remove mistake

* mistake 2

* better comment

* explicit if statemnt

* writing tests

* removed manually added mocks

* generated mock

* ICU-668 Added unit tests

* style fix

* reverse dnd and offline

* Fixed app.SaveStatusAndBroadcast

* Fixed incorrect merge

* Fixing incorrect merge again
2018-03-09 07:48:30 -05:00
Chris
e8943936c5 general cleanup (#8387) 2018-03-07 12:36:40 -06:00
Jesús Espino
b66e4bc932 MM-8830 Consistent Incomming/Outgoing webhooks permissions (#8335) 2018-03-07 14:54:47 +00:00