Commit Graph

25 Commits

Author SHA1 Message Date
Christopher Speller
06b579d18a MM-12393 Server side of bot accounts. (#10378)
* bots model, store and api (#9903)

* bots model, store and api

Fixes: MM-13100, MM-13101, MM-13103, MM-13105, MMM-13119

* uncomment tests incorrectly commented, and fix merge issues

* add etags support

* add missing licenses

* remove unused sqlbuilder.go (for now...)

* rejig permissions

* split out READ_BOTS into READ_BOTS and READ_OTHERS_BOTS, the latter
implicitly allowing the former
* make MANAGE_OTHERS_BOTS imply MANAGE_BOTS

* conform to general rest api pattern

* eliminate redundant http.StatusOK

* Update api4/bot.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* s/model.UserFromBotModel/model.UserFromBot/g

* Update model/bot.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* Update model/client4.go

Co-Authored-By: lieut-data <jesse.hallam@gmail.com>

* move sessionHasPermissionToManageBot to app/authorization.go

* use api.ApiSessionRequired for createBot

* introduce BOT_DESCRIPTION_MAX_RUNES constant

* MM-13512 Prevent getting a user by email based on privacy settings (#10021)

* MM-13512 Prevent getting a user by email based on privacy settings

* Add additional config settings to tests

* upgrade db to 5.7 (#10019)

* MM-13526 Add validation when setting a user's Locale field (#10022)

* Fix typos (#10024)

* Fixing first user being created with system admin privilages without being explicity specified. (#10014)

* Revert "Support for Embeded chat (#9129)" (#10017)

This reverts commit 3fcecd521a.

* s/DisableBot/UpdateBotActive

* add permissions on upgrade

* Update NOTICE.txt (#10054)

- add new dependency (text)
- handle switch to forked dependency (go-gomail -> go-mail)
- misc copyright owner updates

* avoid leaking bot knowledge without permission

* [GH-6798] added a new api endpoint to get the bulk reactions for posts (#10049)

* 6798 added a new api to get the bulk reactions for posts

* 6798 added the permsission check before getting the reactions

* GH-6798 added a new app function for the new endpoint

* 6798 added a store method to get reactions for multiple posts

* 6798 connected the app function with the new store function

* 6798 fixed the review comments

* MM-13559 Update model.post.is_valid.file_ids.app_error text per report (#10055)

Ticket: https://mattermost.atlassian.net/browse/MM-13559
Report: https://github.com/mattermost/mattermost-server/issues/10023

* Trigger Login Hooks with OAuth (#10061)

* make BotStore.GetAll deterministic even on duplicate CreateAt

* fix spurious TestMuteCommandSpecificChannel test failure

See
https://community-daily.mattermost.com/core/pl/px9p8s3dzbg1pf3ddrm5cr36uw

* fix race in TestExportUserChannels

* TestExportUserChannels: remove SaveMember call, as it is redundant and used to be silently failing anyway

* MM-13117: bot tokens (#10111)

* eliminate redundant Client/AdminClient declarations

* harden TestUpdateChannelScheme to API failures

* eliminate unnecessary config restoration

* minor cleanup

* make TestGenerateMfaSecret config dependency explicit

* TestCreateUserAccessToken for bots

* TestGetUserAccessToken* for bots

* leverage SessionHasPermissionToUserOrBot for user token APIs

* Test(Revoke|Disable|Enable)UserAccessToken

* make EnableUserAccessTokens explicit, so as to not rely on local config.json

* uncomment TestResetPassword, but still skip

* mark assert(Invalid)Token as helper

* fix whitespace issues

* fix mangled comments

* MM-13116: bot plugin api (#10113)

* MM-13117: expose bot API to plugins

This also changes the `CreatorId` column definition to allow for plugin
ids, as the default unless the plugin overrides is to use the plugin id
here. This branch hasn't hit master yet, so no migration needed.

* gofmt issues

* expunge use of BotList in plugin/client API

* introduce model.BotGetOptions

* use botUserId term for clarity

* MM-13129 Adding functionality to deal with orphaned bots (#10238)

* Add way to list orphaned bots.

* Add /assign route to modify ownership of bot accounts.

* Apply suggestions from code review

Co-Authored-By: crspeller <crspeller@gmail.com>

* MM-13120: add IsBot field to returned user objects (#10103)

* MM-13104: forbid bot login (#10251)

* MM-13104: disallow bot login

* fix shadowing

* MM-13136 Disable user bots when user is disabled. (#10293)

* Disable user bots when user is disabled.

* Grammer.

Co-Authored-By: crspeller <crspeller@gmail.com>

* Fixing bot branch for test changes.

* Don't use external dependancies in bot plugin tests.

* Rename bot CreatorId to OwnerId

* Adding ability to re-enable bots

* Fixing IsBot to not attempt to be saved to DB.

* Adding diagnostics and licencing counting for bot accounts.

* Modifying gorp to allow reading of '-' fields.

* Removing unnessisary nil values from UserCountOptions.

* Changing comment to GoDoc format

* Improving user count SQL

* Some improvments from feedback.

* Omit empty on User.IsBot
2019-03-05 07:06:45 -08:00
Shobhit Gupta
b4d645f121 [MM-13746] Add GetTeamMembersForUser and GetChannelMembersForUser apis (#10269)
* Add GetTeamMembersForUser and GetChannelMembersForUser apis

* Address comments

* Fix tests

* Fix test

* Fix comment

* Fix minimum server version

* Change to []*model.ChannelMember

* Fix panic, add more tests

* Remove print statement
2019-02-23 11:41:19 -08:00
Shreyansh Chouhan
39ceaa3e86 [MM-13833] Configured unit tests to log through t.Log (#10272)
* 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
2019-02-14 13:52:11 -04:00
Andrew Braunstein
c08fda1337 Added the SearchPostsInTeam method to the plugin API (#10106) 2019-02-13 07:41:32 +01:00
dom3k
2c9cf41dad [MM-13747] Add ability to list users to plugin API (#10102)
* add GetUsers in plugin api

* change GetUsers(page int, perPage int) ([]*model.User, *model.AppError) to GetUsers(options *model.UserGetOptions) ([]*model.User, *model.AppError)

* Update GetUsers doc

Co-Authored-By: dom3k <szeptweb@gmail.com>

* Update doc in plugin/api.go

Co-Authored-By: dom3k <szeptweb@gmail.com>

* correct database initialization for the test

* Update plugin/api.go

Co-Authored-By: dom3k <szeptweb@gmail.com>
2019-01-30 12:55:02 -05:00
Adzim Zul Fahmi
dfb9241e82 [MM-13750] Add ability to search teams to plugin API (#10116)
Add SearchTeams in plugin/api,
2019-01-16 09:13:15 +01:00
Carlos Tadeu Panato Junior
f8b87cbe2d Add SendMail to plugin API (#10082)
* Add SendMail to plugin API

* Update per feedback

Co-Authored-By: cpanato <ctadeu@gmail.com>
2019-01-10 10:06:14 +01:00
Vaibhav Thakkar
dbd3801271 Add GetFile API in app and plugin (#9820) 2018-12-13 10:46:42 +01:00
akhilanandbv003
11059b0251 Gh 9610 add plugin api for update user active method (#9854)
* wip

* wip

* After running make plugin-mocks

* Add
TestUpdateUserActive and run make pluginapi

* Adding plugin_api_test.go

* Better formatting of code using gofmt

* Fix tests and run make pluginapi

* Specify the minimum server version on the comments

* Include more tests as per the CR

* Fix tests

* Checking err.Id intsead of err & Removed comments and trailing spaces

* wip

* Fix tests as per CR and spaces

* Make changes to tests as per CR
2018-12-12 10:18:40 -05:00
Jesse Hallam
6d9b4bc277 fix two page, perPage -> offset, limit mistranslations (#9904)
* fix two page, perPage -> offset, limit mistranslations

* add TestPluginAPIGetUsersInTeam
2018-11-29 13:02:06 -05:00
Carlos Tadeu Panato Junior
1bcf08aa4b Refactor Get/Create Direct Channel into one function (#9867)
* refactor GetDirectChannel and CreateDirectChannel in one function

* remove CreateDirectChannel plugin api and update GetDirectChannel and GetGroupChannel plugin api

* update tests
2018-11-28 18:01:49 +01:00
Carlos Tadeu Panato Junior
cae7798d76 add CreateDirectChannel plugin api (#9848) 2018-11-21 11:36:02 +01:00
Carlos Tadeu Panato Junior
2555a5d45d Add RemoveTeamIcon plugin api (#9847) 2018-11-20 15:43:42 +01:00
Jesse Hallam
c46d8ec892 MM-12974: guard app plugins with mutex (#9818)
* guard app plugins with mutex

Shutting down the app could race with a goroutine that uses the plugins environment, since we shut down the plugins first before cleaning up goroutines.

* fix go vet issues
2018-11-20 08:52:51 -05:00
Hanzei
0a73690537 Remove *model.ChannelList from plugin API return parameter (#9844)
* Remove *model.ChannelList from plugin API return parametern

* Fix panic

* Add tests

* Changes as requested

* Fix panic in GetPublicChannelsForTeam()
2018-11-20 08:50:34 -05:00
Sandeep Sukhani
7a6f957638 [MM-11861] Design & implement a better way for plugins to update their own configuration (#9712)
* [MM-11861] Design & implement a better way for plugins to update their own configuration

Added GetPluginConfig and SavePluginConfig plugin APIs.
Added test cases for testing new APIs.

* Fixed gofmt error

* Minor changes requested in PR
2018-11-19 12:27:15 -05:00
Carlos Tadeu Panato Junior
bffac3f09f add SetTeamIcon plugin api (#9840) 2018-11-16 10:52:07 -05:00
Carlos Tadeu Panato Junior
7a8d7e53cc Add GetTeamIcon plugin api method (#9837) 2018-11-16 08:17:42 -05:00
Carlos Tadeu Panato Junior
b29f1cb844 Add SetProfileImage for plugin API (#9831) 2018-11-15 21:23:03 +01:00
Hanzei
e67d89b9a8 Add plugin methods to plugin API (#9744) 2018-11-08 10:17:07 -08:00
Christopher Speller
ecade2f1ec MM-12849 Moving all non request scoped items to Server struct (#9806)
* Moving goroutine pool

* Auto refactor

* Moving plugins.

* Auto refactor

* Moving fields to server

* Auto refactor

* Removing siteurl duplication.

* Moving reset of app fields

* Auto refactor

* Formatting

* Moving niling of Server to after last use

* Fixing unit tests.
2018-11-07 10:20:07 -08:00
Alexander Akhmetov
160d278592 GH-9633 Added plugin API method to return user's profile image (#9653) 2018-10-15 16:23:41 +02:00
Jesse Hallam
580b546862 MM-12193: remove auto unmarshalling (#9519)
* MM-12193: remove auto configuration unmarshalling

Since plugin hook events are called concurrently, there's no way for the plugin framework to coordinate safe access to the automatically unmarshalled configuration fields. Remove this functionality, and update documentation to illustrate a safe way to do this.

* better Fprint example

* fix unit tests

* log when OnConfigurationChange fails through OnActivate

* clarify lifecycle when OnConfigurationChange returns an error

* call SetAPI even if OnConfigurationChange not implemented
2018-10-03 13:13:19 -04:00
Christopher Speller
5a2d46c6cb MM-11028 Adding some plugin tests. (#9103)
* Rearranging plugin mocks and moving some common test code out.

* Adding tests.

* Fixing tests after GoDoc cleanup changes.
2018-07-18 16:35:12 -07:00
Joram Wilander
275731578e MM-10254 Add plugin APIs for getting/updating user statuses (#9101)
* Add plugin APIs for getting/updating user statuses

* Add and update tests

* Updates per feedback
2018-07-16 15:49:26 -04:00