summaryrefslogtreecommitdiffstats
path: root/plugin/hooks.go
Commit message (Collapse)AuthorAgeFilesLines
* MM-12193: remove auto unmarshalling (#9519)Jesse Hallam2018-10-031-1/+3
| | | | | | | | | | | | | | | | * 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
* MM-11575: change plugin nil semantics (#9212)Jesse Hallam2018-08-031-3/+10
| | | | | | | | * change MessageWillBePosted nil return semantics * change FileWillBeUploaded nil return semantics * use LogDebug to verify plugin inputs vs. the confusing Delete(User|Team)
* Login Hooks (#9177)Daniel Schalla2018-07-301-0/+9
| | | Tests; gofmt
* MM-11431: handle plugin deadlocks (#9167)Jesse Hallam2018-07-271-2/+5
| | | | | | | | | | | | | | | | | | | | | | * ensure plugin is always shutdown Once we call `.client.Client()` the plugin has started, and must be shut down. `newSupervisor` sometimes returned with an error (and without a reference to the supervisor), leaving the client running indefinitely. * Clarify the documentation to explain that plugin hooks will not trigger until `OnActivate` returns successfully, and will stop triggering just before `OnDeactivate` is called. * test for plugin deadlock * plugin/environment.go: switch to sync.Map From: https://golang.org/pkg/sync/#Map > If a goroutine holds a RWMutex for reading and another goroutine might call Lock, no goroutine should expect to be able to acquire a read lock until the initial read lock is released. In particular, this prohibits recursive read locking. This is to ensure that the lock eventually becomes available; a blocked Lock call excludes new readers from acquiring the lock. The previous `RWMutex` was not safe given that we effectively acquired read locks recursively (hook -> api -> hook). This worked up until we activated or deactivated plugins, tried to acquire a write lock, and the plugin used the API to effectively trigger another hook. Switching to sync.Map avoids this by divesting the need to lock at all, avoiding the potential for a recursive lock in the first place.
* Adding FileWillBeUploaded plugin hook (#9169)Christopher Speller2018-07-271-0/+9
| | | | | | | | | | | | | | * Adding file upload hook. * Adding hook test for FileWillBeUploaded * Some debugging fixes. * Fix typo. * Fixing double close * Fix capitalization on docs.
* MM-11292: clean up plugins GoDoc (#9109)Jesse Hallam2018-07-131-7/+10
| | | | | | | | | | | | | | | | | | | * clean up plugins GoDoc: - eliminate plugin.NewBlankContext() as unnecessary - export ValidIdRegex as a string vs. the less readable var - add/update various documentation strings - hide everything by default, except where used by client plugins or the mattermost-server. The exception to this rule are the `*(Args|Returns)` structs which must be public for go-plugin, but are now prefixed with `Z_` with a warning not to use. - include a top-level example to get plugin authors started This is not a breaking change for existing plugins compiled against plugins-v2. * remove commented out ServeHTTPResponseWriter * update examples to match developer docs * add missing plugin/doc.go license header
* First batch of new plugin api methods (#9022)Daniel Schalla2018-07-061-4/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | update api mocks Generated new hooks ChannelHasJoinedChannel Implementation User Left Team/Channel Hook; User Joined Team Hook Implementation Update RPC Client and Mocks gofmt go tests fix Add Config API Methods codegne Add Channel Has Been Created Hook Fix ChannelHasBeenCreated hook fix missing context param fix duplicate hooks; remove redudandcy
* MM-10703 Adding blank request context to plugin hooks for future use. (#9043)Christopher Speller2018-07-061-6/+6
| | | | | | | | | | * Adding blank request context to plugin hooks for future use. * Rename RequestContext to Context * Adding context to ServeHTTP and ExecuteCommand * Fixing import cycle in test.
* MM-10702 Moving plugins to use hashicorp go-plugin. (#8978)Christopher Speller2018-06-251-5/+22
| | | | | | * Moving plugins to use hashicorp go-plugin. * Tweaks from feedback.
* MM-10249 Adding plugin ability to intercept posts before they reach the DB. ↵Christopher Speller2018-05-151-0/+33
| | | | | | | | (#8791) * Adding plugin ability to intercept posts before they reach the DB. * s/envoked/invoked/
* Add plugin slash command support (#7941)Chris2017-12-081-0/+6
| | | | | | | | * add plugin slash command support * remove unused string * rebase
* more plugin doc updates (#7767)Chris2017-11-031-4/+4
|
* Add some plugin docs (#7757)Chris2017-11-021-1/+7
| | | | | | | | | | * add some plugin docs * one more comment * spacing * example simplification
* add missing license headers, test to makefile (#7711)Chris2017-10-251-0/+3
|
* PLT-7407: Back-end plugins (#7409)Chris2017-09-111-0/+3
| | | | | | | | | | | | * tie back-end plugins together * fix comment typo * add tests and a bit of polish * tests and polish * add test, don't let backend executable paths escape the plugin directory
* add plugin http handler (#7289)Chris2017-08-281-0/+11
|
* PLT-7407: Back-end plugin mechanism (#7177)Chris2017-08-161-0/+10
* begin backend plugin wip * flesh out rpcplugin. everything done except for minor supervisor stubs * done with basic plugin infrastructure * simplify tests * remove unused test lines